Skip to content
Snippets Groups Projects
Commit 7290cbef authored by Todd Dembrey's avatar Todd Dembrey
Browse files

make sure the error message returns human friendly text

parent 2e148fc2
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,14 @@ def find_duplicates(items): ...@@ -22,6 +22,14 @@ def find_duplicates(items):
return duplicates return duplicates
def prettify_names(sequence):
return [nice_field_name(item) for item in sequence]
def nice_field_name(name):
return name.title().replace('_', ' ')
class RichTextFieldBlock(TextFieldBlock): class RichTextFieldBlock(TextFieldBlock):
widget = TinyMCE(mce_attrs={ widget = TinyMCE(mce_attrs={
'elementpath': False, 'elementpath': False,
...@@ -60,12 +68,12 @@ class CustomFormFieldsBlock(FormFieldsBlock): ...@@ -60,12 +68,12 @@ class CustomFormFieldsBlock(FormFieldsBlock):
all_errors = list() all_errors = list()
if missing: if missing:
all_errors.append( all_errors.append(
'You are missing the following required fields: {}'.format(', '.join(missing).title()) 'You are missing the following required fields: {}'.format(', '.join(prettify_names(missing)))
) )
if duplicates: if duplicates:
all_errors.append( all_errors.append(
'You have duplicates of the following required fields: {}'.format(', '.join(duplicates).title()) 'You have duplicates of the following required fields: {}'.format(', '.join(prettify_names(duplicates)))
) )
for i, block_name in enumerate(block_types): for i, block_name in enumerate(block_types):
if block_name in duplicates: if block_name in duplicates:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment