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
8675b32a
Commit
8675b32a
authored
Dec 04, 2018
by
BAIRE Anthony
Browse files
some factorisation
parent
db9c8fcc
Changes
2
Hide whitespace changes
Inline
Side-by-side
django/allgo/main/views.py
View file @
8675b32a
...
...
@@ -224,6 +224,11 @@ class WebappUpdate(SuccessMessageMixin, LoginRequiredMixin, UpdateView):
queryset
=
get_object_or_404
(
Webapp
,
docker_name
=
data
,
user_id
=
self
.
request
.
user
.
id
)
return
queryset
def
get_context_data
(
self
,
**
kwargs
):
ctx
=
super
().
get_context_data
(
**
kwargs
)
ctx
[
"action"
]
=
"Update"
return
ctx
def
get_form
(
self
):
form
=
super
().
get_form
()
if
not
self
.
request
.
user
.
is_superuser
:
...
...
@@ -279,6 +284,11 @@ class WebappCreate(SuccessMessageMixin, LoginRequiredMixin, IsProviderMixin, Cre
form
.
fields
[
'memory_limit_mb'
].
widget
.
attrs
[
'readonly'
]
=
True
return
form
def
get_context_data
(
self
,
**
kwargs
):
ctx
=
super
().
get_context_data
(
**
kwargs
)
ctx
[
"action"
]
=
"Create"
return
ctx
def
form_valid
(
self
,
form
):
"""Save data coming from the form in the database """
obj
=
form
.
save
(
commit
=
False
)
...
...
django/allgo/templates/webapp_add_update.html
View file @
8675b32a
...
...
@@ -2,22 +2,12 @@
{% load htmlattrs converters %}
{% block title %}
{% url 'main:webapp_creation' as webapp_url %}
{% if request.get_full_path == webapp_url %}
Create a webapp
{% else %}
Update webapp
{% endif %}
{{action}} a webapp
{% endblock %}
{% block breadcrumb %}
<li
class=
"breadcrumb-item"
><a
href=
"{% url 'main:webapp_list' %}"
>
Applications
</a></li>
{% url 'main:webapp_creation' as webapp_url %}
{% if request.get_full_path == webapp_url %}
<li
class=
"breadcrumb-item active"
aria-current=
"page"
>
Create
</li>
{% else %}
<li
class=
"breadcrumb-item active"
aria-current=
"page"
>
Update
</li>
{% endif %}
<li
class=
"breadcrumb-item active"
aria-current=
"page"
>
{{action}}
</li>
{% endblock %}
{% block content %}
...
...
@@ -132,8 +122,7 @@
</div>
<small
class=
"form-text text-muted"
>
{{ form.entrypoint.help_text }}
</small>
{% url 'main:webapp_creation' as webapp_url %}
{% if request.get_full_path != webapp_url %}
{% if action != "Create" %}
<div
class=
"form-group"
>
{{ form.owner.label_tag }}
{{ form.owner | attr:"placeholder:Enter the new owner username" | add_class:"form-control" }}
...
...
@@ -147,12 +136,7 @@
</div>
</div>
{% url 'main:webapp_creation' as webapp_url %}
{% if request.get_full_path == webapp_url %}
<input
class=
"btn btn-primary float-right mt-4"
type=
"submit"
value=
"Create webapp"
>
{% else %}
<input
class=
"btn btn-primary float-right mt-4"
type=
"submit"
value=
"Update webapp"
>
{% endif %}
<input
class=
"btn btn-primary float-right mt-4"
type=
"submit"
value=
"{{action}} webapp"
>
</form>
</div>
...
...
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