X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=apps%2Fpatchwork%2Futils.py;fp=apps%2Fpatchwork%2Futils.py;h=1771167ae12f35fb55479c35aa865be496ce2664;hb=5bbfb1fc8dc4c034416a9e951de8b9b27ff1d838;hp=e7619c319091ce2dd9e78396f24ffbe8dac1f6db;hpb=d38039cdedd1ffd7dd99e9c5cf2aa7679e27751c;p=patchwork diff --git a/apps/patchwork/utils.py b/apps/patchwork/utils.py index e7619c3..1771167 100644 --- a/apps/patchwork/utils.py +++ b/apps/patchwork/utils.py @@ -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 @@ -107,6 +108,9 @@ def set_bundle(user, project, action, data, patches, context): 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()