From bbe2f45571ce9aaea89a5e6feca79fb56203be6d Mon Sep 17 00:00:00 2001 From: Sudha Kumar Date: Fri, 13 Dec 2024 15:57:50 -0800 Subject: [PATCH] Removed comments, Fixed format --- backend/support/admin.py | 6 +++--- backend/support/cog_over.py | 18 +---------------- backend/support/models/__init__.py | 1 - backend/support/models/cog_over.py | 4 ---- backend/support/test_cog_over.py | 32 ++---------------------------- 5 files changed, 6 insertions(+), 55 deletions(-) diff --git a/backend/support/admin.py b/backend/support/admin.py index be84b5731..e22de4232 100644 --- a/backend/support/admin.py +++ b/backend/support/admin.py @@ -84,9 +84,9 @@ def change_view(self, request, object_id, form_url="", extra_context=None): extra_context = extra_context or {} extra_context["show_save_and_continue"] = False extra_context["show_save"] = False - extra_context["show_save_and_add_another"] = ( - False # this does not work if has_add_permision is True - ) + extra_context[ + "show_save_and_add_another" + ] = False # this does not work if has_add_permision is True return super().change_view(request, object_id, extra_context=extra_context) def save_model(self, request, obj, form, change): diff --git a/backend/support/cog_over.py b/backend/support/cog_over.py index 282078cbd..970c180f0 100644 --- a/backend/support/cog_over.py +++ b/backend/support/cog_over.py @@ -53,7 +53,7 @@ def compute_cog_over( oversight_agency = agency # logger.warning("Assigning an oversight agenct", oversight_agency) return (cognizant_agency, oversight_agency) - # base_year = calc_base_year(audit_year) + cognizant_agency = determine_hist_agency(auditee_ein, auditee_uei, audit_year) if cognizant_agency: return (cognizant_agency, oversight_agency) @@ -106,7 +106,6 @@ def determine_hist_agency(ein, uei, audit_year): if int(base_year) == FIRST_BASELINE_YEAR: dbkey = get_dbkey(ein, uei) - # cog_agency = lookup_baseline(ein, uei, dbkey) cog_agency = lookup_latest_cog(ein, uei, dbkey, base_year, audit_year) if cog_agency: return cog_agency @@ -152,21 +151,6 @@ def get_dbkey(ein, uei): return dbkey -# def lookup_baseline(ein, uei, dbkey): -# try: -# cognizant_agency = CognizantBaseline.objects.values_list( -# "cognizant_agency", flat=True -# ).get( -# Q(is_active=True) -# & ((Q(ein=ein) & Q(dbkey=dbkey)) | (Q(ein=ein) & Q(uei=uei))) -# )[ -# : -# ] -# except (CognizantBaseline.DoesNotExist, CognizantBaseline.MultipleObjectsReturned): -# cognizant_agency = None -# return cognizant_agency - - def lookup_latest_cog(ein, uei, dbkey, base_year, audit_year): query_years = [str(year) for year in range(int(base_year), int(audit_year) + 1)] cognizant_agency = None diff --git a/backend/support/models/__init__.py b/backend/support/models/__init__.py index ffcc6852b..474d68525 100644 --- a/backend/support/models/__init__.py +++ b/backend/support/models/__init__.py @@ -3,7 +3,6 @@ CognizantAssignment, ) from .cog_over import AssignmentTypeCode -# from .cog_over import reset_baseline models = [AdminApiEvent, CognizantAssignment] _for_the_linter = [AssignmentTypeCode] diff --git a/backend/support/models/cog_over.py b/backend/support/models/cog_over.py index c9ba324c7..0ca783d22 100644 --- a/backend/support/models/cog_over.py +++ b/backend/support/models/cog_over.py @@ -1,7 +1,5 @@ from django.apps import apps from django.db import models -from django.db.models import Q -from django.utils import timezone class AssignmentTypeCode: @@ -50,8 +48,6 @@ def save(self, *args, **kwargs): sac.cognizant_agency = cognizant_agency sac.save() - uei, ein = sac.auditee_uei, sac.ein - try: gen_model = apps.get_model("dissemination.General") gen = gen_model.objects.get(report_id=sac.report_id) diff --git a/backend/support/test_cog_over.py b/backend/support/test_cog_over.py index a815847e8..e6514ab93 100644 --- a/backend/support/test_cog_over.py +++ b/backend/support/test_cog_over.py @@ -419,14 +419,6 @@ def test_cog_assignment_with_uei_in_baseline(self): ) migration_inspection_record.save() - # baker.make( - # CognizantBaseline, - # uei=BASE_UEI, - # ein=BASE_EIN, - # dbkey=RESOLVABLE_DBKEY_WITH_BASELINE, - # cognizant_agency=BASE_COG, - # is_active=True, - # ) cog_agency, over_agency = compute_cog_over( sac.federal_awards, sac.submission_status, @@ -449,15 +441,6 @@ def test_cog_assignment_with_uei_in_baseline_and_overris(self): sac.report_id = "9991-09-GSAFAC-0000201851" sac.save() - # baker.make( - # CognizantBaseline, - # uei=BASE_UEI, - # ein=BASE_EIN, - # cognizant_agency=BASE_COG, - # ) - # cbs = CognizantBaseline.objects.all() - # self.assertEqual(len(cbs), 1) - cog_agency, _ = compute_cog_over( sac.federal_awards, sac.submission_status, @@ -468,8 +451,7 @@ def test_cog_assignment_with_uei_in_baseline_and_overris(self): record_cog_assignment(sac.report_id, sac.submitted_by, cog_agency) cas = CognizantAssignment.objects.all() self.assertEqual(len(cas), 1) - # cbs = CognizantBaseline.objects.all() - # self.assertEqual(len(cbs), 1) + sac = SingleAuditChecklist.objects.get(report_id=sac.report_id) self.assertEqual(sac.cognizant_agency, cog_agency) @@ -482,8 +464,7 @@ def test_cog_assignment_with_uei_in_baseline_and_overris(self): ).save() cas = CognizantAssignment.objects.all() self.assertEqual(len(cas), 2) - # cbs = CognizantBaseline.objects.all() - # self.assertEqual(len(cbs), 2) + sac = SingleAuditChecklist.objects.get(report_id=sac.report_id) self.assertEqual(sac.cognizant_agency, oberride_cog) @@ -578,15 +559,6 @@ def test_cog_assignment_for_2027_w_baseline(self): sac.save() - # baker.make( - # CognizantBaseline, - # uei="ZQGGHJH74DW7", - # ein=UNIQUE_EIN_WITHOUT_DBKEY, - # cognizant_agency="24", - # ) - # cbs = CognizantBaseline.objects.all() - # self.assertEqual(len(cbs), 1) - cog_agency, over_agency = compute_cog_over( sac.federal_awards, sac.submission_status,