]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/utils/pagination.py
Adds a couple of options to manage the "accepting answers" workflow.
[osqa.git] / forum / utils / pagination.py
index a573954e46df720761738d397e2eb280306f8078..5951b3384c22a7d324f88548d89e3df574be33af 100644 (file)
@@ -19,11 +19,11 @@ class SimpleSort(SortBase):
         super(SimpleSort, self) .__init__(label, description)
         self.order_by = order_by
 
+    def _get_order_by(self):
+        return isinstance(self.order_by, (list, tuple)) and self.order_by or [self.order_by]
+
     def apply(self, objects):
-        if isinstance(self.order_by, (list, tuple)):
-            return objects.order_by(*self.order_by)
-        else:
-            return objects.order_by(self.order_by)
+        return objects.order_by(*self._get_order_by())
 
 class PaginatorContext(object):
     visible_page_range = 5