]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/utils.py
js: Add jquery and jquery tablednd plugins
[patchwork] / apps / patchwork / utils.py
index e7619c319091ce2dd9e78396f24ffbe8dac1f6db..f48e7a59a341ada3bc9a1465c809f181dac4cd3a 100644 (file)
@@ -26,6 +26,7 @@ from django.contrib.sites.models import Site
 from django.conf import settings
 from django.core.mail import EmailMessage
 from django.db.models import Max
+from django.db.utils import IntegrityError
 from patchwork.forms import MultiplePatchForm
 from patchwork.models import Bundle, Project, BundlePatch, UserProfile, \
         PatchChangeNotification, EmailOptout
@@ -104,9 +105,15 @@ def set_bundle(user, project, action, data, patches, context):
     bundle = None
     if action == 'create':
         bundle_name = data['bundle_name'].strip()
+        if '/' in bundle_name:
+            return ['Bundle names can\'t contain slashes']
+
         if not bundle_name:
             return ['No bundle name was specified']
 
+        if Bundle.objects.filter(owner = user, name = bundle_name).count() > 0:
+            return ['You already have a bundle called "%s"' % bundle_name]
+
         bundle = Bundle(owner = user, project = project,
                 name = bundle_name)
         bundle.save()