]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
Allow assigning of any user as delegate
authorStephen Finucane <stephen.finucane@intel.com>
Mon, 24 Aug 2015 13:21:43 +0000 (14:21 +0100)
committerStephen Finucane <stephen.finucane@intel.com>
Mon, 25 Jan 2016 16:23:51 +0000 (16:23 +0000)
Currently, Patchwork only allows to delegate patches to developers who
are registered as "maintainers" of the project in Patchwork or set up
as autodelegate "targets". This is a bit annoying as "maintainers" in
the Patchwork sense have the power to change the state of *any* patch.

Allow delegation of patches to developers who are not the submitter of
the patch in question, a maintainer of the project or an autodelegate
"target". This request is documented here:

    https://lists.ozlabs.org/pipermail/patchwork/2015-July/001351.html

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
patchwork/forms.py

index 217e743077f54d94cbed6226b92014c0f94566bb..808ec8a388217cf46b987fa4093426d5b37b9ebc 100644 (file)
@@ -99,13 +99,8 @@ class DeleteBundleForm(forms.Form):
 
 class DelegateField(forms.ModelChoiceField):
 
-    def __init__(self, project, instance=None, *args, **kwargs):
-        q = Q(profile__in=UserProfile.objects
-              .filter(maintainer_projects=project)
-              .values('pk').query)
-        if instance and instance.delegate:
-            q = q | Q(username=instance.delegate)
-        queryset = User.objects.complex_filter(q)
+    def __init__(self, *args, **kwargs):
+        queryset = User.objects
         super(DelegateField, self).__init__(queryset, *args, **kwargs)
 
 
@@ -117,8 +112,7 @@ class PatchForm(forms.ModelForm):
         if not project:
             raise Exception("meep")
         super(PatchForm, self).__init__(instance=instance, *args, **kwargs)
-        self.fields['delegate'] = DelegateField(project, instance,
-                                                required=False)
+        self.fields['delegate'] = DelegateField(required=False)
 
     class Meta:
         model = Patch
@@ -225,8 +219,7 @@ class MultiplePatchForm(forms.Form):
 
     def __init__(self, project, *args, **kwargs):
         super(MultiplePatchForm, self).__init__(*args, **kwargs)
-        self.fields['delegate'] = OptionalDelegateField(project=project,
-                                                        required=False)
+        self.fields['delegate'] = OptionalDelegateField(required=False)
 
     def save(self, instance, commit=True):
         opts = instance.__class__._meta