From patchwork Sun Apr 15 22:53:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 898334 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 ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40PRhB4WdCz9s1R for ; Mon, 16 Apr 2018 08:56:10 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="CWtJXd+e"; 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 40PRhB34VszF1qc for ; Mon, 16 Apr 2018 08:56:10 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="CWtJXd+e"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=23.83.222.36; helo=cichlid.ash.relay.mailchannels.net; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="CWtJXd+e"; dkim-atps=neutral Received: from cichlid.ash.relay.mailchannels.net (cichlid.ash.relay.mailchannels.net [23.83.222.36]) (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 40PRf4737vzF1Rl for ; Mon, 16 Apr 2018 08:54:20 +1000 (AEST) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id C11AE3E1C4C for ; Sun, 15 Apr 2018 22:54:13 +0000 (UTC) Received: from one.mxroute.com (unknown [100.96.32.20]) (Authenticated sender: 5xi41l16bi) by relay.mailchannels.net (Postfix) with ESMTPA id 447943E19AA for ; Sun, 15 Apr 2018 22:54:13 +0000 (UTC) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from one.mxroute.com (one-outgoing.mxroute.com [172.18.49.137]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.14.1); Sun, 15 Apr 2018 22:54:13 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: 5xi41l16bi|x-authuser|stephen@that.guru X-MailChannels-Auth-Id: 5xi41l16bi X-Harbor-Ski: 5e34c31748ed5f86_1523832853579_737049777 X-MC-Loop-Signature: 1523832853579:89991663 X-MC-Ingress-Time: 1523832853578 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=HS6WcU/WWCM9QTt+ZfPgeVHlBjYqMQbgtL9jPEslocQ=; b=CWtJXd+etkVGdQ1EyO3yFWffYu ry78vMKwpkl8t410APIDEbdiMRBNvAXydXTzJxkI3qDi4GfszHLT/2sI4DVqjT7UlVvDgR0ZYFOhH MmrV/ksw8F1cf0q+kki0ot9Qxm+cgMFcafqOxTQcZjhrpy0RddBM1x3k7mnhx4cXVvCKrl+3ocB0r TuChhhB21EoHyWfi2CqfDJMFWkfh/Eg8SjrUTLll10rmnJcZNC6nC4bW6sjdlhOZ8ApRv3/8rr/tK a9KkxpeaR8U4ykyB3G5rqmAdpyvKqQhdoGQ0nt0qaM3rDn6VYOGTgKO9fxo1gtXBlCBHpdp8JF1aI t/MxoFlA==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 01/11] fields: Add ColorField Date: Sun, 15 Apr 2018 23:53:55 +0100 Message-Id: <20180415225405.1354-2-stephen@that.guru> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180415225405.1354-1-stephen@that.guru> References: <20180415225405.1354-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.26 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" This will allow us to store color codes cleanly in the database. Signed-off-by: Stephen Finucane --- patchwork/fields.py | 27 +++++++++++++++++++++++++-- patchwork/forms.py | 27 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/patchwork/fields.py b/patchwork/fields.py index 502558be..35bb13d6 100644 --- a/patchwork/fields.py +++ b/patchwork/fields.py @@ -18,8 +18,6 @@ # along with Patchwork; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -from __future__ import absolute_import - import hashlib from django.db import models @@ -44,3 +42,28 @@ class HashField(models.CharField): def db_type(self, connection=None): return 'char(%d)' % self.n_bytes + + +class ColorField(models.Field): + + description = 'Hex color code' + + def get_internal_type(self): + return "PositiveIntegerField" + + def to_python(self, value): + if isinstance(value, six.string_types) or value is None: + return value + return '#%06x' % value + + def from_db_value(self, value, *args, **kwargs): + return self.to_python(value) + + def get_prep_value(self, value): + return int(value.lstrip('#'), 16) + + def formfield(self, *args, **kwargs): + from patchwork import forms # noqa + + kwargs['form_class'] = forms.ColorField + return super(ColorField, self).formfield(*args, **kwargs) diff --git a/patchwork/forms.py b/patchwork/forms.py index 0dd11857..e8a4955e 100644 --- a/patchwork/forms.py +++ b/patchwork/forms.py @@ -17,6 +17,8 @@ # along with Patchwork; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +import re + from django.contrib.auth.models import User from django import forms from django.db.models import Q @@ -214,3 +216,28 @@ class MultiplePatchForm(forms.Form): if commit: instance.save() return instance + + +class ColorField(forms.CharField): + + widget = forms.TextInput + default_error_messages = { + 'invalid': 'Enter a valid colour value: e.g. "#ff0022"', + } + + def __init__(self, *args, **kwargs): + super(ColorField, self).__init__(*args, **kwargs) + + def clean(self, value): + if not re.match('^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$', value): + raise forms.ValidationError(self.error_messages['invalid']) + + value = int(value.lstrip('#'), 16) + super(ColorField, self).clean(value) + + return value + + def widget_attrs(self, widget): + attrs = super().widget_attrs(widget) + attrs['maxlength'] = 7 + return attrs From patchwork Sun Apr 15 22:53:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 898328 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40PRfz2BNMz9s1R for ; Mon, 16 Apr 2018 08:55:07 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="Q1LMxHBC"; 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 40PRfz0jC6zF1pD for ; Mon, 16 Apr 2018 08:55:07 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="Q1LMxHBC"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=23.83.214.38; helo=common.maple.relay.mailchannels.net; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="Q1LMxHBC"; dkim-atps=neutral Received: from common.maple.relay.mailchannels.net (common.maple.relay.mailchannels.net [23.83.214.38]) (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 40PRf324g3zF1Rl for ; Mon, 16 Apr 2018 08:54:18 +1000 (AEST) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id F1E1F121B1B for ; Sun, 15 Apr 2018 22:54:15 +0000 (UTC) Received: from one.mxroute.com (unknown [100.96.15.83]) (Authenticated sender: 5xi41l16bi) by relay.mailchannels.net (Postfix) with ESMTPA id 85558121C49 for ; Sun, 15 Apr 2018 22:54:15 +0000 (UTC) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from one.mxroute.com (one-outgoing.mxroute.com [172.18.54.155]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.14.1); Sun, 15 Apr 2018 22:54:15 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: 5xi41l16bi|x-authuser|stephen@that.guru X-MailChannels-Auth-Id: 5xi41l16bi X-Absorbed-Tank: 3175ad1400923707_1523832855815_1331571336 X-MC-Loop-Signature: 1523832855814:445061813 X-MC-Ingress-Time: 1523832855814 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=PwL/4j5aFPOAW5FjT7yyoiUeoAr36fp3ajcu8gsqDXs=; b=Q1LMxHBCv+xqyF1ZLyCTdci7I7 FQRNjEM4y2Fw0bYOH7gGP8yFG8DBQYGp5Sbl3qZ/kv1rBTtQPefI0s0s/NFDbFCBIh5Uz0B/odx3V d0HbVi9vcXGlwJaztoaEXQHtf7F1lDyrf+VkKOouvfKWRSi8v/RbsWyqrdCKKV3dtjja+FrKaOqS9 MDgOQc/0YpKXURZaZF+3h2TIvC5TNf+RXMHP/q09smOA78Yua2kBucGxMI5pNbIf3sUqYGRmlwsMy xfQXkHJnNiSGFRu+lEjQUAt1AY5NIEIuUrxb4AJNQpb2Kv3dlePXT82Ima4pqydX4IG5GfOPQUzsq v5g78pIg==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 02/11] models: Add patch labels Date: Sun, 15 Apr 2018 23:53:56 +0100 Message-Id: <20180415225405.1354-3-stephen@that.guru> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180415225405.1354-1-stephen@that.guru> References: <20180415225405.1354-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.26 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" Labels are arbitrary bits of metadata attached to a patch. They can be used to signify priority, category, or other similar information. They can also be used to filter patches and identify the ones most interesting to a given user. Labels can be associated with a project to ensure that one project can use a totally different set of labels to another and to, in the future, allow a project administrator to use their own labels. However, they can also be global, which is useful for things that would be common across multiple projects such as "RFC". Signed-off-by: Stephen Finucane --- patchwork/fixtures/default_labels.xml | 9 +++++++ patchwork/migrations/0026_add_patch_labels.py | 39 +++++++++++++++++++++++++++ patchwork/models.py | 35 ++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 patchwork/fixtures/default_labels.xml create mode 100644 patchwork/migrations/0026_add_patch_labels.py diff --git a/patchwork/fixtures/default_labels.xml b/patchwork/fixtures/default_labels.xml new file mode 100644 index 00000000..31313745 --- /dev/null +++ b/patchwork/fixtures/default_labels.xml @@ -0,0 +1,9 @@ + + + + 1 + RFC + "RFC" stands for "Request for Comment", which tells maintainers that they should review your patch thoroughly and provide feedback. RFC is typically used when sending feature patches for the first time, or anytime the patch is more than just a simple bug fix. + 15592941 + + \ No newline at end of file diff --git a/patchwork/migrations/0026_add_patch_labels.py b/patchwork/migrations/0026_add_patch_labels.py new file mode 100644 index 00000000..af503143 --- /dev/null +++ b/patchwork/migrations/0026_add_patch_labels.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-04-13 13:22 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import patchwork.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('patchwork', '0025_add_regex_validators'), + ] + + operations = [ + migrations.CreateModel( + name='Label', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(help_text=b'The label value.', max_length=25)), + ('description', models.TextField(blank=True, help_text=b'A description of what the label is and when it should be applied.', null=True)), + ('color', patchwork.fields.ColorField(help_text=b'The color code to use in the UI.')), + ('project', models.ForeignKey(help_text=b'The project this label is associated with. If unset, this label is global to the instance', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='labels', related_query_name='label', to='patchwork.Project')), + ], + options={ + 'ordering': ['name'], + }, + ), + migrations.AddField( + model_name='patch', + name='labels', + field=models.ManyToManyField(to='patchwork.Label'), + ), + migrations.AlterUniqueTogether( + name='label', + unique_together=set([('project', 'name')]), + ), + ] diff --git a/patchwork/models.py b/patchwork/models.py index f91b994c..9b7b8ceb 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -36,6 +36,7 @@ from django.utils.functional import cached_property from patchwork.compat import is_authenticated from patchwork.compat import reverse +from patchwork.fields import ColorField from patchwork.fields import HashField from patchwork.hasher import hash_diff @@ -237,6 +238,39 @@ class State(models.Model): ordering = ['ordering'] +@python_2_unicode_compatible +class Label(models.Model): + """Labels for patches. + + Labels are arbitrary bits of metadata attached to a patch. They can + be used to signify priority, category, or other similar information. + They can also be used to filter patches and identify the ones most + interesting to a given user. + """ + project = models.ForeignKey( + Project, related_name='labels', related_query_name='label', null=True, + on_delete=models.CASCADE, + help_text='The project this label is associated with. If unset, this ' + 'label is global to the instance') + + name = models.CharField( + max_length=25, + help_text='The label value.') + description = models.TextField( + null=True, blank=True, + help_text='A description of what the label is and when it should be ' + 'applied.') + color = ColorField( + help_text='The color code to use in the UI.') + + def __str__(self): + return self.name + + class Meta: + ordering = ['name'] + unique_together = [('project', 'name')] + + @python_2_unicode_compatible class Tag(models.Model): name = models.CharField(max_length=20) @@ -424,6 +458,7 @@ class Patch(SeriesMixin, Submission): commit_ref = models.CharField(max_length=255, null=True, blank=True) pull_url = models.CharField(max_length=255, null=True, blank=True) tags = models.ManyToManyField(Tag, through=PatchTag) + labels = models.ManyToManyField(Label) # patchwork metadata From patchwork Sun Apr 15 22:53:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 898326 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 ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40PRfY1Zh5z9s06 for ; Mon, 16 Apr 2018 08:54:45 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="S8Dxg0mH"; 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 40PRfX74SRzF1sD for ; Mon, 16 Apr 2018 08:54:44 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="S8Dxg0mH"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=23.83.214.30; helo=caracal.maple.relay.mailchannels.net; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="S8Dxg0mH"; dkim-atps=neutral Received: from caracal.maple.relay.mailchannels.net (caracal.maple.relay.mailchannels.net [23.83.214.30]) (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 40PRf24Q5qzF1Rt for ; Mon, 16 Apr 2018 08:54:18 +1000 (AEST) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 3F381121F4F for ; Sun, 15 Apr 2018 22:54:15 +0000 (UTC) Received: from one.mxroute.com (unknown [100.96.15.83]) (Authenticated sender: 5xi41l16bi) by relay.mailchannels.net (Postfix) with ESMTPA id C6E331220BD for ; Sun, 15 Apr 2018 22:54:14 +0000 (UTC) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from one.mxroute.com (one-outgoing.mxroute.com [100.96.15.1]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.14.1); Sun, 15 Apr 2018 22:54:15 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: 5xi41l16bi|x-authuser|stephen@that.guru X-MailChannels-Auth-Id: 5xi41l16bi X-Whimsical-Gusty: 0456a4a75bb4e413_1523832855072_343111189 X-MC-Loop-Signature: 1523832855072:2474096927 X-MC-Ingress-Time: 1523832855071 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=RDPdiChYowQrnSQ338OV/bkn6nr29G98SFThUhljjrs=; b=S8Dxg0mHh1Tmy1cJOmFdJZfLkm IN+0iuMFXMvjaMyVET9kagO1GDKi3eCyka3z28xsbgFdNHByCQyQrkTf+VvWQp+xHOkKzJUFxoc7A 09lXHDMrkJpUadLtmsT9w8fATk07Qi6JEYXhjR398TBOT2A0Jo7xS9znK9w9s72hwjD044lJFW9xy jPVxg3bw2tmaIZFJ5GQv2Te6tbntnEcaio4ffk4+lWBVs1FKJ5G23MhZbz9HHh4dTtxM4KbhlHaii 5fNTbzRcjEueB+O/nlh/rSWW/MlncgVExsEpw3ZR3eX6V4Bo18nJ3XIPHhco7zWV4x0AIk0S5hKVk wPs0ABfA==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 03/11] parser: Extract and save labels Date: Sun, 15 Apr 2018 23:53:57 +0100 Message-Id: <20180415225405.1354-4-stephen@that.guru> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180415225405.1354-1-stephen@that.guru> References: <20180415225405.1354-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.26 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" Signed-off-by: Stephen Finucane --- patchwork/parser.py | 17 +++++++++++++++++ patchwork/tests/test_parser.py | 16 ++++++++++++++++ patchwork/tests/utils.py | 15 +++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/patchwork/parser.py b/patchwork/parser.py index 805037c7..7ac527a2 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -29,12 +29,14 @@ import logging import re from django.contrib.auth.models import User +from django.db.models import Q from django.utils import six from patchwork.models import Comment from patchwork.models import CoverLetter from patchwork.models import DelegationRule from patchwork.models import get_default_initial_patch_state +from patchwork.models import Label from patchwork.models import Patch from patchwork.models import Person from patchwork.models import Project @@ -497,6 +499,16 @@ def parse_version(subject, subject_prefixes): return 1 +def parse_labels(subject_prefixes, project): + """Extract labels from subject. + + Args: + subject_prefixes: List of subject prefixes to extract tags from + """ + return Label.objects.filter(Q(project=project) | Q(project=None), + name__in=subject_prefixes) + + def _find_content(mail): """Extract the payload(s) from a mail. @@ -1001,6 +1013,8 @@ def parse_mail(mail, list_id=None): filenames = find_filenames(diff) delegate = find_delegate_by_filename(project, filenames) + labels = parse_labels(prefixes, project) + patch = Patch.objects.create( msgid=msgid, project=project, @@ -1016,6 +1030,9 @@ def parse_mail(mail, list_id=None): state=find_state(mail)) logger.debug('Patch saved') + if labels: + patch.labels.set(labels) + # if we don't have a series marker, we will never have an existing # series to match against. series = None diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py index 5ba06c0f..50a07523 100644 --- a/patchwork/tests/test_parser.py +++ b/patchwork/tests/test_parser.py @@ -38,6 +38,7 @@ from patchwork.parser import get_or_create_author from patchwork.parser import find_patch_content as find_content from patchwork.parser import find_project from patchwork.parser import find_series +from patchwork.parser import parse_labels from patchwork.parser import parse_mail as _parse_mail from patchwork.parser import parse_pull_request from patchwork.parser import parse_series_marker @@ -46,6 +47,7 @@ from patchwork.parser import split_prefixes from patchwork.parser import subject_check from patchwork.tests import TEST_MAIL_DIR from patchwork.tests import TEST_FUZZ_DIR +from patchwork.tests.utils import create_label from patchwork.tests.utils import create_project from patchwork.tests.utils import create_series from patchwork.tests.utils import create_series_reference @@ -888,6 +890,20 @@ class SubjectTest(TestCase): self.assertEqual(parse_version('Hello, world (v2)', []), 2) self.assertEqual(parse_version('Hello, world (V6)', []), 6) + def test_labels(self): + label = create_label(name='RFC') + + self.assertEqual(list(parse_labels(['RFC'], label.project)), [label]) + self.assertEqual(list(parse_labels(['rfcx'], label.project)), []) + + project = create_project() + + self.assertEqual(list(parse_labels(['RFC'], project)), []) + + label = create_label(name='stuff', project=None) + + self.assertEqual(list(parse_labels(['stuff'], project)), [label]) + class SubjectMatchTest(TestCase): diff --git a/patchwork/tests/utils.py b/patchwork/tests/utils.py index 00eb6c2a..e51862fc 100644 --- a/patchwork/tests/utils.py +++ b/patchwork/tests/utils.py @@ -29,6 +29,7 @@ from patchwork.models import Bundle from patchwork.models import Check from patchwork.models import Comment from patchwork.models import CoverLetter +from patchwork.models import Label from patchwork.models import Patch from patchwork.models import Person from patchwork.models import Project @@ -266,6 +267,20 @@ def create_series_reference(**kwargs): return SeriesReference.objects.create(**values) +def create_label(**kwargs): + """Create a 'Label' object.""" + num = Label.objects.count() + + values = { + 'name': 'label%d' % num, + 'project': create_project() if 'project' not in kwargs else None, + 'color': '#fff', + } + values.update(**kwargs) + + return Label.objects.create(**values) + + def _create_submissions(create_func, count=1, **kwargs): """Create 'count' Submission-based objects. From patchwork Sun Apr 15 22:53:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 898332 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 ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40PRgm6Q2Nz9s1R for ; Mon, 16 Apr 2018 08:55:48 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="bvFaQ6b9"; 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 40PRgm4s6pzF1pD for ; Mon, 16 Apr 2018 08:55:48 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="bvFaQ6b9"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=23.83.209.66; helo=gecko.birch.relay.mailchannels.net; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="bvFaQ6b9"; dkim-atps=neutral Received: from gecko.birch.relay.mailchannels.net (gecko.birch.relay.mailchannels.net [23.83.209.66]) (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 40PRf40MlGzF1Rl for ; Mon, 16 Apr 2018 08:54:19 +1000 (AEST) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 06F803E1D01 for ; Sun, 15 Apr 2018 22:54:17 +0000 (UTC) Received: from one.mxroute.com (unknown [100.96.11.60]) (Authenticated sender: 5xi41l16bi) by relay.mailchannels.net (Postfix) with ESMTPA id 955C03E1DA9 for ; Sun, 15 Apr 2018 22:54:16 +0000 (UTC) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from one.mxroute.com (one-outgoing.mxroute.com [172.18.36.240]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.14.1); Sun, 15 Apr 2018 22:54:16 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: 5xi41l16bi|x-authuser|stephen@that.guru X-MailChannels-Auth-Id: 5xi41l16bi X-Abaft-Harbor: 4cef272c6f109de7_1523832856860_645993725 X-MC-Loop-Signature: 1523832856860:3063247654 X-MC-Ingress-Time: 1523832856859 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ih8+lJDjBUoCjrnKxaEQBOOKIvfcAbew60YvBycWKOo=; b=bvFaQ6b9onsLjGwJqIU+f3NZOz ZoMS3+iWnAkA8F4+1nhUFGuuuxirqN1kANIR3laoD2egNhNpo4yDVp+iQswCWsi6RGKEAPG+1k/Lk PJ6BQpQQk+tV+UmHPZQtQLyyBvQdBhdikqHEtDIPJi4vsA/l+4pbG3NhgUDoUAsS9GDIX7onAmVQX BijRkjJ02sozaJcAfgoQKcnwc7OgZhpSzyOYybmG03bdjwZqxCPEWYwkFPvktWVznXVnDjc66lQP8 +ULxo8AS3+YWOc5aroiRUPy3uG5oTX7uzQZrbtIUbAuXm3V7HEE4cW2EsNL4borVox+nrNBQ86UxW IESxtwhw==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 04/11] parser: Remove matching label from subject prefixes Date: Sun, 15 Apr 2018 23:53:58 +0100 Message-Id: <20180415225405.1354-5-stephen@that.guru> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180415225405.1354-1-stephen@that.guru> References: <20180415225405.1354-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.26 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" Extend the parser to strip the label from the list of prefixes. This means we don't duplicate things twice in the UI. Signed-off-by: Stephen Finucane --- I'm not 100% sure about this which is why I've kept it separate. On one hand, it doesn't make sense to duplicate things like this. On another, not every label is something we'd want to parse from the subject line and it makes prefixes in the UI kind of useless. Perhaps we should add a 'Label.parseable' flag? --- patchwork/parser.py | 9 +++++++-- patchwork/tests/test_parser.py | 19 +++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/patchwork/parser.py b/patchwork/parser.py index 7ac527a2..9ee4eba0 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -505,8 +505,13 @@ def parse_labels(subject_prefixes, project): Args: subject_prefixes: List of subject prefixes to extract tags from """ - return Label.objects.filter(Q(project=project) | Q(project=None), - name__in=subject_prefixes) + labels = Label.objects.filter(Q(project=project) | Q(project=None), + name__in=subject_prefixes) + for label in labels: + if label.name in subject_prefixes: + subject_prefixes.remove(label.name) + + return labels def _find_content(mail): diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py index 50a07523..3615dfd8 100644 --- a/patchwork/tests/test_parser.py +++ b/patchwork/tests/test_parser.py @@ -893,16 +893,23 @@ class SubjectTest(TestCase): def test_labels(self): label = create_label(name='RFC') - self.assertEqual(list(parse_labels(['RFC'], label.project)), [label]) - self.assertEqual(list(parse_labels(['rfcx'], label.project)), []) + prefixes = ['RFC'] + self.assertEqual(list(parse_labels(prefixes, label.project)), [label]) + self.assertEqual(prefixes, []) - project = create_project() + prefixes = ['rfcx'] + self.assertEqual(list(parse_labels(prefixes, label.project)), []) + self.assertEqual(prefixes, ['rfcx']) - self.assertEqual(list(parse_labels(['RFC'], project)), []) + project = create_project() + prefixes = ['RFC'] + self.assertEqual(list(parse_labels(prefixes, project)), []) + self.assertEqual(prefixes, ['RFC']) label = create_label(name='stuff', project=None) - - self.assertEqual(list(parse_labels(['stuff'], project)), [label]) + prefixes = ['stuff'] + self.assertEqual(list(parse_labels(prefixes, project)), [label]) + self.assertEqual(prefixes, []]) class SubjectMatchTest(TestCase): From patchwork Sun Apr 15 22:53:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 898330 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 ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40PRgN0QSCz9s1R for ; Mon, 16 Apr 2018 08:55:28 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="SiDOVZhO"; 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 40PRgM5wt8zF1sZ for ; Mon, 16 Apr 2018 08:55:27 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="SiDOVZhO"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=23.83.209.68; helo=giant.birch.relay.mailchannels.net; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="SiDOVZhO"; dkim-atps=neutral Received: from giant.birch.relay.mailchannels.net (giant.birch.relay.mailchannels.net [23.83.209.68]) (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 40PRf41W6nzF1Rt for ; Mon, 16 Apr 2018 08:54:19 +1000 (AEST) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 1EB415C1CE1 for ; Sun, 15 Apr 2018 22:54:17 +0000 (UTC) Received: from one.mxroute.com (unknown [100.96.15.83]) (Authenticated sender: 5xi41l16bi) by relay.mailchannels.net (Postfix) with ESMTPA id 97F825C1D0C for ; Sun, 15 Apr 2018 22:54:16 +0000 (UTC) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from one.mxroute.com (one-outgoing.mxroute.com [172.18.43.43]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.14.1); Sun, 15 Apr 2018 22:54:17 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: 5xi41l16bi|x-authuser|stephen@that.guru X-MailChannels-Auth-Id: 5xi41l16bi X-Quick-Bored: 22dce4f31da48ac0_1523832856929_914401345 X-MC-Loop-Signature: 1523832856929:3194801935 X-MC-Ingress-Time: 1523832856929 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=yWPo+qdNVv6aQ8QuS+TBojDZnd5CSem7gbbfFkYri7E=; b=SiDOVZhOvQuyNg0fYOZ+YO/f6N 292/JRrWR3j5h1jVbHPzr6pO4d/lxJLWo8ETs6uZkf5GtuX2B1B1O7XCXtH7EyD3SpDxFU51DXm6t 1bdpv8qSPsg5vqCw6GLwgaroPRqnAc0GEtrADMvgbi7Vf91/WjkEdtUQGeQxvfkc5maQe5XJvL2VG R6I92cIKhe0gVagUF97k+eTcXmXCXjvWzjzUYBXuegCU6mABM5nolBOpCVUrFhaytXq4CIBDRPEGj eoFWK0nr9xdpqaTpkl0V2g1FwmXk0VJg0jM4mXgTpIz0E/4yLlgwsbJPEM2DaW7Tp3zpZAvA2Zrcc Bkz+kY8w==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 05/11] admin: Group register calls at bottom Date: Sun, 15 Apr 2018 23:53:59 +0100 Message-Id: <20180415225405.1354-6-stephen@that.guru> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180415225405.1354-1-stephen@that.guru> References: <20180415225405.1354-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.26 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" This seems more intuitive. Signed-off-by: Stephen Finucane --- patchwork/admin.py | 48 +++++++++++++----------------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/patchwork/admin.py b/patchwork/admin.py index d43cc4dd..0c006fd9 100644 --- a/patchwork/admin.py +++ b/patchwork/admin.py @@ -49,10 +49,6 @@ class UserAdmin(BaseUserAdmin): inlines = (UserProfileInline, ) -admin.site.unregister(User) -admin.site.register(User, UserAdmin) - - class DelegationRuleInline(admin.TabularInline): model = DelegationRule fields = ('path', 'user', 'priority') @@ -65,9 +61,6 @@ class ProjectAdmin(admin.ModelAdmin): ] -admin.site.register(Project, ProjectAdmin) - - class PersonAdmin(admin.ModelAdmin): list_display = ('__str__', 'has_account') search_fields = ('name', 'email') @@ -80,16 +73,10 @@ class PersonAdmin(admin.ModelAdmin): has_account.short_description = 'Account' -admin.site.register(Person, PersonAdmin) - - class StateAdmin(admin.ModelAdmin): list_display = ('name', 'action_required') -admin.site.register(State, StateAdmin) - - class SubmissionAdmin(admin.ModelAdmin): list_display = ('name', 'submitter', 'project', 'date') list_filter = ('project', ) @@ -97,10 +84,6 @@ class SubmissionAdmin(admin.ModelAdmin): date_hierarchy = 'date' -admin.site.register(Submission, SubmissionAdmin) -admin.site.register(CoverLetter, SubmissionAdmin) - - class PatchAdmin(admin.ModelAdmin): list_display = ('name', 'submitter', 'project', 'state', 'date', 'archived', 'is_pull_request') @@ -116,18 +99,12 @@ class PatchAdmin(admin.ModelAdmin): is_pull_request.short_description = 'Pull' -admin.site.register(Patch, PatchAdmin) - - class CommentAdmin(admin.ModelAdmin): list_display = ('submission', 'submitter', 'date') search_fields = ('submission__name', 'submitter__name', 'submitter__email') date_hierarchy = 'date' -admin.site.register(Comment, CommentAdmin) - - class PatchInline(admin.StackedInline): model = Series.patches.through extra = 0 @@ -146,9 +123,6 @@ class SeriesAdmin(admin.ModelAdmin): received_all.boolean = True -admin.site.register(Series, SeriesAdmin) - - class SeriesInline(admin.StackedInline): model = Series readonly_fields = ('date', 'submitter', 'version', 'total', @@ -166,9 +140,6 @@ class SeriesReferenceAdmin(admin.ModelAdmin): model = SeriesReference -admin.site.register(SeriesReference, SeriesReferenceAdmin) - - class CheckAdmin(admin.ModelAdmin): list_display = ('patch', 'user', 'state', 'target_url', 'description', 'context') @@ -177,20 +148,27 @@ class CheckAdmin(admin.ModelAdmin): date_hierarchy = 'date' -admin.site.register(Check, CheckAdmin) - - class BundleAdmin(admin.ModelAdmin): list_display = ('name', 'owner', 'project', 'public') list_filter = ('public', 'project') search_fields = ('name', 'owner') -admin.site.register(Bundle, BundleAdmin) - - class TagAdmin(admin.ModelAdmin): list_display = ('name',) +admin.site.unregister(User) +admin.site.register(User, UserAdmin) +admin.site.register(Project, ProjectAdmin) +admin.site.register(Person, PersonAdmin) +admin.site.register(State, StateAdmin) +admin.site.register(Submission, SubmissionAdmin) +admin.site.register(CoverLetter, SubmissionAdmin) +admin.site.register(Patch, PatchAdmin) +admin.site.register(Comment, CommentAdmin) +admin.site.register(Series, SeriesAdmin) +admin.site.register(SeriesReference, SeriesReferenceAdmin) +admin.site.register(Check, CheckAdmin) +admin.site.register(Bundle, BundleAdmin) admin.site.register(Tag, TagAdmin) From patchwork Sun Apr 15 22:54:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 898336 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 ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40PRhZ0fgLz9s1R for ; Mon, 16 Apr 2018 08:56:30 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="N+rdXz9U"; 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 40PRhY68FQzF1s5 for ; Mon, 16 Apr 2018 08:56:29 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="N+rdXz9U"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=23.83.214.27; helo=butterfly.maple.relay.mailchannels.net; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="N+rdXz9U"; dkim-atps=neutral Received: from butterfly.maple.relay.mailchannels.net (butterfly.maple.relay.mailchannels.net [23.83.214.27]) (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 40PRf601SWzF1Rv for ; Mon, 16 Apr 2018 08:54:21 +1000 (AEST) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id E1DBF40868 for ; Sun, 15 Apr 2018 22:54:18 +0000 (UTC) Received: from one.mxroute.com (unknown [100.96.12.37]) (Authenticated sender: 5xi41l16bi) by relay.mailchannels.net (Postfix) with ESMTPA id 80F504041A for ; Sun, 15 Apr 2018 22:54:18 +0000 (UTC) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from one.mxroute.com (one-outgoing.mxroute.com [172.19.42.253]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.14.1); Sun, 15 Apr 2018 22:54:18 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: 5xi41l16bi|x-authuser|stephen@that.guru X-MailChannels-Auth-Id: 5xi41l16bi X-Shade-Scare: 406cdbad619f8ca5_1523832858783_3364822070 X-MC-Loop-Signature: 1523832858783:2181319806 X-MC-Ingress-Time: 1523832858783 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=5M3g+6RjBIkgRU44ndWjxFTLk+uKkJVpZ0iQ3/Ou0ds=; b=N+rdXz9U9bPvf8ynEidvAGXgQt c051Codwq2NcMQrC/dN1UpDZ1A+U9fBAEtzbSQW9bYg9UvArrnlLY1HJacwOvwk7bJ1eFp1Ubwbod yQ8L/HCR2bow91ojfJ7hVR57GeaoG9P1+LB2r81cEGF9jGxhkv2SW/NOPGa7Z2c0XDamBg4vij8vI ynCscYOUa4XXIf++NcsoJt4TsYN7a+ghEvpdNrJaGra4wQ9ir4jCSQHE39ix9/MxVWrI53tnhPNlv KlvwoYZ0+hkk8VBl4VfKyfPljHLxYN9Kfd+oxiD+mM4lhyLl0Up8FpsQr7C3UJvn/vU9nWEUiDF/N T9TILw1A==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 06/11] admin: Add label views Date: Sun, 15 Apr 2018 23:54:00 +0100 Message-Id: <20180415225405.1354-7-stephen@that.guru> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180415225405.1354-1-stephen@that.guru> References: <20180415225405.1354-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.26 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" There are two added: a general labels view that includes both project and non-project labels, and an inline labels view that's part of the project. Signed-off-by: Stephen Finucane --- patchwork/admin.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/patchwork/admin.py b/patchwork/admin.py index 0c006fd9..b1278610 100644 --- a/patchwork/admin.py +++ b/patchwork/admin.py @@ -28,6 +28,7 @@ from patchwork.models import Check from patchwork.models import Comment from patchwork.models import CoverLetter from patchwork.models import DelegationRule +from patchwork.models import Label from patchwork.models import Patch from patchwork.models import Person from patchwork.models import Project @@ -54,10 +55,16 @@ class DelegationRuleInline(admin.TabularInline): fields = ('path', 'user', 'priority') +class LabelInline(admin.TabularInline): + model = Label + fields = ('name', 'description', 'color') + + class ProjectAdmin(admin.ModelAdmin): list_display = ('name', 'linkname', 'listid', 'listemail') inlines = [ DelegationRuleInline, + LabelInline, ] @@ -87,6 +94,7 @@ class SubmissionAdmin(admin.ModelAdmin): class PatchAdmin(admin.ModelAdmin): list_display = ('name', 'submitter', 'project', 'state', 'date', 'archived', 'is_pull_request') + readonly_fields = ('labels',) list_filter = ('project', 'state', 'archived') search_fields = ('name', 'submitter__name', 'submitter__email') date_hierarchy = 'date' @@ -158,6 +166,10 @@ class TagAdmin(admin.ModelAdmin): list_display = ('name',) +class LabelAdmin(admin.ModelAdmin): + list_display = ('name', 'color') + + admin.site.unregister(User) admin.site.register(User, UserAdmin) admin.site.register(Project, ProjectAdmin) @@ -172,3 +184,4 @@ admin.site.register(SeriesReference, SeriesReferenceAdmin) admin.site.register(Check, CheckAdmin) admin.site.register(Bundle, BundleAdmin) admin.site.register(Tag, TagAdmin) +admin.site.register(Label, LabelAdmin) From patchwork Sun Apr 15 22:54:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 898337 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 ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40PRhw5g3Tz9s1R for ; Mon, 16 Apr 2018 08:56:48 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="cSOP7fHo"; 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 40PRhw4BddzF1ql for ; Mon, 16 Apr 2018 08:56:48 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="cSOP7fHo"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=23.83.209.68; helo=giant.birch.relay.mailchannels.net; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="cSOP7fHo"; dkim-atps=neutral Received: from giant.birch.relay.mailchannels.net (giant.birch.relay.mailchannels.net [23.83.209.68]) (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 40PRf629lyzF1SH for ; Mon, 16 Apr 2018 08:54:21 +1000 (AEST) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id B5F6E40961 for ; Sun, 15 Apr 2018 22:54:19 +0000 (UTC) Received: from one.mxroute.com (unknown [100.96.15.28]) (Authenticated sender: 5xi41l16bi) by relay.mailchannels.net (Postfix) with ESMTPA id 5C1A3408E6 for ; Sun, 15 Apr 2018 22:54:19 +0000 (UTC) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from one.mxroute.com (one-outgoing.mxroute.com [172.19.51.240]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.14.1); Sun, 15 Apr 2018 22:54:19 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: 5xi41l16bi|x-authuser|stephen@that.guru X-MailChannels-Auth-Id: 5xi41l16bi X-White-Stupid: 17eccb8d13576e9e_1523832859615_2032928338 X-MC-Loop-Signature: 1523832859615:2900784018 X-MC-Ingress-Time: 1523832859614 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=tWBUcBj4BJsyXRaizopDtsKzvf3xLDhIW77Xc6T7Ai8=; b=cSOP7fHowDOMyiLVNNZGzAm52G lUtkk4fZiXlt73o17pjqNiPW1vp4j+Xv01ojaSUE6Rdy9RPbzThzfZB56GAg+wgaX2P6JWa7vRf+n ixKKGGIk19fhB6J16YHFUIM4xN7puOFpgDoq9ucU54+sKEfSpi7YdGpOJJxyDHWmsctAIPrOw07h9 EvRSFa9dH64I+fTNaByBy4vokpTKgTS/5ZxYkS6tACB5ilqtt5/tFrNYdUA9dQNailt9zeHlIs4U5 SN3bRvCLlnL0DkU7YBV5k4JlGKxfRco6K+r/srTDPR+BkFrqxEkA7OqiTHxoOiGljgt+L1xvzu8AN aV56KG4A==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 07/11] views: Populate 'project' attribute of PatchForm Date: Sun, 15 Apr 2018 23:54:01 +0100 Message-Id: <20180415225405.1354-8-stephen@that.guru> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180415225405.1354-1-stephen@that.guru> References: <20180415225405.1354-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.26 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" This is required to ensure we can filter delegates by project. If we don't do this, our