diff mbox series

[06/11] admin: Add label views

Message ID 20180415225405.1354-7-stephen@that.guru
State Superseded
Headers show
Series Add labels support | expand

Commit Message

Stephen Finucane April 15, 2018, 10:54 p.m. UTC
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@that.guru>
---
 patchwork/admin.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

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)