comparison libervia/server/pages.py @ 1465:a410db730301

pages: keep `page_max` if set in query params in `setPagination`: rel 399
author Goffi <goffi@goffi.org>
date Thu, 30 Sep 2021 17:01:20 +0200
parents a8435aebfbcc
children 83dce05226ac
comparison
equal deleted inserted replaced
1464:a8435aebfbcc 1465:a410db730301
985 # RSM returns list in order (oldest first), but we want most recent first 985 # RSM returns list in order (oldest first), but we want most recent first
986 # so we start by the end 986 # so we start by the end
987 extra['rsm_before'] = "" 987 extra['rsm_before'] = ""
988 return extra 988 return extra
989 989
990 def setPagination(self, request, pubsub_data): 990 def setPagination(self, request: server.Request, pubsub_data: dict) -> None:
991 """Add to template_data if suitable 991 """Add to template_data if suitable
992 992
993 "previous_page_url" and "next_page_url" will be added using respectively 993 "previous_page_url" and "next_page_url" will be added using respectively
994 "before" and "after" URL parameters 994 "before" and "after" URL parameters
995 @param request(server.Request): current HTTP request 995 @param request: current HTTP request
996 @param pubsub_data(dict): pubsub metadata 996 @param pubsub_data: pubsub metadata
997 """ 997 """
998 template_data = request.template_data 998 template_data = request.template_data
999 extra = {} 999 extra = {}
1000 try: 1000 try:
1001 rsm = pubsub_data["rsm"] 1001 rsm = pubsub_data["rsm"]
1006 1006
1007 # if we have a search query, we must keep it 1007 # if we have a search query, we must keep it
1008 search = self.getPostedData(request, 'search', raise_on_missing=False) 1008 search = self.getPostedData(request, 'search', raise_on_missing=False)
1009 if search is not None: 1009 if search is not None:
1010 extra['search'] = search.strip() 1010 extra['search'] = search.strip()
1011
1012 # same for page_max
1013 page_max = self.getPostedData(request, 'page_max', raise_on_missing=False)
1014 if page_max is not None:
1015 extra['page_max'] = page_max
1011 1016
1012 if rsm.get("index", 1) > 0: 1017 if rsm.get("index", 1) > 0:
1013 # We only show previous button if it's not the first page already. 1018 # We only show previous button if it's not the first page already.
1014 # If we have no index, we default to display the button anyway 1019 # If we have no index, we default to display the button anyway
1015 # as we can't know if we are on the first page or not. 1020 # as we can't know if we are on the first page or not.