From 36a9d42aec04c3fe576f1f24a0dcae1fb00647ac Mon Sep 17 00:00:00 2001 From: "Hassan D. M. Sambo" Date: Fri, 2 Feb 2024 08:18:13 -0500 Subject: [PATCH 1/3] Updated dev and preview instance memories (#3334) --- backend/manifests/vars/vars-dev.yml | 2 +- backend/manifests/vars/vars-preview.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/manifests/vars/vars-dev.yml b/backend/manifests/vars/vars-dev.yml index 7cb4caf102..fba5803da7 100644 --- a/backend/manifests/vars/vars-dev.yml +++ b/backend/manifests/vars/vars-dev.yml @@ -1,5 +1,5 @@ app_name: gsa-fac -mem_amount: 512M +mem_amount: 2G cf_env_name: DEVELOPMENT env_name: dev service_name: dev diff --git a/backend/manifests/vars/vars-preview.yml b/backend/manifests/vars/vars-preview.yml index 1763029779..c834408894 100644 --- a/backend/manifests/vars/vars-preview.yml +++ b/backend/manifests/vars/vars-preview.yml @@ -1,5 +1,5 @@ app_name: gsa-fac -mem_amount: 6G +mem_amount: 2G cf_env_name: PREVIEW env_name: preview service_name: preview 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 2/3] 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, ) From 3ef6ce8601a96809b20443061613409108970887 Mon Sep 17 00:00:00 2001 From: James Person Date: Fri, 2 Feb 2024 15:21:00 -0500 Subject: [PATCH 3/3] Omit Underscored Fields from Pre-certification Reports (#3340) * 500 errors should have (some limited) context. * Pre-cert reports should not append bonus fields. * Pre-cert reports should not append bonus fields. * Omit underscored fields from column names. --- backend/dissemination/summary_reports.py | 28 ++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/backend/dissemination/summary_reports.py b/backend/dissemination/summary_reports.py index f272bf0120..31291002c2 100644 --- a/backend/dissemination/summary_reports.py +++ b/backend/dissemination/summary_reports.py @@ -107,6 +107,10 @@ "BJ", ] +# Each field here represents a field from the dissemination models, with the exeption of underscored fields. +# Underscored fields are generated from other disseminated data, and should be ommitted from the pre-certification reports. +# These fields are handled in "_get_attribute_or_data()" +# If one would like to add more fields that require preprocessing (such as "_aln"), ensure that they begin with an underscore. field_name_ordered = { "general": [ "report_id", @@ -413,20 +417,26 @@ def gather_report_data_pre_certification(i2d_data): # We also strip tzinfo from the dates, because excel doesn't like them. # Once a row is created, append it to the data[ModelName]['entries'] array. for model in models: - model_name = model.__name__.lower() - # This pulls directly from the model - # fields = model._meta.get_fields() - # field_names = [f.name for f in fields] - # This uses the ordered columns above - field_names = field_name_ordered[model_name] - data[model_name] = {"field_names": field_names, "entries": []} - + model_name = ( + model.__name__.lower() + ) # Sheet/tab name, ex. "federalaward", "finding" + field_names = [ + field_name + for field_name in field_name_ordered[model_name] + if not field_name.startswith("_") + ] # Column names, omitting "_" fields + data[model_name] = { + "field_names": field_names, + "entries": [], + } # The sheet/tab content, with no rows by default + + # For every instance of a model we have, generate an appropriate row and append it to the sheet/tab. + # Ignore underscored fields and wipe timezone information. for obj in dissemination_data[model_name]: row = [] for field_name in field_names: if not field_name.startswith("_"): value = getattr(obj, field_name) - # Wipe tzinfo if isinstance(value, datetime): value = value.replace(tzinfo=None) row.append(value)