Commit 6cf8d6e1 authored by Jeremy Kerr's avatar Jeremy Kerr
Browse files

[views] Allow Order class to be user-editable



This can be enabled with the editable_order parameter to
generic_list
Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
parent aca889fc
......@@ -48,8 +48,12 @@ class Order(object):
}
default_order = ('date', True)
def __init__(self, str = None):
def __init__(self, str = None, editable = False):
self.reversed = False
self.editable = editable
if self.editable:
return
if str is None or str == '':
(self.order, self.reversed) = self.default_order
......@@ -114,7 +118,7 @@ def set_bundle(user, project, action, data, patches, context):
for patch in patches:
if action == 'create' or action == 'add':
bundle.patches.add(patch)
bundle.append_patch(patch)
elif action == 'remove':
bundle.patches.remove(patch)
......
......@@ -24,14 +24,15 @@ from patchwork.paginator import Paginator
from patchwork.forms import MultiplePatchForm
def generic_list(request, project, view,
view_args = {}, filter_settings = [], patches = None):
view_args = {}, filter_settings = [], patches = None,
editable_order = False):
context = PatchworkRequestContext(request,
list_view = view,
list_view_params = view_args)
context.project = project
order = Order(request.REQUEST.get('order'))
order = Order(request.REQUEST.get('order'), editable = editable_order)
form = MultiplePatchForm(project)
......@@ -75,7 +76,8 @@ def generic_list(request, project, view,
patches = Patch.objects.filter(project=project)
patches = context.filters.apply(patches)
patches = patches.order_by(order.query())
if not editable_order:
patches = patches.order_by(order.query())
paginator = Paginator(request, patches)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment