from patchwork.forms import MultiplePatchForm
-from patchwork.models import Bundle, Project, BundlePatch, State, UserProfile
-from django.conf import settings
-from django.shortcuts import render_to_response, get_object_or_404
+from patchwork.models import Bundle, Project, BundlePatch, UserProfile
+from django.shortcuts import get_object_or_404
def get_patch_ids(d, prefix = 'patch_id'):
ids = []
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:
form.save(patch)
str = 'updated'
- elif action == 'ack':
- pass
-
- elif action == 'archive':
- patch.archived = True
- patch.save()
- str = 'archived'
-
- elif action == 'unarchive':
- patch.archived = True
- patch.save()
- str = 'un-archived'
-
- elif action == 'delete':
- patch.delete()
- str = 'un-archived'
-
if len(patches) > 0:
if len(patches) == 1:
context.add_message(str)
return (errors, form)
-
-def userprofile_register_callback(user):
- profile = UserProfile(user = user)
- profile.save()
-