From b9c05d132882b42ac4fd98eed50f847753825286 Mon Sep 17 00:00:00 2001 From: Tim Ballard <1425377+timoballard@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:25:28 -0600 Subject: [PATCH] django admin tooling for dissem (#3342) --- backend/dissemination/admin.py | 266 +++++++++++++++++- ..._alter_additionalein_report_id_and_more.py | 91 ++++++ backend/dissemination/models.py | 39 ++- 3 files changed, 372 insertions(+), 24 deletions(-) create mode 100644 backend/dissemination/migrations/0012_alter_additionalein_report_id_and_more.py diff --git a/backend/dissemination/admin.py b/backend/dissemination/admin.py index 4d9ecf388a..cc1e4115a2 100644 --- a/backend/dissemination/admin.py +++ b/backend/dissemination/admin.py @@ -11,17 +11,259 @@ Note, Passthrough, SecondaryAuditor, - OneTimeAccess, ) -admin.site.register(AdditionalEin) -admin.site.register(AdditionalUei) -admin.site.register(CapText) -admin.site.register(FederalAward) -admin.site.register(Finding) -admin.site.register(FindingText) -admin.site.register(General) -admin.site.register(Note) -admin.site.register(Passthrough) -admin.site.register(SecondaryAuditor) -admin.site.register(OneTimeAccess) + +class AdditionalEinAdmin(admin.ModelAdmin): + def has_add_permission(self, request, obj=None): + return False + + def has_change_permission(self, request, obj=None): + return False + + def has_delete_permission(self, request, obj=None): + return False + + def has_module_permission(self, request, obj=None): + return request.user.is_staff + + def has_view_permission(self, request, obj=None): + return request.user.is_staff + + list_display = ( + "report_id", + "additional_ein", + ) + + search_fields = ("report_id",) + + +class AdditionalUeiAdmin(admin.ModelAdmin): + def has_add_permission(self, request, obj=None): + return False + + def has_change_permission(self, request, obj=None): + return False + + def has_delete_permission(self, request, obj=None): + return False + + def has_module_permission(self, request, obj=None): + return request.user.is_staff + + def has_view_permission(self, request, obj=None): + return request.user.is_staff + + list_display = ( + "report_id", + "additional_uei", + ) + + search_fields = ("report_id",) + + +class CapTextAdmin(admin.ModelAdmin): + def has_add_permission(self, request, obj=None): + return False + + def has_change_permission(self, request, obj=None): + return False + + def has_delete_permission(self, request, obj=None): + return False + + def has_module_permission(self, request, obj=None): + return request.user.is_staff + + def has_view_permission(self, request, obj=None): + return request.user.is_staff + + list_display = ( + "report_id", + "finding_ref_number", + ) + + search_fields = ("report_id",) + + +class FederalAwardAdmin(admin.ModelAdmin): + def has_add_permission(self, request, obj=None): + return False + + def has_change_permission(self, request, obj=None): + return False + + def has_delete_permission(self, request, obj=None): + return False + + def has_module_permission(self, request, obj=None): + return request.user.is_staff + + def has_view_permission(self, request, obj=None): + return request.user.is_staff + + list_display = ( + "report_id", + "award_reference", + ) + + search_fields = ("report_id",) + + +class FindingAdmin(admin.ModelAdmin): + def has_add_permission(self, request, obj=None): + return False + + def has_change_permission(self, request, obj=None): + return False + + def has_delete_permission(self, request, obj=None): + return False + + def has_module_permission(self, request, obj=None): + return request.user.is_staff + + def has_view_permission(self, request, obj=None): + return request.user.is_staff + + list_display = ( + "report_id", + "award_reference", + "reference_number", + ) + + search_fields = ("report_id",) + + +class FindingTextAdmin(admin.ModelAdmin): + def has_add_permission(self, request, obj=None): + return False + + def has_change_permission(self, request, obj=None): + return False + + def has_delete_permission(self, request, obj=None): + return False + + def has_module_permission(self, request, obj=None): + return request.user.is_staff + + def has_view_permission(self, request, obj=None): + return request.user.is_staff + + list_display = ( + "report_id", + "finding_ref_number", + ) + + search_fields = ("report_id",) + + +class GeneralAdmin(admin.ModelAdmin): + def has_add_permission(self, request, obj=None): + return False + + def has_change_permission(self, request, obj=None): + return False + + def has_delete_permission(self, request, obj=None): + return False + + def has_module_permission(self, request, obj=None): + return request.user.is_staff + + def has_view_permission(self, request, obj=None): + return request.user.is_staff + + list_display = ( + "report_id", + "auditee_name", + "date_created", + ) + + search_fields = ("report_id",) + + +class NoteAdmin(admin.ModelAdmin): + def has_add_permission(self, request, obj=None): + return False + + def has_change_permission(self, request, obj=None): + return False + + def has_delete_permission(self, request, obj=None): + return False + + def has_module_permission(self, request, obj=None): + return request.user.is_staff + + def has_view_permission(self, request, obj=None): + return request.user.is_staff + + list_display = ( + "report_id", + "note_title", + ) + + search_fields = ("report_id",) + + +class PassThroughAdmin(admin.ModelAdmin): + def has_add_permission(self, request, obj=None): + return False + + def has_change_permission(self, request, obj=None): + return False + + def has_delete_permission(self, request, obj=None): + return False + + def has_module_permission(self, request, obj=None): + return request.user.is_staff + + def has_view_permission(self, request, obj=None): + return request.user.is_staff + + list_display = ( + "report_id", + "award_reference", + "passthrough_id", + ) + + search_fields = ("report_id",) + + +class SecondaryAuditorAdmin(admin.ModelAdmin): + def has_add_permission(self, request, obj=None): + return False + + def has_change_permission(self, request, obj=None): + return False + + def has_delete_permission(self, request, obj=None): + return False + + def has_module_permission(self, request, obj=None): + return request.user.is_staff + + def has_view_permission(self, request, obj=None): + return request.user.is_staff + + list_display = ( + "report_id", + "auditor_ein", + ) + + search_fields = ("report_id",) + + +admin.site.register(AdditionalEin, AdditionalEinAdmin) +admin.site.register(AdditionalUei, AdditionalUeiAdmin) +admin.site.register(CapText, CapTextAdmin) +admin.site.register(FederalAward, FederalAwardAdmin) +admin.site.register(Finding, FindingAdmin) +admin.site.register(FindingText, FindingTextAdmin) +admin.site.register(General, GeneralAdmin) +admin.site.register(Note, NoteAdmin) +admin.site.register(Passthrough, PassThroughAdmin) +admin.site.register(SecondaryAuditor, SecondaryAuditorAdmin) diff --git a/backend/dissemination/migrations/0012_alter_additionalein_report_id_and_more.py b/backend/dissemination/migrations/0012_alter_additionalein_report_id_and_more.py new file mode 100644 index 0000000000..f51ddbd7f5 --- /dev/null +++ b/backend/dissemination/migrations/0012_alter_additionalein_report_id_and_more.py @@ -0,0 +1,91 @@ +# Generated by Django 4.2.6 on 2024-02-02 19:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("dissemination", "0011_onetimeaccess"), + ] + + operations = [ + migrations.AlterField( + model_name="additionalein", + name="report_id", + field=models.TextField( + help_text="GSAFAC generated identifier", verbose_name="Report ID" + ), + ), + migrations.AlterField( + model_name="additionaluei", + name="report_id", + field=models.TextField( + help_text="GSAFAC generated identifier", verbose_name="Report ID" + ), + ), + migrations.AlterField( + model_name="captext", + name="report_id", + field=models.TextField( + help_text="GSAFAC generated identifier", verbose_name="Report ID" + ), + ), + migrations.AlterField( + model_name="federalaward", + name="report_id", + field=models.TextField( + help_text="GSAFAC generated identifier", verbose_name="Report ID" + ), + ), + migrations.AlterField( + model_name="finding", + name="report_id", + field=models.TextField( + help_text="GSAFAC generated identifier", verbose_name="Report ID" + ), + ), + migrations.AlterField( + model_name="findingtext", + name="report_id", + field=models.TextField( + help_text="GSAFAC generated identifier", verbose_name="Report ID" + ), + ), + migrations.AlterField( + model_name="general", + name="report_id", + field=models.TextField( + help_text="GSAFAC generated identifier", + unique=True, + verbose_name="Report ID", + ), + ), + migrations.AlterField( + model_name="note", + name="report_id", + field=models.TextField( + help_text="GSAFAC generated identifier", verbose_name="Report ID" + ), + ), + migrations.AlterField( + model_name="onetimeaccess", + name="report_id", + field=models.TextField( + help_text="GSAFAC generated identifier", verbose_name="Report ID" + ), + ), + migrations.AlterField( + model_name="passthrough", + name="report_id", + field=models.TextField( + help_text="GSAFAC generated identifier", verbose_name="Report ID" + ), + ), + migrations.AlterField( + model_name="secondaryauditor", + name="report_id", + field=models.TextField( + help_text="GSAFAC generated identifier", verbose_name="Report ID" + ), + ), + ] diff --git a/backend/dissemination/models.py b/backend/dissemination/models.py index 4f328719bc..4f86724193 100644 --- a/backend/dissemination/models.py +++ b/backend/dissemination/models.py @@ -7,14 +7,15 @@ BIGINT_MAX_DIGITS = 25 -REPORT_ID_FK_HELP_TEXT = "; foreign key everywhere else" +REPORT_ID_FK_HELP_TEXT = "GSAFAC generated identifier" class FindingText(models.Model): """Specific findings details. References General""" report_id = models.TextField( - REPORT_ID_FK_HELP_TEXT, + "Report ID", + help_text=REPORT_ID_FK_HELP_TEXT, ) finding_ref_number = models.TextField( "Finding Reference Number - FK", @@ -33,14 +34,20 @@ class FindingText(models.Model): class AdditionalUei(models.Model): """Additional UEIs for this audit.""" - report_id = models.TextField(REPORT_ID_FK_HELP_TEXT) + report_id = models.TextField( + "Report ID", + help_text=REPORT_ID_FK_HELP_TEXT, + ) additional_uei = models.TextField() class AdditionalEin(models.Model): """Additional EINs for this audit.""" - report_id = models.TextField(REPORT_ID_FK_HELP_TEXT) + report_id = models.TextField( + "Report ID", + help_text=REPORT_ID_FK_HELP_TEXT, + ) additional_ein = models.TextField() @@ -83,7 +90,8 @@ class Finding(models.Model): help_text=docs.prior_finding_ref_nums, ) report_id = models.TextField( - REPORT_ID_FK_HELP_TEXT, + "Report ID", + help_text=REPORT_ID_FK_HELP_TEXT, ) # each element in the list is a FK to Finding type_requirement = models.TextField( @@ -180,7 +188,8 @@ class FederalAward(models.Model): null=True, ) report_id = models.TextField( - REPORT_ID_FK_HELP_TEXT, + "Report ID", + help_text=REPORT_ID_FK_HELP_TEXT, ) state_cluster_name = models.TextField( "The name of the state cluster", @@ -204,7 +213,8 @@ class CapText(models.Model): help_text=docs.text_captext, ) report_id = models.TextField( - REPORT_ID_FK_HELP_TEXT, + "Report ID", + help_text=REPORT_ID_FK_HELP_TEXT, ) @@ -217,7 +227,8 @@ class Note(models.Model): is_minimis_rate_used = models.TextField("'Yes', 'No', or 'Both' (2 CFR 200.414(f))") rate_explained = models.TextField("Explanation for minimis rate") report_id = models.TextField( - REPORT_ID_FK_HELP_TEXT, + "Report ID", + help_text=REPORT_ID_FK_HELP_TEXT, ) content = models.TextField("Content of the Note", help_text=docs.content) note_title = models.TextField("Note title", help_text=docs.title) @@ -234,7 +245,8 @@ class Passthrough(models.Model): "Order that the award line was reported", ) report_id = models.TextField( - "G-FAC generated identifier. FK refers to General", + "Report ID", + help_text=REPORT_ID_FK_HELP_TEXT, ) passthrough_id = models.TextField( "Identifying Number Assigned by the Pass-through Entity", @@ -258,7 +270,8 @@ class General(models.Model): # ] report_id = models.TextField( - "G-FAC generated identifier. ", + "Report ID", + help_text=REPORT_ID_FK_HELP_TEXT, unique=True, ) auditee_certify_name = models.TextField( @@ -533,7 +546,8 @@ class SecondaryAuditor(models.Model): help_text=docs.auditor_title, ) report_id = models.TextField( - REPORT_ID_FK_HELP_TEXT, + "Report ID", + help_text=REPORT_ID_FK_HELP_TEXT, ) @@ -546,7 +560,8 @@ class OneTimeAccess(models.Model): "API key Id for the user", ) report_id = models.TextField( - "Report ID for the PDF being requested", + "Report ID", + help_text=REPORT_ID_FK_HELP_TEXT, )