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
04305fa9
authored
Sep 09, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: improve transfer ownership view
parent
ab87f4fc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
25 deletions
+51
-25
circle/dashboard/forms.py
+8
-0
circle/dashboard/templates/dashboard/_modal.html
+6
-0
circle/dashboard/templates/dashboard/vm-detail/access.html
+3
-1
circle/dashboard/templates/dashboard/vm-detail/tx-owner.html
+13
-22
circle/dashboard/views.py
+21
-2
No files found.
circle/dashboard/forms.py
View file @
04305fa9
...
...
@@ -1062,6 +1062,14 @@ class AclUserOrGroupAddForm(forms.Form):
attrs
=
{
'class'
:
'form-control'
}))
class
TransferOwnershipForm
(
forms
.
Form
):
name
=
forms
.
CharField
(
widget
=
autocomplete_light
.
TextWidget
(
'AclUserAutocomplete'
,
autocomplete_js_attributes
=
{
"placeholder"
:
_
(
"Name of user"
)},
attrs
=
{
'class'
:
'form-control'
}),
label
=
_
(
"E-mail address or identifier of user"
))
class
AddGroupMemberForm
(
forms
.
Form
):
new_member
=
forms
.
CharField
(
...
...
circle/dashboard/templates/dashboard/_modal.html
View file @
04305fa9
...
...
@@ -2,6 +2,12 @@
<div
class=
"modal fade"
id=
"confirmation-modal"
tabindex=
"-1"
role=
"dialog"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
{% if box_title and ajax_title %}
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h4
class=
"modal-title"
>
{{ box_title }}
</h4>
</div>
{% endif %}
<div
class=
"modal-body"
>
{% if template %}
{% include template %}
...
...
circle/dashboard/templates/dashboard/vm-detail/access.html
View file @
04305fa9
...
...
@@ -9,8 +9,10 @@
{% endblocktrans %}
{% endif %}
{% if user == instance.owner or user.is_superuser %}
<span
class=
"operation-wrapper"
>
<a
href=
"{% url "
dashboard
.
views
.
vm-transfer-ownership
"
instance
.
pk
%}"
class=
"btn btn-link"
>
{% trans "Transfer ownership..." %}
</a>
class=
"btn btn-link operation"
>
{% trans "Transfer ownership..." %}
</a>
</span>
{% endif %}
</p>
<h3>
{% trans "Permissions"|capfirst %}
</h3>
...
...
circle/dashboard/templates/dashboard/vm-detail/tx-owner.html
View file @
04305fa9
{% 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"
>
{% trans "Transfer ownership" %}
</h3>
</div>
<div
class=
"panel-body"
>
<div
class=
"pull-right"
>
<form
action=
""
method=
"POST"
>
{% csrf_token %}
<label>
{% trans "E-mail address or identifier of user" %}:
<input
name=
"name"
>
</label>
<input
type=
"submit"
>
</form>
<div
class=
"pull-right"
>
<form
action=
"{% url "
dashboard
.
views
.
vm-transfer-ownership
"
pk=
instance.pk
%}"
method=
"POST"
style=
"max-width: 400px;"
>
{% csrf_token %}
<label>
{{ form.name.label }}
</label>
<div
class=
"input-group"
>
{{form.name}}
<div
class=
"input-group-btn"
>
<input
type=
"submit"
value=
"{% trans "
Save
"
%}"
class=
"btn btn-primary"
>
</div>
</div>
</div
>
{% endblock %}
</div>
</form
>
</div>
circle/dashboard/views.py
View file @
04305fa9
...
...
@@ -2766,11 +2766,30 @@ class FavouriteView(TemplateView):
return
HttpResponse
(
"Added."
)
class
TransferOwnershipView
(
LoginRequiredMixin
,
DetailView
):
class
TransferOwnershipView
(
CheckedDetailView
,
DetailView
):
model
=
Instance
template_name
=
'dashboard/vm-detail/tx-owner.html'
def
get_template_names
(
self
):
if
self
.
request
.
is_ajax
():
return
[
'dashboard/_modal.html'
]
else
:
return
[
'dashboard/nojs-wrapper.html'
]
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
context
=
super
(
TransferOwnershipView
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
context
[
'form'
]
=
TransferOwnershipForm
()
context
.
update
({
'box_title'
:
_
(
"Transfer ownership"
),
'ajax_title'
:
True
,
'template'
:
"dashboard/vm-detail/tx-owner.html"
,
})
return
context
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
form
=
TransferOwnershipForm
(
request
.
POST
)
if
not
form
.
is_valid
():
return
self
.
get
(
request
)
try
:
new_owner
=
search_user
(
request
.
POST
[
'name'
])
except
User
.
DoesNotExist
:
...
...
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