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