Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ots
hypha
Commits
7290cbef
Commit
7290cbef
authored
7 years ago
by
Todd Dembrey
Browse files
Options
Downloads
Patches
Plain Diff
make sure the error message returns human friendly text
parent
2e148fc2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
opentech/apply/funds/blocks.py
+10
-2
10 additions, 2 deletions
opentech/apply/funds/blocks.py
with
10 additions
and
2 deletions
opentech/apply/funds/blocks.py
+
10
−
2
View file @
7290cbef
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment