Skip to content

Commit

Permalink
Merge pull request #3088 from GSA-TTS/main
Browse files Browse the repository at this point in the history
  • Loading branch information
jadudm authored Dec 27, 2023
2 parents c212fea + 3635277 commit 1e4c2c4
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 4 deletions.
Binary file not shown.
Binary file not shown.
33 changes: 33 additions & 0 deletions backend/audit/intakelib/checks/check_aln_prefix_pattern.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import logging
import re
from django.conf import settings

from django.core.exceptions import ValidationError
from ..intermediate_representation import (
get_range_by_name,
)
from ..common import get_message, build_cell_error_tuple

logger = logging.getLogger(__name__)


# DESCRIPTION
# The ALN prefix represents a two-digit number ##
# TESTED BY has_bad_aln_prefix.xlsx
def aln_agency_prefix(ir):
prefixes = get_range_by_name(ir, "federal_agency_prefix")
errors = []
for index, prefix in enumerate(prefixes["values"]):
if not re.match(settings.REGEX_ALN_PREFIX, str(prefix)):
errors.append(
build_cell_error_tuple(
ir,
prefixes,
index,
get_message("check_aln_prefix_invalid"),
)
)

if len(errors) > 0:
logger.info("Raising a validation error.")
raise ValidationError(errors)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

logger = logging.getLogger(__name__)

# A version of these regexes also exists in Base.libsonnet
# A version of this regex also exists in Base.libsonnet
AWARD_REFERENCES_REGEX = r"^AWARD-(?!0000)[0-9]{4}$"


Expand Down
2 changes: 2 additions & 0 deletions backend/audit/intakelib/checks/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from .check_no_repeat_findings import no_repeat_findings
from .check_findings_grid_validation import findings_grid_validation
from .check_finding_prior_references_pattern import prior_references_pattern
from .check_aln_prefix_pattern import aln_agency_prefix

logger = logging.getLogger(__name__)

Expand All @@ -75,6 +76,7 @@
no_major_program_no_type,
all_unique_award_numbers,
sequential_award_numbers,
aln_agency_prefix,
aln_three_digit_extension,
additional_award_identification,
federal_program_total_is_correct,
Expand Down
1 change: 1 addition & 0 deletions backend/audit/intakelib/common/error_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"check_aln_three_digit_extension_invalid": "The three digit extension should follow one of these formats: ###, RD#, or U##, where # represents a number",
"check_prior_references_invalid": "Prior references must be <b>N/A</b> or a comma-separated list of values in the format <b>20##-###</b>, for example, <b>2019-001, 2019-002</b>",
"check_award_references_invalid": "Award references must be of the form <b>AWARD-####</b>, for example, <b>AWARD-0001</b>",
"check_aln_prefix_invalid": "The federal agency prefix should be a two-digit value, for example, <b>10</b>",
"check_additional_award_identification_present": "Missing additional award identification",
"check_federal_program_total": "Federal program total is {}, but should be {}",
"check_cluster_total": "This cluster total is {}, but should be {}",
Expand Down
2 changes: 2 additions & 0 deletions backend/audit/intakelib/transforms/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from .xform_uniform_cluster_names import regenerate_uniform_cluster_names
from .xform_reformat_prior_references import reformat_prior_references
from .xform_reformat_award_references import reformat_award_reference
from .xform_reformat_agency_prefix import reformat_federal_agency_prefix

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -105,6 +106,7 @@ def run_all_secondary_auditors_transforms(ir):
convert_number_of_findings_to_integers,
convert_loan_balance_to_integers_or_na,
regenerate_uniform_cluster_names,
reformat_federal_agency_prefix,
generate_cfda_keys,
]

Expand Down
15 changes: 15 additions & 0 deletions backend/audit/intakelib/transforms/xform_reformat_agency_prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import logging
from audit.intakelib.intermediate_representation import (
get_range_by_name,
replace_range_by_name,
)

logger = logging.getLogger(__name__)


# Tested by has-aln-prefix-entered-as-numbers.xlsx
def reformat_federal_agency_prefix(ir):
references = get_range_by_name(ir, "federal_agency_prefix")
new_values = list(map(lambda v: v.split(".")[0] if v else v, references["values"]))
new_ir = replace_range_by_name(ir, "federal_agency_prefix", new_values)
return new_ir
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
logger = logging.getLogger(__name__)


# Tested by has_lowercase_award_reference.py
# Tested by has_lowercase_award_reference.xlsx
def reformat_award_reference(ir):
references = get_range_by_name(ir, "award_reference")
new_values = list(map(lambda v: v.upper() if v else v, references["values"]))
Expand Down
2 changes: 1 addition & 1 deletion backend/schemas/source/base/Base.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ local Meta = {
},
};

local REGEX_ALN_PREFIX = '^([0-9]{2})$';
# A python version of these regexes also exists in settings.py
local REGEX_ALN_PREFIX = '^([0-9]{2})$';
local REGEX_RD_EXTENSION = 'RD[0-9]?';
local REGEX_THREE_DIGIT_EXTENSION = '[0-9]{3}[A-Za-z]{0,1}';
local REGEX_U_EXTENSION = 'U[0-9]{2}';
Expand Down
2 changes: 1 addition & 1 deletion backend/static/js/globals.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const UPLOAD_TIMEOUT = 30000; // 30s
export const UPLOAD_TIMEOUT = 60000; // 60s

export const UPLOAD_URLS = {
'federal-awards': 'federal-awards-expended',
Expand Down

0 comments on commit 1e4c2c4

Please sign in to comment.