]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/views/patch.py
Bundle reordering support
[patchwork] / apps / patchwork / views / patch.py
index 72472cac646925e6e4f4d70a6955d27fdabcc935..49843eb2cfad3c99c5dfc62707d829ddd66f793c 100644 (file)
@@ -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: