mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-01 10:13:55 +02:00
refactor org literal mapping to dict, tweak error handing, lint
This commit is contained in:
parent
5e787eeed3
commit
372ead1121
2 changed files with 16 additions and 13 deletions
|
@ -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 long_form_type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue