Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
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 @@
...
@@ -13,7 +13,9 @@
<br
/>
<br
/>
<div
class=
"pull-right"
style=
"margin-top: 15px;"
>
<div
class=
"pull-right"
style=
"margin-top: 15px;"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
{% trans "Cancel" %}
</button>
<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>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
</div>
</div>
...
...
circle/dashboard/templates/dashboard/confirm/base-delete.html
View file @
3191e377
...
@@ -26,7 +26,9 @@
...
@@ -26,7 +26,9 @@
{% csrf_token %}
{% csrf_token %}
<a
class=
"btn btn-default"
>
{% trans "Cancel" %}
</a>
<a
class=
"btn btn-default"
>
{% trans "Cancel" %}
</a>
<input
type=
"hidden"
name=
"next"
value=
"{{ request.GET.next }}"
/>
<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>
</form>
</div>
</div>
</div>
</div>
...
...
circle/dashboard/views.py
View file @
3191e377
...
@@ -1761,9 +1761,26 @@ class LeaseDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
...
@@ -1761,9 +1761,26 @@ class LeaseDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
else
:
else
:
return
[
'dashboard/confirm/base-delete.html'
]
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
):
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
object
=
self
.
get_object
()
object
=
self
.
get_object
()
if
(
object
.
instancetemplate_set
.
count
()
>
0
):
raise
SuspiciousOperation
()
object
.
delete
()
object
.
delete
()
success_url
=
self
.
get_success_url
()
success_url
=
self
.
get_success_url
()
success_message
=
_
(
"Lease successfully deleted!"
)
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