diff options
Diffstat (limited to 'forum/middleware/pagesize.py')
-rwxr-xr-x | forum/middleware/pagesize.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/forum/middleware/pagesize.py b/forum/middleware/pagesize.py index f6e6fcfd..486193dc 100755 --- a/forum/middleware/pagesize.py +++ b/forum/middleware/pagesize.py @@ -3,30 +3,30 @@ QUESTIONS_PAGE_SIZE = 10 class QuestionsPageSizeMiddleware(object): def process_request(self, request): # Set flag to False by default. If it is equal to True, then need to be saved. - pagesize_changed = False - # get pagesize from session, if failed then get default value - user_page_size = request.session.get("pagesize", QUESTIONS_PAGE_SIZE) - # set pagesize equal to logon user specified value in database + page_size_changed = False + # get page_size from session, if failed then get default value + user_page_size = request.session.get("page_size", QUESTIONS_PAGE_SIZE) + # set page_size equal to logon user specified value in database if request.user.is_authenticated() and request.user.questions_per_page > 0: user_page_size = request.user.questions_per_page try: - # get new pagesize from UI selection - pagesize = int(request.GET.get('pagesize', user_page_size)) - if pagesize <> user_page_size: - pagesize_changed = True + # get new page_size from UI selection + page_size = int(request.GET.get('page_size', user_page_size)) + if page_size <> user_page_size: + page_size_changed = True except ValueError: - pagesize = user_page_size + page_size = user_page_size - # save this pagesize to user database - if pagesize_changed: + # save this page_size to user database + if page_size_changed: if request.user.is_authenticated(): user = request.user - user.questions_per_page = pagesize + user.questions_per_page = page_size user.save() - # put pagesize into session - request.session["pagesize"] = pagesize + # put page_size into session + request.session["page_size"] = page_size def process_exception(self,request,exception): import logging |