]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/utils.py
parser: allow short-form List-Id headers
[patchwork] / apps / patchwork / utils.py
index 5bd6925b6bf0065ee2beaf30b60f354c2d4de5c0..fa26aef7e674d8be9ee299e0556cdc93c4ca1e0a 100644 (file)
@@ -97,8 +97,12 @@ def set_bundle(user, project, action, data, patches, context):
     # set up the bundle
     bundle = None
     if action == 'create':
+        bundle_name = data['bundle_name'].strip()
+        if not bundle_name:
+            return ['No bundle name was specified']
+
         bundle = Bundle(owner = user, project = project,
-                name = data['bundle_name'])
+                name = bundle_name)
         bundle.save()
         context.add_message("Bundle %s created" % bundle.name)
 
@@ -113,13 +117,15 @@ def set_bundle(user, project, action, data, patches, context):
 
     for patch in patches:
         if action == 'create' or action == 'add':
-            try:
+            bundlepatch_count = BundlePatch.objects.filter(bundle = bundle,
+                        patch = patch).count()
+            if bundlepatch_count == 0:
                 bundle.append_patch(patch)
                 context.add_message("Patch '%s' added to bundle %s" % \
                         (patch.name, bundle.name))
-            except Exception, ex:
-                context.add_message("Couldn't add patch '%s' to bundle: %s" % \
-                        (patch.name, ex.message))
+            else:
+                context.add_message("Patch '%s' already in bundle %s" % \
+                        (patch.name, bundle.name))
 
         elif action == 'remove':
             try:
@@ -177,7 +183,7 @@ def set_patches(user, project, action, data, patches, context):
             str = 'archived'
 
         elif action == 'unarchive':
-            patch.archived = True
+            patch.archived = False
             patch.save()
             str = 'un-archived'