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
b8e7c396
authored
Feb 20, 2014
by
Oláh István Gergely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: list acl groups, remove groups, group perm fix
parent
a37614e8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
26 deletions
+50
-26
circle/dashboard/templates/dashboard/group-detail.html
+11
-2
circle/dashboard/urls.py
+19
-16
circle/dashboard/views.py
+20
-8
No files found.
circle/dashboard/templates/dashboard/group-detail.html
View file @
b8e7c396
...
...
@@ -39,7 +39,7 @@
<thead><tr><th></th><th>
{% trans "Who" %}
</th><th></th><th></th></tr></thead>
{% for i in users %}
<tr><td><i
class=
"icon-user"
></i></td><td>
{{i.username}}
</td>
<td><a
data-groupmember-pk=
"{{i.pk}}"
href=
"{% url "
dashboard
.
views
.
remove-
groupmemb
er
"
user_pk=
i.pk
group_pk=
group.pk
%}?
next=
{{
request
.
path
}}"
class=
"real-link groupmember-delete btn btn-link btn-xs"
><i
class=
"icon-remove"
><span
class=
"sr-only"
>
{% trans "remove" %}
</span></i></a></td></tr>
<td><a
data-groupmember-pk=
"{{i.pk}}"
href=
"{% url "
dashboard
.
views
.
remove-
us
er
"
user_pk=
i.pk
group_pk=
group.pk
%}?
next=
{{
request
.
path
}}"
class=
"real-link groupmember-delete btn btn-link btn-xs"
><i
class=
"icon-remove"
><span
class=
"sr-only"
>
{% trans "remove" %}
</span></i></a></td></tr>
{% endfor %}
<tr><td><i
class=
"icon-plus"
></i></td>
<td><input
type=
"text"
class=
"form-control"
name=
"perm-new-name"
...
...
@@ -60,7 +60,16 @@
<option
{%
if
id =
i.level%}
selected=
"selected"
{%
endif
%}
value=
"{{id}}"
>
{{name}}
</option>
{% endfor %}
</select></td>
<td
class=
"user-remove"
><a
href=
"#"
class=
"btn btn-link btn-xs"
><i
class=
"icon-remove"
><span
class=
"sr-only"
>
{% trans "remove" %}
</span></i></a></td></tr>
<td
class=
"user-remove"
><a
data-groupaclmember-pk=
"{{i.user.id}}"
href=
"{% url "
dashboard
.
views
.
remove-acluser
"
user_pk=
i.user.pk
group_pk=
group.pk
%}?
next=
{{
request
.
path
}}"
class=
"real-link groupacl-delete btn btn-link btn-xs"
><i
class=
"icon-remove"
><span
class=
"sr-only"
>
{% trans "remove" %}
</span></i></a></td></tr>
{% endfor %}
{% for i in acl.groups %}
<tr><td><i
class=
"icon-user"
></i></td><td>
{{ i.group }}
</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-groupaclmember-pk=
"{{i.group.pk }}"
href=
"{% url "
dashboard
.
views
.
remove-aclgroup
"
user_pk=
i.group.pk
group_pk=
group.pk
%}?
next=
{{
request
.
path
}}"
class=
"real-link groupacl-delete btn btn-link btn-xs"
><i
class=
"icon-remove"
><span
class=
"sr-only"
>
{% trans "remove" %}
</span></i></a></td></tr>
{% endfor %}
<tr><td><i
class=
"icon-plus"
></i></td>
<td><input
type=
"text"
class=
"form-control"
name=
"perm-new-name"
...
...
circle/dashboard/urls.py
View file @
b8e7c396
from
django.conf.urls
import
patterns
,
url
from
.views
import
(
AclUpdateView
,
DiskAddView
,
FavouriteView
,
GroupAclUpdateView
,
GroupDe
lete
,
GroupDetailView
,
GroupList
,
GroupUserDele
te
,
IndexView
,
LeaseCreate
,
LeaseDelete
,
LeaseDetail
,
MyPreferencesView
,
Node
AddTraitView
,
NodeCreate
,
NodeDelete
,
NodeDetailView
,
NodeFlushView
,
Node
GraphView
,
NodeList
,
NodeStatus
,
NotificationView
,
PortDelete
,
Template
AclUpdateView
,
TemplateCreate
,
TemplateDelete
,
TemplateDetail
,
T
emplateList
,
TransferOwnershipConfirmView
,
TransferOwnershipView
,
vm_activity
,
VmCreate
,
VmDelete
,
VmDetailView
,
VmDetailVncTokenView
,
Vm
GraphView
,
VmList
,
VmMassDelete
,
VmMigrateView
,
VmRenew
View
,
Group
AclRemoveView
,
GroupMemberRemove
View
AclUpdateView
,
DiskAddView
,
FavouriteView
,
GroupAclUpdateView
,
GroupDelete
,
GroupDe
tailView
,
GroupList
,
GroupUserDelete
,
IndexView
,
LeaseCrea
te
,
LeaseDelete
,
LeaseDetail
,
MyPreferencesView
,
NodeAddTraitView
,
NodeCreate
,
Node
Delete
,
NodeDetailView
,
NodeFlushView
,
NodeGraphView
,
NodeList
,
Node
Status
,
NotificationView
,
PortDelete
,
TemplateAclUpdateView
,
Template
Create
,
TemplateDelete
,
TemplateDetail
,
TemplateList
,
T
ransferOwnershipConfirmView
,
TransferOwnershipView
,
vm_activity
,
VmCreate
,
VmDelete
,
VmDetailView
,
VmDetailVncTokenView
,
VmGraphView
,
VmList
,
Vm
MassDelete
,
VmMigrateView
,
VmRenewView
,
GroupRemoveAclUser
View
,
Group
RemoveAclGroupView
,
GroupRemoveUser
View
)
from
vm.models
import
Instance
...
...
@@ -102,10 +102,13 @@ urlpatterns = patterns(
name
=
"dashboard.views.disk-add"
),
url
(
r'^profile/$'
,
MyPreferencesView
.
as_view
(),
name
=
"dashboard.views.profile"
),
url
(
r'^group/(?P<group_pk>\d+)/remove/acl/(?P<user_pk>\d+)/$'
,
GroupAclRemoveView
.
as_view
(),
name
=
"dashboard.views.remove-groupaclmember"
),
url
(
r'^group/(?P<group_pk>\d+)/remove/member/(?P<user_pk>\d+)/$'
,
GroupMemberRemoveView
.
as_view
(),
name
=
"dashboard.views.remove-groupmember"
),
url
(
r'^group/(?P<group_pk>\d+)/remove/acl/user/(?P<user_pk>\d+)/$'
,
GroupRemoveAclUserView
.
as_view
(),
name
=
"dashboard.views.remove-acluser"
),
url
(
r'^group/(?P<group_pk>\d+)/remove/acl/group/(?P<user_pk>\d+)/$'
,
GroupRemoveAclGroupView
.
as_view
(),
name
=
"dashboard.views.remove-aclgroup"
),
url
(
r'^group/(?P<group_pk>\d+)/remove/user/(?P<user_pk>\d+)/$'
,
GroupRemoveUserView
.
as_view
(),
name
=
"dashboard.views.remove-user"
),
)
circle/dashboard/views.py
View file @
b8e7c396
...
...
@@ -635,6 +635,8 @@ class AclUpdateView(LoginRequiredMixin, View, SingleObjectMixin):
m
=
re
.
match
(
'perm-([ug])-(
\
d+)'
,
key
)
if
m
:
typ
,
id
=
m
.
groups
()
print
"+++++++++++++++++++++"
print
typ
entity
=
{
'u'
:
User
,
'g'
:
Group
}[
typ
]
.
objects
.
get
(
id
=
id
)
if
getattr
(
instance
,
"owner"
,
None
)
==
entity
:
logger
.
info
(
"Tried to set owner's acl level for
%
s by
%
s."
,
...
...
@@ -986,7 +988,7 @@ class GroupUserDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
return
reverse_lazy
(
'dashboard.index'
)
class
Group
MemberRemove
View
(
LoginRequiredMixin
,
DeleteView
):
class
Group
RemoveUser
View
(
LoginRequiredMixin
,
DeleteView
):
model
=
Group
slug_field
=
'pk'
slug_url_kwarg
=
'group_pk'
...
...
@@ -1004,15 +1006,15 @@ class GroupMemberRemoveView(LoginRequiredMixin, DeleteView):
else
:
return
[
'dashboard/confirm/base-remove.html'
]
def
remove_
user
(
self
,
user
pk
):
def
remove_
member
(
self
,
pk
):
container
=
self
.
get_object
()
container
.
user_set
.
remove
(
User
.
objects
.
get
(
pk
=
user
pk
))
container
.
user_set
.
remove
(
User
.
objects
.
get
(
pk
=
pk
))
def
get_success_message
(
self
):
return
_
(
"Member successfully removed from group!"
)
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
remove_
us
er
(
kwargs
[
"user_pk"
])
self
.
remove_
memb
er
(
kwargs
[
"user_pk"
])
success_url
=
self
.
get_success_url
()
success_message
=
self
.
get_success_message
()
...
...
@@ -1026,14 +1028,24 @@ class GroupMemberRemoveView(LoginRequiredMixin, DeleteView):
return
HttpResponseRedirect
(
success_url
)
class
Group
AclRemoveView
(
GroupMemberRemove
View
):
class
Group
RemoveAclUserView
(
GroupRemoveUser
View
):
def
remove_
user
(
self
,
user
pk
):
def
remove_
member
(
self
,
pk
):
container
=
self
.
get_object
()
.
profile
container
.
set_level
(
User
.
objects
.
get
(
pk
=
user
pk
),
None
)
container
.
set_level
(
User
.
objects
.
get
(
pk
=
pk
),
None
)
def
get_success_message
(
self
):
return
_
(
"Acl member successfully removed from group!"
)
return
_
(
"Acl user successfully removed from group!"
)
class
GroupRemoveAclGroupView
(
GroupRemoveUserView
):
def
remove_member
(
self
,
pk
):
container
=
self
.
get_object
()
.
profile
container
.
set_level
(
Group
.
objects
.
get
(
pk
=
pk
),
None
)
def
get_success_message
(
self
):
return
_
(
"Acl group successfully removed from group!"
)
class
GroupDelete
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DeleteView
):
...
...
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