Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3191e377
authored
Apr 30, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: don't allow lease deletion when there are template still using it
parent
1bf4c14c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
2 deletions
+23
-2
circle/dashboard/templates/dashboard/confirm/ajax-delete.html
+3
-1
circle/dashboard/templates/dashboard/confirm/base-delete.html
+3
-1
circle/dashboard/views.py
+17
-0
No files found.
circle/dashboard/templates/dashboard/confirm/ajax-delete.html
View file @
3191e377
...
...
@@ -13,7 +13,9 @@
<br
/>
<div
class=
"pull-right"
style=
"margin-top: 15px;"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
{% trans "Cancel" %}
</button>
<button
id=
"confirmation-modal-button"
type=
"button"
class=
"btn btn-danger"
>
{% trans "Delete" %}
</button>
<button
disabled
id=
"confirmation-modal-button"
type=
"button"
class=
"btn btn-danger"
{%
if
disable_submit
%}
disabled
{%
endif
%}
>
{% trans "Delete" %}
</button>
</div>
<div
class=
"clearfix"
></div>
</div>
...
...
circle/dashboard/templates/dashboard/confirm/base-delete.html
View file @
3191e377
...
...
@@ -26,7 +26,9 @@
{% csrf_token %}
<a
class=
"btn btn-default"
>
{% trans "Cancel" %}
</a>
<input
type=
"hidden"
name=
"next"
value=
"{{ request.GET.next }}"
/>
<button
class=
"btn btn-danger"
>
{% trans "Yes" %}
</button>
<button
class=
"btn btn-danger"
{%
if
disable_submit
%}
disabled
{%
endif
%}
>
{% trans "Yes" %}
</button>
</form>
</div>
</div>
...
...
circle/dashboard/views.py
View file @
3191e377
...
...
@@ -1761,9 +1761,26 @@ class LeaseDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
else
:
return
[
'dashboard/confirm/base-delete.html'
]
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
c
=
super
(
LeaseDelete
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
lease
=
self
.
get_object
()
templates
=
lease
.
instancetemplate_set
if
templates
.
count
()
>
0
:
text
=
_
(
"You can't delete this lease because some templates "
"are still using it, modify these to proceed: "
)
c
[
'text'
]
=
text
+
", "
.
join
(
"<strong>
%
s (#
%
d)</strong>"
""
%
(
o
.
name
,
o
.
pk
)
for
o
in
templates
.
all
())
c
[
'disable_submit'
]
=
True
return
c
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
object
=
self
.
get_object
()
if
(
object
.
instancetemplate_set
.
count
()
>
0
):
raise
SuspiciousOperation
()
object
.
delete
()
success_url
=
self
.
get_success_url
()
success_message
=
_
(
"Lease successfully deleted!"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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