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
Commit
60fa88a0
authored
Dec 02, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add vm ownership-transfer
parent
95d5bccd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
1 deletions
+49
-1
circle/dashboard/templates/dashboard/vm-detail-tx-owner.html
+22
-0
circle/dashboard/urls.py
+3
-1
circle/dashboard/views.py
+24
-0
No files found.
circle/dashboard/templates/dashboard/vm-detail-tx-owner.html
0 → 100644
View file @
60fa88a0
{% extends "dashboard/base.html" %}
{% load i18n %}
{% block content %}
<div
class=
"body-content"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<h3
class=
"no-margin"
>
Transfer ownership
</h3>
</div>
<div
class=
"panel-body"
>
<div
class=
"pull-right"
>
<form
action=
""
method=
"POST"
>
{% csrf_token %}
<input
name=
"name"
>
<input
type=
"submit"
>
</form>
</div>
</div>
</div>
{% endblock %}
circle/dashboard/urls.py
View file @
60fa88a0
...
@@ -4,7 +4,7 @@ from vm.models import Instance
...
@@ -4,7 +4,7 @@ from vm.models import Instance
from
.views
import
(
from
.views
import
(
IndexView
,
VmDetailView
,
VmList
,
VmCreate
,
TemplateDetail
,
AclUpdateView
,
IndexView
,
VmDetailView
,
VmList
,
VmCreate
,
TemplateDetail
,
AclUpdateView
,
VmDelete
,
VmMassDelete
,
vm_activity
,
NodeList
,
NodeDetailView
,
VmDelete
,
VmMassDelete
,
vm_activity
,
NodeList
,
NodeDetailView
,
TransferOwnershipConfirmView
TransferOwnership
View
,
TransferOwnership
ConfirmView
)
)
urlpatterns
=
patterns
(
urlpatterns
=
patterns
(
...
@@ -16,6 +16,8 @@ urlpatterns = patterns(
...
@@ -16,6 +16,8 @@ urlpatterns = patterns(
name
=
'dashboard.views.detail'
),
name
=
'dashboard.views.detail'
),
url
(
r'^vm/(?P<pk>\d+)/acl/$'
,
AclUpdateView
.
as_view
(
model
=
Instance
),
url
(
r'^vm/(?P<pk>\d+)/acl/$'
,
AclUpdateView
.
as_view
(
model
=
Instance
),
name
=
'dashboard.views.vm-acl'
),
name
=
'dashboard.views.vm-acl'
),
url
(
r'^vm/(?P<pk>\d+)/tx/$'
,
TransferOwnershipView
.
as_view
(),
name
=
'dashboard.views.vm-transfer-ownership'
),
url
(
r'^vm/list/$'
,
VmList
.
as_view
(),
name
=
'dashboard.views.vm-list'
),
url
(
r'^vm/list/$'
,
VmList
.
as_view
(),
name
=
'dashboard.views.vm-list'
),
url
(
r'^vm/create/$'
,
VmCreate
.
as_view
(),
url
(
r'^vm/create/$'
,
VmCreate
.
as_view
(),
name
=
'dashboard.views.vm-create'
),
name
=
'dashboard.views.vm-create'
),
...
...
circle/dashboard/views.py
View file @
60fa88a0
...
@@ -499,6 +499,30 @@ def vm_activity(request, pk):
...
@@ -499,6 +499,30 @@ def vm_activity(request, pk):
)
)
class
TransferOwnershipView
(
LoginRequiredMixin
,
DetailView
):
model
=
Instance
template_name
=
'dashboard/vm-detail-tx-owner.html'
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
try
:
new_owner
=
User
.
objects
.
get
(
username
=
request
.
POST
[
'name'
])
except
User
.
DoesNotExist
:
raise
Http404
()
except
KeyError
:
raise
SuspiciousOperation
()
obj
=
self
.
get_object
()
if
not
(
obj
.
owner
==
request
.
user
or
request
.
user
.
is_superuser
):
raise
PermissionDenied
()
token
=
signing
.
dumps
((
obj
.
pk
,
new_owner
.
pk
),
salt
=
TransferOwnershipConfirmView
.
get_salt
())
return
HttpResponse
(
"
%
s?key=
%
s"
%
(
reverse
(
'dashboard.views.vm-transfer-ownership-confirm'
),
token
),
content_type
=
"text/plain"
)
class
TransferOwnershipConfirmView
(
LoginRequiredMixin
,
View
):
class
TransferOwnershipConfirmView
(
LoginRequiredMixin
,
View
):
max_age
=
3
*
24
*
3600
max_age
=
3
*
24
*
3600
success_message
=
_
(
"Ownership successfully transferred."
)
success_message
=
_
(
"Ownership successfully transferred."
)
...
...
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