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
3472c1bf
Commit
3472c1bf
authored
3 years ago
by
sandeepsajan0
Committed by
Fredrik Jonsson
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update error msgs for required fields like field label, choices, etc
parent
3f633e0b
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
hypha/apply/utils/blocks.py
+19
-1
19 additions, 1 deletion
hypha/apply/utils/blocks.py
with
19 additions
and
1 deletion
hypha/apply/utils/blocks.py
+
19
−
1
View file @
3472c1bf
...
...
@@ -7,7 +7,12 @@ from django.utils.safestring import mark_safe
from
django.utils.translation
import
gettext_lazy
as
_
from
pagedown.widgets
import
PagedownWidget
from
wagtail.admin
import
messages
from
wagtail.core.blocks
import
StaticBlock
,
StreamBlock
,
StreamValue
from
wagtail.core.blocks
import
(
ListBlock
,
StaticBlock
,
StreamBlock
,
StreamValue
,
)
from
hypha.apply.stream_forms.blocks
import
(
FormFieldBlock
,
...
...
@@ -117,6 +122,19 @@ class CustomFormFieldsBlock(StreamBlock):
if
block_name
in
duplicates
:
self
.
add_error_to_child
(
error_dict
,
i
,
'
info
'
,
'
Duplicate field
'
)
for
block
in
value
:
for
child_block_name
,
child_block
in
block
.
block
.
child_blocks
.
items
():
if
child_block
.
required
and
not
block
.
value
[
child_block_name
]:
all_errors
.
append
(
'
{} cannot be empty for {}
'
.
format
(
child_block_name
.
capitalize
(),
block
.
block
.
label
)
)
if
isinstance
(
child_block
,
ListBlock
)
and
child_block
.
child_block
.
required
:
for
child_value
in
block
.
value
[
child_block_name
]:
if
not
child_value
:
all_errors
.
append
(
'
{} cannot be empty for {}
'
.
format
(
child_block_name
.
capitalize
(),
block
.
block
.
label
)
)
if
all_errors
or
error_dict
:
error_dict
[
'
__all__
'
]
=
all_errors
raise
ValidationError
(
all_errors
,
params
=
error_dict
)
...
...
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