- def session_preferences(self, request):
- return request.session.get('paginator_%s%s' % (self.prefix, self.id), {})
+ def preferences(self, request):
+ if request.user.is_authenticated():
+ if request.user.prop.pagination:
+ preferences = request.user.prop.pagination.get(self.id, {})
+ else:
+ preferences = {}
+ else:
+ preferences = request.session.get('paginator_%s%s' % (self.prefix, self.id), {})
+
+ return preferences
+
+ def set_preferences(self, request, preferences):
+ if request.user.is_authenticated():
+ all_preferences = request.user.prop.pagination or {}
+ all_preferences[self.id] = preferences
+ request.user.prop.pagination = all_preferences
+ else:
+ request.session['paginator_%s%s' % (self.prefix, self.id)] = preferences