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
Commit
ed33b273
authored
Aug 15, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: remove mass delete
parent
1d1ab1ea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 additions
and
59 deletions
+1
-59
circle/dashboard/tests/test_views.py
+0
-14
circle/dashboard/urls.py
+1
-3
circle/dashboard/views.py
+0
-42
No files found.
circle/dashboard/tests/test_views.py
View file @
ed33b273
...
...
@@ -107,20 +107,6 @@ class VmDetailTest(LoginMixin, TestCase):
response
=
c
.
get
(
'/dashboard/vm/1/'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_unpermitted_vm_mass_delete
(
self
):
c
=
Client
()
self
.
login
(
c
,
'user1'
)
response
=
c
.
post
(
'/dashboard/vm/mass-delete/'
,
{
'vms'
:
[
1
]})
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_permitted_vm_mass_delete
(
self
):
c
=
Client
()
self
.
login
(
c
,
'user2'
)
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
inst
.
set_level
(
self
.
u2
,
'owner'
)
response
=
c
.
post
(
'/dashboard/vm/mass-delete/'
,
{
'vms'
:
[
1
]})
self
.
assertEqual
(
response
.
status_code
,
302
)
def
test_unpermitted_password_change
(
self
):
c
=
Client
()
self
.
login
(
c
,
"user2"
)
...
...
circle/dashboard/urls.py
View file @
ed33b273
...
...
@@ -29,7 +29,7 @@ from .views import (
NotificationView
,
PortDelete
,
TemplateAclUpdateView
,
TemplateCreate
,
TemplateDelete
,
TemplateDetail
,
TemplateList
,
TransferOwnershipConfirmView
,
TransferOwnershipView
,
vm_activity
,
VmCreate
,
VmDetailView
,
VmDetailVncTokenView
,
VmGraphView
,
VmList
,
VmMassDelete
,
VmDetailVncTokenView
,
VmGraphView
,
VmList
,
DiskRemoveView
,
get_disk_download_status
,
InterfaceDeleteView
,
GroupRemoveUserView
,
GroupRemoveFutureUserView
,
...
...
@@ -87,8 +87,6 @@ urlpatterns = patterns(
url
(
r'^vm/list/$'
,
VmList
.
as_view
(),
name
=
'dashboard.views.vm-list'
),
url
(
r'^vm/create/$'
,
VmCreate
.
as_view
(),
name
=
'dashboard.views.vm-create'
),
url
(
r'^vm/mass-delete/'
,
VmMassDelete
.
as_view
(),
name
=
'dashboard.view.mass-delete-vm'
),
url
(
r'^vm/(?P<pk>\d+)/activity/$'
,
vm_activity
),
url
(
r'^vm/activity/(?P<pk>\d+)/$'
,
InstanceActivityDetail
.
as_view
(),
name
=
'dashboard.views.vm-activity'
),
...
...
circle/dashboard/views.py
View file @
ed33b273
...
...
@@ -2468,48 +2468,6 @@ class PortDelete(LoginRequiredMixin, DeleteView):
kwargs
=
{
'pk'
:
self
.
kwargs
.
get
(
"pk"
)})
class
VmMassDelete
(
LoginRequiredMixin
,
View
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
vms
=
request
.
GET
.
getlist
(
'v[]'
)
objects
=
Instance
.
objects
.
filter
(
pk__in
=
vms
)
return
render
(
request
,
"dashboard/confirm/mass-delete.html"
,
{
'objects'
:
objects
})
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
vms
=
request
.
POST
.
getlist
(
'vms'
)
names
=
[]
if
vms
is
not
None
:
for
i
in
Instance
.
objects
.
filter
(
pk__in
=
vms
):
if
not
i
.
has_level
(
request
.
user
,
'owner'
):
logger
.
info
(
'Tried to delete instance #
%
d without owner '
'permission by
%
s.'
,
i
.
pk
,
unicode
(
request
.
user
))
# no need for rollback or proper error message, this can't
# normally happen:
raise
PermissionDenied
()
try
:
i
.
destroy
.
async
(
user
=
request
.
user
)
names
.
append
(
i
.
name
)
except
Exception
as
e
:
logger
.
error
(
e
)
success_message
=
ungettext_lazy
(
"Mass delete complete, the following VM was deleted:
%
s."
,
"Mass delete complete, the following VMs were deleted:
%
s."
,
len
(
names
))
%
u', '
.
join
(
names
)
# we can get this only via AJAX ...
if
request
.
is_ajax
():
return
HttpResponse
(
json
.
dumps
({
'message'
:
success_message
}),
content_type
=
"application/json"
)
else
:
messages
.
success
(
request
,
success_message
)
next
=
request
.
GET
.
get
(
'next'
)
return
redirect
(
next
if
next
else
reverse_lazy
(
'dashboard.index'
))
class
LeaseCreate
(
LoginRequiredMixin
,
PermissionRequiredMixin
,
SuccessMessageMixin
,
CreateView
):
model
=
Lease
...
...
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