From patchwork Thu Sep 27 10:14:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Veronika Kabatova X-Patchwork-Id: 975664 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42LVzC5Spqz9s55 for ; Thu, 27 Sep 2018 20:14:31 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42LVzC47bbzF36f for ; Thu, 27 Sep 2018 20:14:31 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=redhat.com (client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=vkabatov@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42LVz64dGkzF342 for ; Thu, 27 Sep 2018 20:14:26 +1000 (AEST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE7EC3084049 for ; Thu, 27 Sep 2018 10:14:24 +0000 (UTC) Received: from steamlocomotive (unknown [10.40.205.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3232265305; Thu, 27 Sep 2018 10:14:23 +0000 (UTC) From: vkabatov@redhat.com To: patchwork@lists.ozlabs.org Subject: [PATCH] Add help text to project and patch_project fields Date: Thu, 27 Sep 2018 12:14:08 +0200 Message-Id: <20180927101408.25078-1-vkabatov@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 27 Sep 2018 10:14:24 +0000 (UTC) X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 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: Veronika Kabatova Duplication of the field to avoid performance issues caused some unexpected results when moving patches between projects in the admin interface. It's easy to change the "project" field and click save, instead of double checking which field needs to be modified and kept in sync with the one being changed. This lead to patch showing correct project in the API and patch detail in the web UI, but the patch itself was listed in the wrong project when looking at the patch listings. Because of the discussions of the denormalization of the tables, trying to code automatic modification of the other field if one is being changed seems like too much work for very little benefit. What we can do instead is mention this dependency in fields' help text. Modification of the project is not an everyday task so it shouldn't put too much burden on the users and this simple reminder can prevent unexpected breakage and bug reports. Signed-off-by: Veronika Kabatova Acked-by: Daniel Axtens --- patchwork/models.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/patchwork/models.py b/patchwork/models.py index a043844d..e30a9739 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -350,7 +350,11 @@ class FilenameMixin(object): class Submission(FilenameMixin, EmailMixin, models.Model): # parent - project = models.ForeignKey(Project, on_delete=models.CASCADE) + project = models.ForeignKey(Project, on_delete=models.CASCADE, + help_text='If modifying this field on Patch, ' + 'don\'t forget to modify the "Patch project" ' + 'field appropriately as well to ensure proper ' + 'functionality!') # submission metadata @@ -405,7 +409,11 @@ class Patch(Submission): # duplicate project from submission in subclass so we can count the # patches in a project without needing to do a JOIN. - patch_project = models.ForeignKey(Project, on_delete=models.CASCADE) + patch_project = models.ForeignKey(Project, on_delete=models.CASCADE, + help_text='"Project" field needs to be ' + 'kept in sync and changed manually in ' + 'case of modifications to ensure proper ' + 'functionality!') objects = PatchManager()