From patchwork Sun Sep 25 21:37:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 674731 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sj0n33qf1z9s5w for ; Mon, 26 Sep 2016 07:37:27 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b=eBORXBzi; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3sj0n32lrhzDrPj for ; Mon, 26 Sep 2016 07:37:27 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b=eBORXBzi; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from brown.birch.relay.mailchannels.net (brown.birch.relay.mailchannels.net [23.83.209.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3sj0n019tvzDrM9 for ; Mon, 26 Sep 2016 07:37:23 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b=eBORXBzi; dkim-atps=neutral X-Sender-Id: mxroute|x-authuser|stephen@that.guru Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id A877310035A; Sun, 25 Sep 2016 21:37:20 +0000 (UTC) Received: from one.mxroute.com (ip-10-27-139-41.us-west-2.compute.internal [10.27.139.41]) by relay.mailchannels.net (Postfix) with ESMTPA id 2DED41007E1; Sun, 25 Sep 2016 21:37:20 +0000 (UTC) X-Sender-Id: mxroute|x-authuser|stephen@that.guru Received: from one.mxroute.com ([UNAVAILABLE]. [10.135.9.54]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.7.8); Sun, 25 Sep 2016 21:37:20 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: mxroute|x-authuser|stephen@that.guru X-MailChannels-Auth-Id: mxroute X-MC-Loop-Signature: 1474839440475:1280682142 X-MC-Ingress-Time: 1474839440474 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Ii4U89iyx045jVAPpWLlVdHXQjOSi58A/K+ZCO9cgLU=; b=eBORXBziP15mRxlwkDZLPNq659 hHV3wK8Pl3ct6uF9dBTD3WEruu45yhyKn0UQ6oppb9K2KnD8KwINIMaGqBIMKM3uMilDFNzdUFwu5 j9N0KmeegrCHlByhK1ZHkdpJCJbgiZkxfONGHpoIIZPHUViIO1LBQe1e5vWG/LgDe5qVzVIshpoMz hMyuQknu8HLh1cp9beupf8KlkHoV6XhC7+tZ744l+VOAM4R2gvt7S/ytVHPCMLY0S5QafeDiUaum/ skRW/1y7aFmpChsrDd90LaRcGcAABlKpnB/PvAvxXE3rG0caq76WIsyHqDfnlKRB6YZ2R+rZOurRI ttt7leJA==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH] Revert "Allow assigning of any user as delegate" Date: Sun, 25 Sep 2016 22:37:11 +0100 Message-Id: <1474839431-12769-1-git-send-email-stephen@that.guru> X-Mailer: git-send-email 2.7.4 X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" From: Stephen Finucane This reverts commit e0fd7cd91a5fbe0a0077c46bea870ccd09c8920d. This change does not scale with a larger number of lists, and clearly needs more work. Revert until such a time as this is carried out. --- patchwork/forms.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/patchwork/forms.py b/patchwork/forms.py index 8f73f8b..cd954cd 100644 --- a/patchwork/forms.py +++ b/patchwork/forms.py @@ -99,8 +99,13 @@ class DeleteBundleForm(forms.Form): class DelegateField(forms.ModelChoiceField): - def __init__(self, *args, **kwargs): - queryset = User.objects + 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) super(DelegateField, self).__init__(queryset, *args, **kwargs) @@ -112,7 +117,8 @@ class PatchForm(forms.ModelForm): if not project: raise Exception("meep") super(PatchForm, self).__init__(instance=instance, *args, **kwargs) - self.fields['delegate'] = DelegateField(required=False) + self.fields['delegate'] = DelegateField(project, instance, + required=False) class Meta: model = Patch @@ -225,7 +231,8 @@ class MultiplePatchForm(forms.Form): def __init__(self, project, *args, **kwargs): super(MultiplePatchForm, self).__init__(*args, **kwargs) - self.fields['delegate'] = OptionalDelegateField(required=False) + self.fields['delegate'] = OptionalDelegateField(project=project, + required=False) def save(self, instance, commit=True): opts = instance.__class__._meta