From: Stephen Finucane <[email protected]> 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: Franciszek Stachura <[email protected]> --- v3: - Added extra = 0 to LabelInline to remove unnecessary empty label forms. - Use admin.register decorator --- patchwork/admin.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/patchwork/admin.py b/patchwork/admin.py index d3bdae1b..267a3820 100644 --- a/patchwork/admin.py +++ b/patchwork/admin.py @@ -13,6 +13,7 @@ from patchwork.models import Check from patchwork.models import Cover from patchwork.models import CoverComment from patchwork.models import DelegationRule +from patchwork.models import Label from patchwork.models import Patch from patchwork.models import PatchComment from patchwork.models import PatchRelation @@ -44,11 +45,18 @@ class DelegationRuleInline(admin.TabularInline): fields = ('path', 'user', 'priority') +class LabelInline(admin.TabularInline): + model = Label + fields = ('name', 'description', 'color') + extra = 0 + + @admin.register(Project) class ProjectAdmin(admin.ModelAdmin): list_display = ('name', 'linkname', 'listid', 'listemail') inlines = [ DelegationRuleInline, + LabelInline, ] @@ -91,6 +99,7 @@ class PatchAdmin(admin.ModelAdmin): 'is_pull_request', ) list_filter = ('project', 'submitter', 'state', 'archived') + readonly_fields = ('labels',) list_select_related = ('submitter', 'project', 'state') search_fields = ('name', 'submitter__name', 'submitter__email') date_hierarchy = 'date' @@ -194,3 +203,12 @@ class TagAdmin(admin.ModelAdmin): @admin.register(PatchRelation) class PatchRelationAdmin(admin.ModelAdmin): model = PatchRelation + + [email protected](Label) +class LabelAdmin(admin.ModelAdmin): + list_display = ('name', 'color') + + def get_queryset(self, request): + qs = super(LabelAdmin, self).get_queryset(request) + return qs.filter(project=None) -- 2.55.0 _______________________________________________ Patchwork mailing list [email protected] https://lists.ozlabs.org/listinfo/patchwork
