From: Stephen Finucane Date: Mon, 24 Aug 2015 13:21:43 +0000 (+0100) Subject: Allow assigning of any user as delegate X-Git-Tag: v1.1.0~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0fd7cd91a5fbe0a0077c46bea870ccd09c8920d;p=thirdparty%2Fpatchwork.git Allow assigning of any user as delegate 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 --- diff --git a/patchwork/forms.py b/patchwork/forms.py index 217e7430..808ec8a3 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