Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
allgo
allgo
Commits
ae99af36
Commit
ae99af36
authored
Dec 04, 2018
by
BAIRE Anthony
Browse files
expand the 'advanced' tab in case of server-side validation error
parent
d630d502
Pipeline
#53083
failed with stage
in 1 minute and 22 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
django/allgo/main/forms.py
View file @
ae99af36
...
...
@@ -142,6 +142,8 @@ class WebappForm(forms.ModelForm):
widget
=
forms
.
RadioSelect
)
# Advanced
ADVANCED_FIELDS
=
(
"docker_os"
,
"memory_limit_mb"
,
"job_queue"
,
"entrypoint"
,
"owner"
,
"tags"
)
docker_os
=
forms
.
ModelChoiceField
(
queryset
=
DockerOs
.
objects
.
all
().
distinct
(),
label
=
'Operating sytem'
,
...
...
django/allgo/main/views.py
View file @
ae99af36
...
...
@@ -227,6 +227,11 @@ class WebappUpdate(SuccessMessageMixin, LoginRequiredMixin, UpdateView):
def
get_context_data
(
self
,
**
kwargs
):
ctx
=
super
().
get_context_data
(
**
kwargs
)
ctx
[
"action"
]
=
"Update"
# we expand the 'advanced' tab if any of its field has a validation error
ctx
[
"show_advanced"
]
=
bool
(
set
(
ctx
[
"form"
].
errors
)
.
intersection
(
ctx
[
"form"
].
ADVANCED_FIELDS
))
return
ctx
def
get_form
(
self
):
...
...
@@ -287,6 +292,7 @@ class WebappCreate(SuccessMessageMixin, LoginRequiredMixin, IsProviderMixin, Cre
def
get_context_data
(
self
,
**
kwargs
):
ctx
=
super
().
get_context_data
(
**
kwargs
)
ctx
[
"action"
]
=
"Create"
ctx
[
"show_advanced"
]
=
False
return
ctx
def
form_valid
(
self
,
form
):
...
...
django/allgo/templates/webapp_add_update.html
View file @
ae99af36
...
...
@@ -66,12 +66,12 @@
<div
class=
"card"
>
<div
class=
"card-header"
>
<h5
class=
"mb-0"
>
<button
class=
"btn btn-link"
type=
"button"
data-toggle=
"collapse"
data-target=
"#collapseAdvanced"
aria-expanded=
"
false
"
aria-controls=
"collapseAdvanced"
>
<button
class=
"btn btn-link"
type=
"button"
data-toggle=
"collapse"
data-target=
"#collapseAdvanced"
aria-expanded=
"
{{show_advanced}}
"
aria-controls=
"collapseAdvanced"
>
Advanced options
</button>
</h5>
</div>
<div
class=
"collapse"
id=
"collapseAdvanced"
>
<div
class=
"collapse
{% if show_advanced %}show{% endif %}
"
id=
"collapseAdvanced"
>
<div
class=
"card-body"
>
<div
class=
"form-row"
>
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment