Skip to content

Commit

Permalink
Hl 1306 admin changes (#3048)
Browse files Browse the repository at this point in the history
* feat: add created at to log entry listings

* feat: add batch link to application admin page

* feat: add created_at to log entry list view

* feat: add timestamps to application log  admin

* feat: exclude ssn from employee admin page
  • Loading branch information
rikuke authored May 30, 2024
1 parent fe9112f commit bfcca13
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
61 changes: 59 additions & 2 deletions backend/benefit/applications/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django import forms
from django.contrib import admin
from django.urls import reverse
from django.utils.html import format_html
from django.utils.safestring import mark_safe

from applications.models import (
Expand Down Expand Up @@ -104,6 +106,7 @@ class ApplicationAdmin(admin.ModelAdmin):
"company_contact_person_email",
"company_contact_person_first_name",
"company_contact_person_last_name",
"batch",
"created_at",
"modified_at",
"__str__",
Expand All @@ -124,6 +127,33 @@ class ApplicationAdmin(admin.ModelAdmin):
ordering = ("-created_at",)
exclude = ("bases",)

readonly_fields = ["batch_details"]

fieldsets = (
(None, {"fields": ("status", "batch")}),
(
"Batch Information",
{
"fields": ("batch_details",),
},
),
)

def batch_details(self, obj):
if obj.batch:
url = reverse(
"admin:applications_applicationbatch_change", args=[obj.batch.id]
)
return format_html(
'<a href="{}">{}</a>',
url,
obj.batch.id,
)

return "Not assigned to any batch"

batch_details.short_description = "Batch Details"


class ApplicationInline(admin.StackedInline):
model = Application
Expand Down Expand Up @@ -190,13 +220,40 @@ class AhjoDecisionTextAdmin(admin.ModelAdmin):
search_fields = ["id", "decision_type", "application_id"]


class ApplicationLogEntryAdmin(admin.ModelAdmin):
fields = [
"application",
"created_at",
"modified_at",
"from_status",
"to_status",
"comment",
]
list_display = ["application", "created_at", "modified_at"]
readonly_fields = ["created_at", "modified_at"]
search_fields = ["application__id"]


class EmployeeAdmin(admin.ModelAdmin):
exclude = ("encrypted_social_security_number", "social_security_number")
list_display = [
"id",
"first_name",
"last_name",
"application",
"created_at",
"modified_at",
]
search_fields = ["id", "application__id"]


admin.site.register(Application, ApplicationAdmin)
admin.site.register(ApplicationBatch, ApplicationBatchAdmin)
admin.site.register(DeMinimisAid)
admin.site.register(Employee)
admin.site.register(Employee, EmployeeAdmin)
admin.site.register(Attachment)
admin.site.register(ApplicationBasis, ApplicationBasisAdmin)
admin.site.register(ApplicationLogEntry)
admin.site.register(ApplicationLogEntry, ApplicationLogEntryAdmin)
admin.site.register(AhjoSetting, AhjoSettingAdmin)
admin.site.register(
DecisionProposalTemplateSection, DecisionProposalTemplateSectionAdmin
Expand Down
1 change: 1 addition & 0 deletions backend/shared/shared/audit_log/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class AuditLogEntryAdmin(admin.ModelAdmin):
fields = ("id", "created_at", "message")
list_display = ["message", "created_at"]
readonly_fields = ("id", "created_at", "message")


Expand Down

0 comments on commit bfcca13

Please sign in to comment.