From ac330707b3300f8713c93acf936304c578218944 Mon Sep 17 00:00:00 2001 From: Michiel Holtkamp Date: Tue, 26 Nov 2019 14:40:45 +0100 Subject: [PATCH] OPT: Show some 'created_at' fields because they are used for sorting --- katka/admin.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/katka/admin.py b/katka/admin.py index 331b1da..6c085d8 100644 --- a/katka/admin.py +++ b/katka/admin.py @@ -16,7 +16,11 @@ ) -class WithUsernameAdminModel(admin.ModelAdmin): +class ReadOnlyAuditFieldsMixin: + readonly_fields = ("created_at", "created_username", "modified_at", "modified_username", "deleted") + + +class WithUsernameAdminModel(admin.ModelAdmin, ReadOnlyAuditFieldsMixin): def save_model(self, request, obj, form, change): with username_on_model(self.model, request.user.username): super().save_model(request, obj, form, change) @@ -69,7 +73,7 @@ class SCMPipelineRunAdmin(WithUsernameAdminModel): "pipeline_yaml", "application", ) - list_display = ("pk", "application", "commit_hash", "first_parent_hash") + list_display = ("pk", "application", "commit_hash", "first_parent_hash", "created_at") list_filter = ("application__name",) ordering = ("created_at",) @@ -77,7 +81,7 @@ class SCMPipelineRunAdmin(WithUsernameAdminModel): @admin.register(SCMStepRun) class SCMStepRunAdmin(WithUsernameAdminModel): fields = ("slug", "name", "stage", "status", "output", "started_at", "ended_at", "scm_pipeline_run") - list_display = ("pk", "scm_pipeline_run", "name", "stage", "status", "started_at", "ended_at") + list_display = ("pk", "scm_pipeline_run", "name", "stage", "status", "created_at", "started_at", "ended_at") list_filter = ("scm_pipeline_run__application__name",) ordering = ("created_at",) @@ -91,5 +95,5 @@ class ApplicationMetadataAdmin(WithUsernameAdminModel): @admin.register(SCMRelease) class SCMReleaseAdmin(WithUsernameAdminModel): fields = ("name", "status", "started_at", "ended_at", "scm_pipeline_runs") - list_display = ("pk", "name") + list_display = ("pk", "name", "status", "created_at", "started_at", "ended_at") ordering = ("created_at",)