Skip to content

Commit

Permalink
change where case type name validation is done
Browse files Browse the repository at this point in the history
  • Loading branch information
zandre-eng committed Jan 3, 2024
1 parent 8aac252 commit 25f1609
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 8 additions & 0 deletions corehq/apps/data_dictionary/bulk.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
save_case_property,
get_column_headings,
map_row_values_to_column_names,
is_case_type_or_prop_name_valid,
)

FHIR_RESOURCE_TYPE_MAPPING_SHEET = "fhir_mapping"
Expand Down Expand Up @@ -137,7 +138,14 @@ def _process_sheets(domain, workbook, allowed_value_info):
domain, worksheet)
errors.extend(_errors)
continue

case_type = worksheet.title
if not is_case_type_or_prop_name_valid(case_type):
errors.append(
_('Invalid sheet name "{}". It should start with a letter, and only contain '
'letters, numbers, "-", and "_"').format(case_type)
)
continue

column_headings = []
for (i, row) in enumerate(itertools.islice(worksheet.iter_rows(), 0, None), start=1):
Expand Down
3 changes: 0 additions & 3 deletions corehq/apps/data_dictionary/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@ def save_case_property(name, case_type, domain=None, data_type=None,
if not is_case_type_or_prop_name_valid(name):
return gettext('Invalid case property name. It should start with a letter, and only contain letters, '
'numbers, "-", and "_"')
if not is_case_type_or_prop_name_valid(case_type):
return gettext('Invalid case type name. It should start with a letter, and only contain letters, '
'numbers, "-", and "_"')

try:
prop = CaseProperty.get_or_create(
Expand Down

0 comments on commit 25f1609

Please sign in to comment.