Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
98456714
authored
Jul 10, 2014
by
Kálmán Viktor
Committed by
Őry Máté
Jul 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add lease acl update
parent
64c69044
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
2 deletions
+98
-2
circle/dashboard/templates/dashboard/lease-edit.html
+80
-1
circle/dashboard/urls.py
+3
-0
circle/dashboard/views.py
+10
-0
circle/vm/models/common.py
+5
-1
No files found.
circle/dashboard/templates/dashboard/lease-edit.html
View file @
98456714
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
{% block content %}
{% block content %}
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-
12
"
>
<div
class=
"col-md-
7
"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<div
class=
"panel-heading"
>
<a
class=
"pull-right btn btn-default btn-xs"
href=
"{% url "
dashboard
.
views
.
template-list
"
%}"
>
{% trans "Back" %}
</a>
<a
class=
"pull-right btn btn-default btn-xs"
href=
"{% url "
dashboard
.
views
.
template-list
"
%}"
>
{% trans "Back" %}
</a>
...
@@ -20,6 +20,85 @@
...
@@ -20,6 +20,85 @@
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"col-md-5"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<h4
class=
"no-margin"
><i
class=
"icon-group"
></i>
{% trans "Manage access" %}
</h4>
</div>
<div
class=
"panel-body"
>
<form
action=
"{% url "
dashboard
.
views
.
lease-acl
"
pk=
object.pk
%}"
method=
"post"
>
{% csrf_token %}
<table
class=
"table table-striped table-with-form-fields"
id=
"template-access-table"
>
<thead>
<tr>
<th></th>
<th>
{% trans "Who" %}
</th>
<th>
{% trans "What" %}
</th>
<th><i
class=
"icon-remove"
></i></th>
</tr>
</thead>
<tbody>
{% for i in acl.users %}
<tr>
<td>
<i
class=
"icon-user"
></i>
</td>
<td>
<a
href=
"{% url "
dashboard
.
views
.
profile
"
username=
i.user.username
%}"
title=
"{{ i.user.username }}"
>
{% include "dashboard/_display-name.html" with user=i.user show_org=True %}
</a>
</td>
<td>
<select
class=
"form-control"
name=
"perm-u-{{i.user.id}}"
>
{% for id, name in acl.levels %}
<option
{%
if
id =
i.level%}
selected=
"selected"
{%
endif
%}
value=
"{{id}}"
>
{{name}}
</option>
{% endfor %}
</select>
</td>
<td>
<input
type=
"checkbox"
name=
"remove-u-{{i.user.id}}"
title=
"{% trans "
Remove
"
%}"
/>
</td>
</tr>
{% endfor %}
{% for i in acl.groups %}
<tr>
<td><i
class=
"icon-group"
></i></td>
<td>
<a
href=
"{% url "
dashboard
.
views
.
group-detail
"
pk=
i.group.pk
%}"
>
{{i.group}}
</a>
</td>
<td>
<select
class=
"form-control"
name=
"perm-g-{{i.group.id}}"
>
{% for id, name in acl.levels %}
<option
{%
if
id =
i.level%}
selected=
"selected"
{%
endif
%}
value=
"{{id}}"
>
{{name}}
</option>
{% endfor %}
</select>
</td>
<td>
<input
type=
"checkbox"
name=
"remove-g-{{i.group.id}}"
title=
"{% trans "
Remove
"
%}"
/>
</td>
</tr>
{% endfor %}
<tr><td><i
class=
"icon-plus"
></i></td>
<td><input
type=
"text"
class=
"form-control"
name=
"perm-new-name"
placeholder=
"{% trans "
Name
of
group
or
user
"
%}"
></td>
<td><select
class=
"form-control"
name=
"perm-new"
>
{% for id, name in acl.levels %}
<option
value=
"{{id}}"
>
{{name}}
</option>
{% endfor %}
</select></td><td></td>
</tr>
</tbody>
</table>
<div
class=
"form-actions"
>
<button
type=
"submit"
class=
"btn btn-success"
>
{% trans "Save" %}
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% endblock %}
circle/dashboard/urls.py
View file @
98456714
...
@@ -40,6 +40,7 @@ from .views import (
...
@@ -40,6 +40,7 @@ from .views import (
UserKeyDelete
,
UserKeyDetail
,
UserKeyCreate
,
UserKeyDelete
,
UserKeyDetail
,
UserKeyCreate
,
VmTraitsUpdate
,
VmRawDataUpdate
,
VmTraitsUpdate
,
VmRawDataUpdate
,
GroupPermissionsView
,
GroupPermissionsView
,
LeaseAclUpdateView
,
)
)
urlpatterns
=
patterns
(
urlpatterns
=
patterns
(
...
@@ -51,6 +52,8 @@ urlpatterns = patterns(
...
@@ -51,6 +52,8 @@ urlpatterns = patterns(
name
=
"dashboard.views.lease-create"
),
name
=
"dashboard.views.lease-create"
),
url
(
r'^lease/delete/(?P<pk>\d+)/$'
,
LeaseDelete
.
as_view
(),
url
(
r'^lease/delete/(?P<pk>\d+)/$'
,
LeaseDelete
.
as_view
(),
name
=
"dashboard.views.lease-delete"
),
name
=
"dashboard.views.lease-delete"
),
url
(
r'^lease/(?P<pk>\d+)/acl/$'
,
LeaseAclUpdateView
.
as_view
(),
name
=
"dashboard.views.lease-acl"
),
url
(
r'^template/create/$'
,
TemplateCreate
.
as_view
(),
url
(
r'^template/create/$'
,
TemplateCreate
.
as_view
(),
name
=
"dashboard.views.template-create"
),
name
=
"dashboard.views.template-create"
),
...
...
circle/dashboard/views.py
View file @
98456714
...
@@ -2296,6 +2296,10 @@ class LeaseCreate(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -2296,6 +2296,10 @@ class LeaseCreate(LoginRequiredMixin, SuperuserRequiredMixin,
return
reverse_lazy
(
"dashboard.views.template-list"
)
return
reverse_lazy
(
"dashboard.views.template-list"
)
class
LeaseAclUpdateView
(
AclUpdateView
):
model
=
Lease
class
LeaseDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
class
LeaseDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
SuccessMessageMixin
,
UpdateView
):
model
=
Lease
model
=
Lease
...
@@ -2303,6 +2307,12 @@ class LeaseDetail(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -2303,6 +2307,12 @@ class LeaseDetail(LoginRequiredMixin, SuperuserRequiredMixin,
template_name
=
"dashboard/lease-edit.html"
template_name
=
"dashboard/lease-edit.html"
success_message
=
_
(
"Successfully modified lease."
)
success_message
=
_
(
"Successfully modified lease."
)
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
obj
=
self
.
get_object
()
context
=
super
(
LeaseDetail
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
context
[
'acl'
]
=
get_vm_acl_data
(
obj
)
return
context
def
get_success_url
(
self
):
def
get_success_url
(
self
):
return
reverse_lazy
(
"dashboard.views.lease-detail"
,
kwargs
=
self
.
kwargs
)
return
reverse_lazy
(
"dashboard.views.lease-detail"
,
kwargs
=
self
.
kwargs
)
...
...
circle/vm/models/common.py
View file @
98456714
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
from
__future__
import
absolute_import
,
unicode_literals
from
__future__
import
absolute_import
,
unicode_literals
from
datetime
import
timedelta
,
datetime
from
datetime
import
timedelta
,
datetime
from
django.db.models
import
Model
,
CharField
,
IntegerField
from
django.db.models
import
Model
,
CharField
,
IntegerField
,
permalink
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.timesince
import
timeuntil
from
django.utils.timesince
import
timeuntil
...
@@ -151,6 +151,10 @@ class Lease(AclBase):
...
@@ -151,6 +151,10 @@ class Lease(AclBase):
's'
:
self
.
get_readable_suspend_time
(),
's'
:
self
.
get_readable_suspend_time
(),
'r'
:
self
.
get_readable_delete_time
()}
'r'
:
self
.
get_readable_delete_time
()}
@permalink
def
get_absolute_url
(
self
):
return
(
'dashboard.views.lease-detail'
,
None
,
{
'pk'
:
self
.
pk
})
class
Trait
(
Model
):
class
Trait
(
Model
):
name
=
CharField
(
max_length
=
50
,
verbose_name
=
_
(
'name'
))
name
=
CharField
(
max_length
=
50
,
verbose_name
=
_
(
'name'
))
...
...
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