[PATCH 06/11] admin: Add label views

Stephen Finucane stephen at that.guru
Mon Apr 16 08:54:00 AEST 2018


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 <stephen at that.guru>
---
 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)
-- 
2.14.3



More information about the Patchwork mailing list