diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2009-02-08 21:40:17 +1100 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2009-02-08 21:44:25 +1100 |
commit | 6ce62d26739ebf0dd81ecff5284adf3fbe2aed23 (patch) | |
tree | 1bd8034844b48ef8c91f232de7000ff12450a06d /apps/patchwork/views | |
parent | 6cf8d6e128b9117f10431eb9b534e9c8b1024cdf (diff) | |
download | patchwork-6ce62d26739ebf0dd81ecff5284adf3fbe2aed23.tar.bz2 patchwork-6ce62d26739ebf0dd81ecff5284adf3fbe2aed23.tar.xz |
Bundle reordering support
Bundles can now be reordered and saved.
Add dependency on jquery in INSTALL.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'apps/patchwork/views')
-rw-r--r-- | apps/patchwork/views/bundle.py | 23 | ||||
-rw-r--r-- | apps/patchwork/views/patch.py | 12 |
2 files changed, 27 insertions, 8 deletions
diff --git a/apps/patchwork/views/bundle.py b/apps/patchwork/views/bundle.py index d8e4e2f..9995fc6 100644 --- a/apps/patchwork/views/bundle.py +++ b/apps/patchwork/views/bundle.py @@ -23,7 +23,7 @@ from django.shortcuts import render_to_response, get_object_or_404 from patchwork.requestcontext import PatchworkRequestContext from django.http import HttpResponse, HttpResponseRedirect import django.core.urlresolvers -from patchwork.models import Patch, Bundle, Project +from patchwork.models import Patch, Bundle, BundlePatch, Project from patchwork.utils import get_patch_ids from patchwork.forms import BundleForm, DeleteBundleForm from patchwork.views import generic_list @@ -49,7 +49,10 @@ def setbundle(request): patch_id = request.POST.get('patch_id', None) if patch_id: patch = get_object_or_404(Patch, id = patch_id) - bundle.patches.add(patch) + try: + bundle.append_patch(patch) + except Exception: + pass bundle.save() elif action == 'add': bundle = get_object_or_404(Bundle, @@ -65,7 +68,7 @@ def setbundle(request): for id in patch_ids: try: patch = Patch.objects.get(id = id) - bundle.patches.add(patch) + bundle.append_patch(patch) except ex: pass @@ -143,11 +146,23 @@ def bundle(request, bundle_id): else: form = BundleForm(instance = bundle) + if request.method == 'POST' and request.POST.get('form') == 'reorderform': + order = get_object_or_404(BundlePatch, bundle = bundle, + patch__id = request.POST.get('order_start')).order + + for patch_id in request.POST.getlist('neworder'): + bundlepatch = get_object_or_404(BundlePatch, + bundle = bundle, patch__id = patch_id) + bundlepatch.order = order + bundlepatch.save() + order += 1 + context = generic_list(request, bundle.project, 'patchwork.views.bundle.bundle', view_args = {'bundle_id': bundle_id}, filter_settings = filter_settings, - patches = bundle.patches.all()) + patches = bundle.ordered_patches(), + editable_order = True) context['bundle'] = bundle context['bundleform'] = form diff --git a/apps/patchwork/views/patch.py b/apps/patchwork/views/patch.py index 72472ca..49843eb 100644 --- a/apps/patchwork/views/patch.py +++ b/apps/patchwork/views/patch.py @@ -59,7 +59,7 @@ def patch(request, patch_id): data = request.POST) if createbundleform.is_valid(): createbundleform.save() - bundle.patches.add(patch) + bundle.append_patch(patch) bundle.save() createbundleform = CreateBundleForm() context.add_message('Bundle %s created' % bundle.name) @@ -67,9 +67,13 @@ def patch(request, patch_id): elif action == 'addtobundle': bundle = get_object_or_404(Bundle, id = \ request.POST.get('bundle_id')) - bundle.patches.add(patch) - bundle.save() - context.add_message('Patch added to bundle "%s"' % bundle.name) + try: + bundle.append_patch(patch) + bundle.save() + context.add_message('Patch added to bundle "%s"' % bundle.name) + except Exception, ex: + context.add_message("Couldn't add patch '%s' to bundle %s: %s" \ + % (patch.name, bundle.name, ex.message)) # all other actions require edit privs elif not editable: |