|
13 | 13 | from patchwork.models import Cover |
14 | 14 | from patchwork.models import CoverComment |
15 | 15 | from patchwork.models import DelegationRule |
| 16 | +from patchwork.models import Label |
16 | 17 | from patchwork.models import Patch |
17 | 18 | from patchwork.models import PatchComment |
18 | 19 | from patchwork.models import PatchRelation |
@@ -44,11 +45,18 @@ class DelegationRuleInline(admin.TabularInline): |
44 | 45 | fields = ('path', 'user', 'priority') |
45 | 46 |
|
46 | 47 |
|
| 48 | +class LabelInline(admin.TabularInline): |
| 49 | + model = Label |
| 50 | + fields = ('name', 'description', 'color') |
| 51 | + extra = 0 |
| 52 | + |
| 53 | + |
47 | 54 | @admin.register(Project) |
48 | 55 | class ProjectAdmin(admin.ModelAdmin): |
49 | 56 | list_display = ('name', 'linkname', 'listid', 'listemail') |
50 | 57 | inlines = [ |
51 | 58 | DelegationRuleInline, |
| 59 | + LabelInline, |
52 | 60 | ] |
53 | 61 |
|
54 | 62 |
|
@@ -91,6 +99,7 @@ class PatchAdmin(admin.ModelAdmin): |
91 | 99 | 'is_pull_request', |
92 | 100 | ) |
93 | 101 | list_filter = ('project', 'submitter', 'state', 'archived') |
| 102 | + readonly_fields = ('labels',) |
94 | 103 | list_select_related = ('submitter', 'project', 'state') |
95 | 104 | search_fields = ('name', 'submitter__name', 'submitter__email') |
96 | 105 | date_hierarchy = 'date' |
@@ -194,3 +203,12 @@ class TagAdmin(admin.ModelAdmin): |
194 | 203 | @admin.register(PatchRelation) |
195 | 204 | class PatchRelationAdmin(admin.ModelAdmin): |
196 | 205 | 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