From patchwork Sun Oct 14 12:45:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 983716 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 42Y1ZN3Qn7z9s8F for ; Sun, 14 Oct 2018 23:47:56 +1100 (AEDT) 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="ITp8M2OC"; 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 42Y1ZN1q5fzF3Dt for ; Sun, 14 Oct 2018 23:47:56 +1100 (AEDT) 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="ITp8M2OC"; 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=185.234.75.13; helo=relay013.mxrelay.co; 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="ITp8M2OC"; dkim-atps=neutral Received: from relay013.mxrelay.co (relay013.mxrelay.co [185.234.75.13]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42Y1YP2P1BzF18l for ; Sun, 14 Oct 2018 23:47:05 +1100 (AEDT) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay013.mxrelay.co (Postfix) with ESMTP id 7C1E442DD6; Sun, 14 Oct 2018 12:46:32 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id 649503F051; Sun, 14 Oct 2018 12:46:32 +0000 (UTC) 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=7xPLQ28XxTV1ssJnmLV/vIHmzMTmQMFVb2f+EnxXDsA=; b=ITp8M2OCuhRjKqag8A8b8dsPFR VECQKZQGJElLuexEwrOtmsXxjpE1C1IERrIX8LpxOvMJEIL23pfoidaL3mPsRIK5xG8TAvNN39GhJ Y0H7ig9eCBuHl4MrVP1et0ZE9u+1CtkZ3sT3jqjQtihj0dGz5S4hG5uIFpPLfL4hwDHC3m1WmeIeX rWTTjs4+WVFPtnttv2UPo+OJPwMfTtm9xjit6KGAXLOdNyy/CsqW/spB5kuXcaqxtbcHcKfQopRhz HT7G/0/L0UlSkgiPIiGjHHL1aFck8VhTRBGYPzY8vehQrMvKJrEnyuq+XwnayFhE1/0Acn4y+xwPF uqGrBs3Q==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH v2 02/10] models: Add submission labels Date: Sun, 14 Oct 2018 13:45:33 +0100 Message-Id: <20181014124541.13393-3-stephen@that.guru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181014124541.13393-1-stephen@that.guru> References: <20181014124541.13393-1-stephen@that.guru> X-AuthUser: stephen@that.guru 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: , Cc: mpe@ellerman.id.au, andrew.donnellan@au1.ibm.com 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 submission. 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 --- v2: - Associate labels with cover letters as well as patches - Update migration numbers - Add release note --- patchwork/fixtures/default_labels.xml | 9 +++++ patchwork/migrations/0031_add_labels.py | 39 +++++++++++++++++++ patchwork/models.py | 35 +++++++++++++++++ .../notes/labels-6d0096c7d8505627.yaml | 11 ++++++ 4 files changed, 94 insertions(+) create mode 100644 patchwork/fixtures/default_labels.xml create mode 100644 patchwork/migrations/0031_add_labels.py create mode 100644 releasenotes/notes/labels-6d0096c7d8505627.yaml diff --git a/patchwork/fixtures/default_labels.xml b/patchwork/fixtures/default_labels.xml new file mode 100644 index 00000000..1e1aa705 --- /dev/null +++ b/patchwork/fixtures/default_labels.xml @@ -0,0 +1,9 @@ + + + + + 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. + #EDEDED + + diff --git a/patchwork/migrations/0031_add_labels.py b/patchwork/migrations/0031_add_labels.py new file mode 100644 index 00000000..ba93ecd6 --- /dev/null +++ b/patchwork/migrations/0031_add_labels.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.15 on 2018-09-13 03:49 +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', '0030_add_submission_covering_index'), + ] + + 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, blank=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='submission', + 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 a043844d..b6a1fe38 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -18,6 +18,7 @@ from django.urls import reverse from django.utils.encoding import python_2_unicode_compatible from django.utils.functional import cached_property +from patchwork.fields import ColorField from patchwork.fields import HashField from patchwork.hasher import hash_diff @@ -219,6 +220,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, + blank=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) @@ -355,6 +389,7 @@ class Submission(FilenameMixin, EmailMixin, models.Model): # submission metadata name = models.CharField(max_length=255) + labels = models.ManyToManyField(Label) # patchwork metadata diff --git a/releasenotes/notes/labels-6d0096c7d8505627.yaml b/releasenotes/notes/labels-6d0096c7d8505627.yaml new file mode 100644 index 00000000..fdebd6b7 --- /dev/null +++ b/releasenotes/notes/labels-6d0096c7d8505627.yaml @@ -0,0 +1,11 @@ +--- +features: + - | + Add support for patch labels. Labels are a way to organize and prioritize + submissions. You can apply labels to patches and cover letters to signify + priority, category, or any other marker you wish. + + Labels can be either global or tied to the project they are created in. + Labels can have an optional description attached, which will provide a + little insight into the purpose of the label. Labels are completely + customizable and the labels available will vary by instance.