]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/utils.py
Add pwclientrc configuration file sample for each project
[patchwork] / apps / patchwork / utils.py
index 7cf88bcb924ca19637263fb6f88f16ee165f3bd7..05e66e26eb0c72bd9b7e0db0378fc9e5d012a1cb 100644 (file)
@@ -19,7 +19,7 @@
 
 
 from patchwork.forms import MultiplePatchForm
-from patchwork.models import Bundle, Project, State
+from patchwork.models import Bundle, Project, State, UserProfile
 from django.conf import settings
 from django.shortcuts import render_to_response, get_object_or_404
 
@@ -40,10 +40,11 @@ def get_patch_ids(d, prefix = 'patch_id'):
 
 class Order(object):
     order_map = {
-        'date':                'date',
-        'name':                'name',
-        'state':       'state__ordering',
-        'submitter':   'submitter__name'
+        'date':         'date',
+        'name':         'name',
+        'state':        'state__ordering',
+        'submitter':    'submitter__name',
+        'delegate':     'delegate__username',
     }
     default_order = 'date'
 
@@ -88,7 +89,7 @@ class Order(object):
         return q
 
 bundle_actions = ['create', 'add', 'remove']
-def set_bundle(user, action, data, patches, context):
+def set_bundle(user, project, action, data, patches, context):
     # set up the bundle
     bundle = None
     if action == 'create':
@@ -130,9 +131,9 @@ def set_bundle(user, action, data, patches, context):
     return []
 
 
-def set_patches(user, action, data, patches, context):
+def set_patches(user, project, action, data, patches, context):
     errors = []
-    form = MultiplePatchForm(data = data)
+    form = MultiplePatchForm(project = project, data = data)
 
     try:
         project = Project.objects.get(id = data['project'])
@@ -142,12 +143,10 @@ def set_patches(user, action, data, patches, context):
 
     str = ''
 
-    print "action: ", action
-
     # this may be a bundle action, which doesn't modify a patch. in this
     # case, don't require a valid form, or patch editing permissions
     if action in bundle_actions:
-        errors = set_bundle(user, action, data, patches, context)
+        errors = set_bundle(user, project, action, data, patches, context)
         return (errors, form)
 
     if not form.is_valid():
@@ -191,3 +190,8 @@ def set_patches(user, action, data, patches, context):
         context.add_message(str)
 
     return (errors, form)
+
+def userprofile_register_callback(user):
+    profile = UserProfile(user = user)
+    profile.save()
+