Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
c485b7d3
authored
Aug 27, 2013
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: confirmation for domain delete
parent
089ff40c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
1 deletions
+46
-1
network/views.py
+46
-1
No files found.
network/views.py
View file @
c485b7d3
...
...
@@ -17,6 +17,7 @@ from .forms import (HostForm, VlanForm, DomainForm, GroupForm, RecordForm,
from
django.contrib
import
messages
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.db.models
import
Q
from
itertools
import
chain
import
json
...
...
@@ -148,6 +149,50 @@ class DomainDelete(DeleteView):
else
:
return
reverse_lazy
(
'network.domain_list'
)
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
object
=
self
.
get_object
()
if
unicode
(
self
.
object
)
!=
request
.
POST
.
get
(
'confirm'
):
messages
.
error
(
request
,
_
(
"Object name does not match!"
))
return
self
.
get
(
request
,
*
args
,
**
kwargs
)
response
=
super
(
DomainDelete
,
self
)
.
delete
(
request
,
*
args
,
**
kwargs
)
messages
.
success
(
request
,
_
(
"Domain successfully deleted!"
))
return
response
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
DomainDelete
,
self
)
.
get_context_data
(
**
kwargs
)
deps
=
[]
# vlans
vlans
=
Vlan
.
objects
.
filter
(
domain
=
self
.
object
)
.
all
()
if
len
(
vlans
)
>
0
:
deps
.
append
({
'name'
:
'Vlans'
,
'data'
:
vlans
})
# hosts
hosts
=
Host
.
objects
.
filter
(
vlan__in
=
deps
[
0
][
'data'
])
if
len
(
hosts
)
>
0
:
deps
.
append
({
'name'
:
'Hosts'
,
'data'
:
hosts
})
# records
records
=
Record
.
objects
.
filter
(
Q
(
domain
=
self
.
object
)
|
Q
(
host__in
=
deps
[
1
][
'data'
])
)
if
len
(
records
)
>
0
:
deps
.
append
({
'name'
:
'Records'
,
'data'
:
records
})
context
[
'deps'
]
=
deps
context
[
'confirmation'
]
=
True
return
context
class
GroupList
(
SingleTableView
):
model
=
Group
...
...
@@ -461,7 +506,7 @@ class VlanDelete(DeleteView):
deps
=
[]
# hosts
hosts
=
Host
.
objects
.
filter
(
vlan
=
self
.
get_
object
)
.
all
()
hosts
=
Host
.
objects
.
filter
(
vlan
=
self
.
object
)
.
all
()
if
len
(
hosts
)
>
0
:
deps
.
append
({
'name'
:
'Hosts'
,
...
...
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