Skip to content

Commit 65c90ee

Browse files
stephenfinfstachura
authored andcommitted
admin: Add label views
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.
1 parent 029d4bd commit 65c90ee

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎patchwork/admin.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from patchwork.models import Cover
1414
from patchwork.models import CoverComment
1515
from patchwork.models import DelegationRule
16+
from patchwork.models import Label
1617
from patchwork.models import Patch
1718
from patchwork.models import PatchComment
1819
from patchwork.models import PatchRelation
@@ -44,11 +45,18 @@ class DelegationRuleInline(admin.TabularInline):
4445
fields = ('path', 'user', 'priority')
4546

4647

48+
class LabelInline(admin.TabularInline):
49+
model = Label
50+
fields = ('name', 'description', 'color')
51+
extra = 0
52+
53+
4754
@admin.register(Project)
4855
class ProjectAdmin(admin.ModelAdmin):
4956
list_display = ('name', 'linkname', 'listid', 'listemail')
5057
inlines = [
5158
DelegationRuleInline,
59+
LabelInline,
5260
]
5361

5462

@@ -91,6 +99,7 @@ class PatchAdmin(admin.ModelAdmin):
9199
'is_pull_request',
92100
)
93101
list_filter = ('project', 'submitter', 'state', 'archived')
102+
readonly_fields = ('labels',)
94103
list_select_related = ('submitter', 'project', 'state')
95104
search_fields = ('name', 'submitter__name', 'submitter__email')
96105
date_hierarchy = 'date'
@@ -194,3 +203,12 @@ class TagAdmin(admin.ModelAdmin):
194203
@admin.register(PatchRelation)
195204
class PatchRelationAdmin(admin.ModelAdmin):
196205
model = PatchRelation
206+
207+
208+
@admin.register(Label)
209+
class LabelAdmin(admin.ModelAdmin):
210+
list_display = ('name', 'color')
211+
212+
def get_queryset(self, request):
213+
qs = super(LabelAdmin, self).get_queryset(request)
214+
return qs.filter(project=None)

0 commit comments

Comments
 (0)