[PATCH v2 2/2] Allow assigning of any user as delegate

Stephen Finucane stephen.finucane at intel.com
Wed Jan 27 08:55:08 AEDT 2016


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 at intel.com>
---
 patchwork/forms.py | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/patchwork/forms.py b/patchwork/forms.py
index 217e743..808ec8a 100644
--- a/patchwork/forms.py
+++ b/patchwork/forms.py
@@ -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
-- 
2.0.0



More information about the Patchwork mailing list