diff --git a/src/registrar/models/domain_application.py b/src/registrar/models/domain_application.py index 4da32ad18..a4752aa88 100644 --- a/src/registrar/models/domain_application.py +++ b/src/registrar/models/domain_application.py @@ -107,9 +107,9 @@ class DomainApplication(TimeStampedModel): class OrganizationChoices(models.TextChoices): """ - Primary organization choices: - For use in django admin - Keys need to match OrganizationChoicesVerbose + Primary organization choices: + For use in django admin + Keys need to match OrganizationChoicesVerbose """ FEDERAL = "federal", "Federal" @@ -124,9 +124,9 @@ class DomainApplication(TimeStampedModel): class OrganizationChoicesVerbose(models.TextChoices): """ - Secondary organization choices - For use in the application form and on the templates - Keys need to match OrganizationChoices + Secondary organization choices + For use in the application form and on the templates + Keys need to match OrganizationChoices """ FEDERAL = ( diff --git a/src/registrar/templatetags/custom_filters.py b/src/registrar/templatetags/custom_filters.py index e90c3166d..158b7269e 100644 --- a/src/registrar/templatetags/custom_filters.py +++ b/src/registrar/templatetags/custom_filters.py @@ -1,8 +1,10 @@ +import logging from django import template import re from registrar.models.domain_application import DomainApplication register = template.Library() +logger = logging.getLogger(__name__) @register.filter(name="extract_value") @@ -53,13 +55,14 @@ def contains_checkbox(html_list): @register.filter def get_organization_long_name(organization_type): - organization_choices_dict = {} - - for name, value in DomainApplication.OrganizationChoicesVerbose.choices: - organization_choices_dict[name] = value + # https://gist.github.com/OmenApps/3eef60ba4204f3d1842d9d7477efcce1#file-django_choices-txt-L28 + organization_choices_dict = dict( + DomainApplication.OrganizationChoicesVerbose.choices + ) long_form_type = organization_choices_dict[organization_type] - if long_form_type is not None: - return long_form_type + if long_form_type is None: + logger.error("Organization type error, triggered by a template's custom filter") + return "Error" - return "Error" + return long_form_type