Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
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
Show 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 @@
...
@@ -39,7 +39,7 @@
<thead><tr><th></th><th>
{% trans "Who" %}
</th><th></th><th></th></tr></thead>
<thead><tr><th></th><th>
{% trans "Who" %}
</th><th></th><th></th></tr></thead>
{% for i in users %}
{% for i in users %}
<tr><td><i
class=
"icon-user"
></i></td><td>
{{i.username}}
</td>
<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 %}
{% endfor %}
<tr><td><i
class=
"icon-plus"
></i></td>
<tr><td><i
class=
"icon-plus"
></i></td>
<td><input
type=
"text"
class=
"form-control"
name=
"perm-new-name"
<td><input
type=
"text"
class=
"form-control"
name=
"perm-new-name"
...
@@ -60,7 +60,16 @@
...
@@ -60,7 +60,16 @@
<option
{%
if
id =
i.level%}
selected=
"selected"
{%
endif
%}
value=
"{{id}}"
>
{{name}}
</option>
<option
{%
if
id =
i.level%}
selected=
"selected"
{%
endif
%}
value=
"{{id}}"
>
{{name}}
</option>
{% endfor %}
{% endfor %}
</select></td>
</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 %}
{% endfor %}
<tr><td><i
class=
"icon-plus"
></i></td>
<tr><td><i
class=
"icon-plus"
></i></td>
<td><input
type=
"text"
class=
"form-control"
name=
"perm-new-name"
<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
django.conf.urls
import
patterns
,
url
from
.views
import
(
from
.views
import
(
AclUpdateView
,
DiskAddView
,
FavouriteView
,
GroupAclUpdateView
,
AclUpdateView
,
DiskAddView
,
FavouriteView
,
GroupAclUpdateView
,
GroupDelete
,
GroupDe
lete
,
GroupDetailView
,
GroupList
,
GroupUserDele
te
,
GroupDe
tailView
,
GroupList
,
GroupUserDelete
,
IndexView
,
LeaseCrea
te
,
IndexView
,
LeaseCreate
,
LeaseDelete
,
LeaseDetail
,
MyPreferencesView
,
LeaseDelete
,
LeaseDetail
,
MyPreferencesView
,
NodeAddTraitView
,
NodeCreate
,
Node
AddTraitView
,
NodeCreate
,
NodeDelete
,
NodeDetailView
,
NodeFlushView
,
Node
Delete
,
NodeDetailView
,
NodeFlushView
,
NodeGraphView
,
NodeList
,
Node
GraphView
,
NodeList
,
NodeStatus
,
NotificationView
,
PortDelete
,
Node
Status
,
NotificationView
,
PortDelete
,
TemplateAclUpdateView
,
Template
AclUpdateView
,
TemplateCreate
,
TemplateDelete
,
TemplateDetail
,
Template
Create
,
TemplateDelete
,
TemplateDetail
,
TemplateList
,
T
emplateList
,
TransferOwnershipConfirmView
,
TransferOwnershipView
,
T
ransferOwnershipConfirmView
,
TransferOwnershipView
,
vm_activity
,
VmCreate
,
vm_activity
,
VmCreate
,
VmDelete
,
VmDetailView
,
VmDetailVncTokenView
,
VmDelete
,
VmDetailView
,
VmDetailVncTokenView
,
VmGraphView
,
VmList
,
Vm
GraphView
,
VmList
,
VmMassDelete
,
VmMigrateView
,
VmRenew
View
,
Vm
MassDelete
,
VmMigrateView
,
VmRenewView
,
GroupRemoveAclUser
View
,
Group
AclRemoveView
,
GroupMemberRemove
View
Group
RemoveAclGroupView
,
GroupRemoveUser
View
)
)
from
vm.models
import
Instance
from
vm.models
import
Instance
...
@@ -102,10 +102,13 @@ urlpatterns = patterns(
...
@@ -102,10 +102,13 @@ urlpatterns = patterns(
name
=
"dashboard.views.disk-add"
),
name
=
"dashboard.views.disk-add"
),
url
(
r'^profile/$'
,
MyPreferencesView
.
as_view
(),
url
(
r'^profile/$'
,
MyPreferencesView
.
as_view
(),
name
=
"dashboard.views.profile"
),
name
=
"dashboard.views.profile"
),
url
(
r'^group/(?P<group_pk>\d+)/remove/acl/(?P<user_pk>\d+)/$'
,
url
(
r'^group/(?P<group_pk>\d+)/remove/acl/user/(?P<user_pk>\d+)/$'
,
GroupAclRemoveView
.
as_view
(),
GroupRemoveAclUserView
.
as_view
(),
name
=
"dashboard.views.remove-groupaclmember"
),
name
=
"dashboard.views.remove-acluser"
),
url
(
r'^group/(?P<group_pk>\d+)/remove/member/(?P<user_pk>\d+)/$'
,
url
(
r'^group/(?P<group_pk>\d+)/remove/acl/group/(?P<user_pk>\d+)/$'
,
GroupMemberRemoveView
.
as_view
(),
GroupRemoveAclGroupView
.
as_view
(),
name
=
"dashboard.views.remove-groupmember"
),
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):
...
@@ -635,6 +635,8 @@ class AclUpdateView(LoginRequiredMixin, View, SingleObjectMixin):
m
=
re
.
match
(
'perm-([ug])-(
\
d+)'
,
key
)
m
=
re
.
match
(
'perm-([ug])-(
\
d+)'
,
key
)
if
m
:
if
m
:
typ
,
id
=
m
.
groups
()
typ
,
id
=
m
.
groups
()
print
"+++++++++++++++++++++"
print
typ
entity
=
{
'u'
:
User
,
'g'
:
Group
}[
typ
]
.
objects
.
get
(
id
=
id
)
entity
=
{
'u'
:
User
,
'g'
:
Group
}[
typ
]
.
objects
.
get
(
id
=
id
)
if
getattr
(
instance
,
"owner"
,
None
)
==
entity
:
if
getattr
(
instance
,
"owner"
,
None
)
==
entity
:
logger
.
info
(
"Tried to set owner's acl level for
%
s by
%
s."
,
logger
.
info
(
"Tried to set owner's acl level for
%
s by
%
s."
,
...
@@ -986,7 +988,7 @@ class GroupUserDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
...
@@ -986,7 +988,7 @@ class GroupUserDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
return
reverse_lazy
(
'dashboard.index'
)
return
reverse_lazy
(
'dashboard.index'
)
class
Group
MemberRemove
View
(
LoginRequiredMixin
,
DeleteView
):
class
Group
RemoveUser
View
(
LoginRequiredMixin
,
DeleteView
):
model
=
Group
model
=
Group
slug_field
=
'pk'
slug_field
=
'pk'
slug_url_kwarg
=
'group_pk'
slug_url_kwarg
=
'group_pk'
...
@@ -1004,15 +1006,15 @@ class GroupMemberRemoveView(LoginRequiredMixin, DeleteView):
...
@@ -1004,15 +1006,15 @@ class GroupMemberRemoveView(LoginRequiredMixin, DeleteView):
else
:
else
:
return
[
'dashboard/confirm/base-remove.html'
]
return
[
'dashboard/confirm/base-remove.html'
]
def
remove_
user
(
self
,
user
pk
):
def
remove_
member
(
self
,
pk
):
container
=
self
.
get_object
()
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
):
def
get_success_message
(
self
):
return
_
(
"Member successfully removed from group!"
)
return
_
(
"Member successfully removed from group!"
)
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
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_url
=
self
.
get_success_url
()
success_message
=
self
.
get_success_message
()
success_message
=
self
.
get_success_message
()
...
@@ -1026,14 +1028,24 @@ class GroupMemberRemoveView(LoginRequiredMixin, DeleteView):
...
@@ -1026,14 +1028,24 @@ class GroupMemberRemoveView(LoginRequiredMixin, DeleteView):
return
HttpResponseRedirect
(
success_url
)
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
=
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
):
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
):
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