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
c2037190
authored
Jul 23, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add acl template
parent
a25f2d4a
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
86 additions
and
273 deletions
+86
-273
circle/dashboard/templates/dashboard/_manage_access.html
+75
-0
circle/dashboard/templates/dashboard/group-detail.html
+1
-70
circle/dashboard/templates/dashboard/template-edit.html
+1
-74
circle/dashboard/templates/dashboard/vm-detail/access.html
+1
-61
circle/dashboard/views.py
+2
-0
circle/network/templates/network/vlan-edit.html
+1
-55
circle/network/urls.py
+1
-1
circle/network/views.py
+4
-12
No files found.
circle/dashboard/templates/dashboard/_manage_access.html
0 → 100644
View file @
c2037190
{% load i18n %}
<form
action=
"{{ acl.url }}"
method=
"post"
>
{% csrf_token %}
<table
class=
"table table-striped table-with-form-fields"
id=
"{{table_id}}"
>
<thead>
<tr>
<th></th>
<th>
{% trans "Who" %}
</th>
<th>
{% trans "What" %}
</th>
<th><i
class=
"fa fa-times"
></i></th>
</tr>
</thead>
<tbody>
{% for i in acl.users %}
<tr>
<td>
<i
class=
"fa fa-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}}"
{%
if
i
.
level
not
in
acl
.
allowed_levels
%}
disabled
{%
endif
%}
>
{% for id, name in acl.levels %}
<option
{%
if
id =
i.level%}
selected=
"selected"
{%
endif
%}
{%
if
id
not
in
acl
.
allowed_levels
%}
disabled
{%
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=
"fa fa-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}}{% if i.level not in acl.allowed_levels %} disabled{% endif %}"
>
{% for id, name in acl.levels %}
<option
{%
if
id =
i.level%}
selected=
"selected"
{%
endif
%}
{%
if
id
not
in
acl
.
allowed_levels
%}
disabled
{%
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=
"fa fa-plus"
></i></td>
<td>
{{aclform.name }}
</td>
<td><select
class=
"form-control"
name=
"level"
>
{% for id, name in acl.levels %}
{% if id in acl.allowed_levels %}
<option
value=
"{{id}}"
>
{{name}}
</option>
{% endif %}
{% endfor %}
</select></td><td></td>
</tr>
</tbody>
</table>
<div
class=
"form-actions"
>
<button
type=
"submit"
class=
"btn btn-success"
>
{% trans "Save" %}
</button>
</div>
</form>
circle/dashboard/templates/dashboard/group-detail.html
View file @
c2037190
...
@@ -104,76 +104,7 @@
...
@@ -104,76 +104,7 @@
<hr
/>
<hr
/>
<h3
id=
"group-detail-perm-header"
>
{% trans "Access permissions"|capfirst %}
</h3>
<h3
id=
"group-detail-perm-header"
>
{% trans "Access permissions"|capfirst %}
</h3>
<form
action=
"{{acl.url}}"
method=
"post"
>
{% csrf_token %}
{% include "dashboard/_manage_access.html" with table_id="group-detail-perm-table" %}
<table
class=
"table table-striped table-with-form-fields table-bordered"
id=
"group-detail-perm-table"
>
<thead>
<tr>
<th></th><th>
{% trans "Who" %}
</th><th>
{% trans "What" %}
</th><th>
{% trans "Remove" %}
</th>
</tr>
</thead>
<tbody>
{% for i in acl.users %}
<tr>
<td>
<i
class=
"fa fa-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
class=
"user-remove"
><a
data-group_pk=
"{{ group.pk }}"
data-member_pk=
"{{i.user.pk }}"
href=
"{% url "
dashboard
.
views
.
remove-acluser
"
member_pk=
i.user.pk
group_pk=
group.pk
%}"
class=
"real-link delete-from-group btn btn-link btn-xs"
><i
class=
"fa fa-times"
><span
class=
"sr-only"
>
{% trans "remove" %}
</span></i></a></td>
</tr>
{% endfor %}
{% for i in acl.groups %}
<tr>
<td>
<i
class=
"fa fa-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.pk }}"
>
{% for id, name in acl.levels %}
<option
{%
if
id =
i.level%}
selected=
"selected"
{%
endif
%}
value=
"{{id}}"
>
{{name}}
</option>
{% endfor %}
</select>
</td>
<td
class=
"user-remove"
><a
data-group_pk=
"{{ i.pk }}"
data-member_pk=
"{{i.group.pk }}"
href=
"{% url "
dashboard
.
views
.
remove-aclgroup
"
member_pk=
i.group.pk
group_pk=
group.pk
%}"
class=
"real-link delete-from-group btn btn-link btn-xs"
><i
class=
"fa fa-times"
><span
class=
"sr-only"
>
{% trans "remove" %}
</span></i></a>
</td>
</tr>
{% endfor %}
<tr>
<td><i
class=
"fa fa-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>
{% if user.is_superuser %}
{% if user.is_superuser %}
<hr
/>
<hr
/>
...
...
circle/dashboard/templates/dashboard/template-edit.html
View file @
c2037190
...
@@ -29,80 +29,7 @@
...
@@ -29,80 +29,7 @@
<h4
class=
"no-margin"
><i
class=
"fa fa-group"
></i>
{% trans "Manage access" %}
</h4>
<h4
class=
"no-margin"
><i
class=
"fa fa-group"
></i>
{% trans "Manage access" %}
</h4>
</div>
</div>
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
<form
action=
"{% url "
dashboard
.
views
.
template-acl
"
pk=
object.pk
%}"
method=
"post"
>
{% csrf_token %}
{% include "dashboard/_manage_access.html" with table_id="template-access-table" %}
<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=
"fa fa-times"
></i></th>
</tr>
</thead>
<tbody>
{% for i in acl.users %}
<tr>
<td>
<i
class=
"fa fa-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}}"
{%
if
i
.
level
not
in
acl
.
allowed_levels
%}
disabled
{%
endif
%}
>
{% for id, name in acl.levels %}
<option
{%
if
id =
i.level%}
selected=
"selected"
{%
endif
%}
{%
if
id
not
in
acl
.
allowed_levels
%}
disabled
{%
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=
"fa fa-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}}{% if i.level not in acl.allowed_levels %} disabled{% endif %}"
>
{% for id, name in acl.levels %}
<option
{%
if
id =
i.level%}
selected=
"selected"
{%
endif
%}
{%
if
id
not
in
acl
.
allowed_levels
%}
disabled
{%
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=
"fa fa-plus"
></i></td>
<td>
{{aclform.name }}
</td>
<td><select
class=
"form-control"
name=
"level"
>
{% for id, name in acl.levels %}
{% if id in acl.allowed_levels %}
<option
value=
"{{id}}"
>
{{name}}
</option>
{% endif %}
{% 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>
...
...
circle/dashboard/templates/dashboard/vm-detail/access.html
View file @
c2037190
...
@@ -14,64 +14,4 @@
...
@@ -14,64 +14,4 @@
{% endif %}
{% endif %}
</p>
</p>
<h3>
{% trans "Permissions"|capfirst %}
</h3>
<h3>
{% trans "Permissions"|capfirst %}
</h3>
<form
action=
"{{acl.url}}"
method=
"post"
>
{% csrf_token %}
{% include "dashboard/_manage_access.html" with table_id="vm-access-table" %}
<table
class=
"table table-striped table-with-form-fields"
id=
"vm-access-table"
>
<thead><tr>
<th></th>
<th>
{% trans "Who" %}
</th>
<th>
{% trans "What" %}
</th>
<th>
{% trans "Remove" %}
</th>
</tr></thead>
<tbody>
{% for i in acl.users %}
<tr>
<td><i
class=
"fa fa-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}}"
/>
</td>
</tr>
{% endfor %}
{% for i in acl.groups %}
<tr>
<td><i
class=
"fa fa-group"
></i></td>
<td>
<a
href=
"{% url "
dashboard
.
views
.
group-detail
"
pk=
i.group.pk
%}"
>
{{ i.group.name }}
</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}}"
/>
</td>
</tr>
{% endfor %}
<tr><td><i
class=
"fa fa-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>
circle/dashboard/views.py
View file @
c2037190
...
@@ -283,6 +283,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -283,6 +283,7 @@ class VmDetailView(CheckedDetailView):
)
.
all
()
)
.
all
()
context
[
'acl'
]
=
AclUpdateView
.
get_acl_data
(
context
[
'acl'
]
=
AclUpdateView
.
get_acl_data
(
instance
,
self
.
request
.
user
,
'dashboard.views.vm-acl'
)
instance
,
self
.
request
.
user
,
'dashboard.views.vm-acl'
)
context
[
'aclform'
]
=
AclUserAddForm
()
context
[
'os_type_icon'
]
=
instance
.
os_type
.
replace
(
"unknown"
,
context
[
'os_type_icon'
]
=
instance
.
os_type
.
replace
(
"unknown"
,
"question"
)
"question"
)
# ipv6 infos
# ipv6 infos
...
@@ -958,6 +959,7 @@ class GroupDetailView(CheckedDetailView):
...
@@ -958,6 +959,7 @@ class GroupDetailView(CheckedDetailView):
context
[
'acl'
]
=
AclUpdateView
.
get_acl_data
(
context
[
'acl'
]
=
AclUpdateView
.
get_acl_data
(
self
.
object
.
profile
,
self
.
request
.
user
,
self
.
object
.
profile
,
self
.
request
.
user
,
'dashboard.views.group-acl'
)
'dashboard.views.group-acl'
)
context
[
'aclform'
]
=
AclUserAddForm
()
context
[
'group_profile_form'
]
=
GroupProfileUpdate
.
get_form_object
(
context
[
'group_profile_form'
]
=
GroupProfileUpdate
.
get_form_object
(
self
.
request
,
self
.
object
.
profile
)
self
.
request
,
self
.
object
.
profile
)
...
...
circle/network/templates/network/vlan-edit.html
View file @
c2037190
...
@@ -23,61 +23,7 @@
...
@@ -23,61 +23,7 @@
<div
class=
"page-header"
>
<div
class=
"page-header"
>
<h3>
{% trans "Manage access" %}
</h3>
<h3>
{% trans "Manage access" %}
</h3>
</div>
</div>
<form
action=
"{% url "
network
.
vlan-acl
"
vid=
vlan_vid
%}"
method=
"post"
>
{% csrf_token %}
{% include "dashboard/_manage_access.html" with table_id="vlan-access-table" %}
<table
class=
"table table-striped table-with-form-fields"
id=
"vlan-access-table"
>
<thead>
<tr>
<th></th>
<th>
{% trans "Who" %}
</th>
<th>
{% trans "What" %}
</th>
<th><i
class=
"fa fa-times"
></i></th>
</tr></thead>
<tbody>
{% for i in acl.users %}
<tr>
<td><i
class=
"fa fa-user"
></i></td><td>
{{i.user}}
</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=
"fa fa-group"
></i></td><td>
{{i.group}}
</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=
"fa fa-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>
{% endblock %}
{% endblock %}
circle/network/urls.py
View file @
c2037190
...
@@ -84,7 +84,7 @@ urlpatterns = patterns(
...
@@ -84,7 +84,7 @@ urlpatterns = patterns(
url
(
'^vlans/$'
,
VlanList
.
as_view
(),
name
=
'network.vlan_list'
),
url
(
'^vlans/$'
,
VlanList
.
as_view
(),
name
=
'network.vlan_list'
),
url
(
'^vlans/create$'
,
VlanCreate
.
as_view
(),
name
=
'network.vlan_create'
),
url
(
'^vlans/create$'
,
VlanCreate
.
as_view
(),
name
=
'network.vlan_create'
),
url
(
'^vlans/(?P<vid>
\
d+)/$'
,
VlanDetail
.
as_view
(),
name
=
'network.vlan'
),
url
(
'^vlans/(?P<vid>
\
d+)/$'
,
VlanDetail
.
as_view
(),
name
=
'network.vlan'
),
url
(
'^vlans/(?P<
vid
>
\
d+)/acl/$'
,
VlanAclUpdateView
.
as_view
(),
url
(
'^vlans/(?P<
pk
>
\
d+)/acl/$'
,
VlanAclUpdateView
.
as_view
(),
name
=
'network.vlan-acl'
),
name
=
'network.vlan-acl'
),
url
(
'^vlans/delete/(?P<vid>
\
d+)/$'
,
VlanDelete
.
as_view
(),
url
(
'^vlans/delete/(?P<vid>
\
d+)/$'
,
VlanDelete
.
as_view
(),
name
=
"network.vlan_delete"
),
name
=
"network.vlan_delete"
),
...
...
circle/network/views.py
View file @
c2037190
...
@@ -42,6 +42,7 @@ from operator import itemgetter
...
@@ -42,6 +42,7 @@ from operator import itemgetter
from
itertools
import
chain
from
itertools
import
chain
import
json
import
json
from
dashboard.views
import
AclUpdateView
from
dashboard.views
import
AclUpdateView
from
dashboard.forms
import
AclUserAddForm
class
SuccessMessageMixin
(
FormMixin
):
class
SuccessMessageMixin
(
FormMixin
):
...
@@ -629,19 +630,8 @@ class VlanList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
...
@@ -629,19 +630,8 @@ class VlanList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
table_pagination
=
False
table_pagination
=
False
def
get_vlan_acl_data
(
obj
):
levels
=
obj
.
ACL_LEVELS
users
=
obj
.
get_users_with_level
()
users
=
[{
'user'
:
u
,
'level'
:
l
}
for
u
,
l
in
users
]
groups
=
obj
.
get_groups_with_level
()
groups
=
[{
'group'
:
g
,
'level'
:
l
}
for
g
,
l
in
groups
]
return
{
'users'
:
users
,
'groups'
:
groups
,
'levels'
:
levels
}
class
VlanAclUpdateView
(
AclUpdateView
):
class
VlanAclUpdateView
(
AclUpdateView
):
model
=
Vlan
model
=
Vlan
slug_field
=
"vid"
slug_url_kwarg
=
"vid"
class
VlanDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
class
VlanDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
...
@@ -662,7 +652,9 @@ class VlanDetail(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -662,7 +652,9 @@ class VlanDetail(LoginRequiredMixin, SuperuserRequiredMixin,
context
[
'host_list'
]
=
SmallHostTable
(
q
)
context
[
'host_list'
]
=
SmallHostTable
(
q
)
context
[
'vlan_vid'
]
=
self
.
kwargs
.
get
(
'vid'
)
context
[
'vlan_vid'
]
=
self
.
kwargs
.
get
(
'vid'
)
context
[
'acl'
]
=
get_vlan_acl_data
(
self
.
get_object
())
context
[
'acl'
]
=
AclUpdateView
.
get_acl_data
(
self
.
object
,
self
.
request
.
user
,
'network.vlan-acl'
)
context
[
'aclform'
]
=
AclUserAddForm
()
return
context
return
context
success_url
=
reverse_lazy
(
'network.vlan_list'
)
success_url
=
reverse_lazy
(
'network.vlan_list'
)
...
...
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