Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
0b3c1d59
authored
Jul 07, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-group-perms' into 'master'
Change group perms ![](
http://i.imgur.com/iDgAcpa.png
)
parents
6faef9af
03940a7f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
101 additions
and
5 deletions
+101
-5
circle/dashboard/forms.py
+30
-0
circle/dashboard/static/dashboard/dashboard.css
+29
-0
circle/dashboard/templates/dashboard/group-detail.html
+19
-3
circle/dashboard/urls.py
+5
-1
circle/dashboard/views.py
+18
-1
No files found.
circle/dashboard/forms.py
View file @
0b3c1d59
...
...
@@ -48,6 +48,8 @@ from storage.models import Disk
from
vm.models
import
(
InstanceTemplate
,
Lease
,
InterfaceTemplate
,
Node
,
Trait
,
Instance
)
from
django.contrib.admin.widgets
import
FilteredSelectMultiple
from
django.contrib.auth.models
import
Permission
from
.models
import
Profile
,
GroupProfile
from
circle.settings.base
import
LANGUAGES
from
django.utils.translation
import
string_concat
...
...
@@ -1212,3 +1214,31 @@ class RawDataForm(forms.ModelForm):
css_class
=
"btn btn-success"
,
css_id
=
"submit-password-button"
))
return
helper
permissions_filtered
=
Permission
.
objects
.
exclude
(
codename__startswith
=
"add_"
)
.
exclude
(
codename__startswith
=
"delete_"
)
.
exclude
(
codename__startswith
=
"change_"
)
class
GroupPermissionForm
(
forms
.
ModelForm
):
permissions
=
forms
.
ModelMultipleChoiceField
(
queryset
=
permissions_filtered
,
widget
=
FilteredSelectMultiple
(
_
(
"permissions"
),
is_stacked
=
False
)
)
class
Meta
:
model
=
Group
fields
=
(
'permissions'
,
)
@property
def
helper
(
self
):
helper
=
FormHelper
()
helper
.
form_show_labels
=
False
helper
.
form_action
=
reverse_lazy
(
"dashboard.views.group-permissions"
,
kwargs
=
{
'group_pk'
:
self
.
instance
.
pk
})
helper
.
add_input
(
Submit
(
"submit"
,
_
(
"Save"
),
css_class
=
"btn btn-success"
,
))
return
helper
circle/dashboard/static/dashboard/dashboard.css
View file @
0b3c1d59
...
...
@@ -722,3 +722,32 @@ textarea[name="list-new-namelist"] {
margin-bottom
:
20px
;
}
#group-detail-permissions
.filtered
{
margin
:
2px
0
;
padding
:
2px
3px
;
vertical-align
:
middle
;
font-family
:
"Lucida Grande"
,
Verdana
,
Arial
,
sans-serif
;
font-weight
:
normal
;
font-size
:
11px
;
border
:
1px
solid
#ccc
;
}
#group-detail-permissions
.selector-available
h2
,
#group-detail-permissions
.selector-chosen
h2
{
margin
:
0
;
padding
:
5px
8px
5px
8px
;
font-size
:
12px
;
text-align
:
left
;
font-weight
:
bold
;
background
:
#7CA0C7
;
color
:
white
;
}
#group-detail-user-table
{
margin-top
:
20px
;
}
#group-detail-permissions
input
[
type
=
"submit"
]
{
margin-top
:
-6px
;
}
circle/dashboard/templates/dashboard/group-detail.html
View file @
0b3c1d59
...
...
@@ -48,6 +48,8 @@
{% crispy group_profile_form %}
</form>
<hr
/>
<h3>
{% trans "User list"|capfirst %}
{% if perms.auth.add_user %}
<a
href=
"{% url "
dashboard
.
views
.
create-user
"
group
.
pk
%}"
class=
"btn btn-success pull-right"
>
{% trans "Create user" %}
</a>
...
...
@@ -100,8 +102,8 @@
</div>
</form>
<h3
id=
"group-detail-perm-header"
>
{% trans "
P
ermissions"|capfirst %}
</h3>
<hr
/>
<h3
id=
"group-detail-perm-header"
>
{% trans "
Access p
ermissions"|capfirst %}
</h3>
<form
action=
"{{acl.url}}"
method=
"post"
>
{% csrf_token %}
<table
class=
"table table-striped table-with-form-fields table-bordered"
id=
"group-detail-perm-table"
>
<thead>
...
...
@@ -172,11 +174,25 @@
</div>
</form>
{% if user.is_superuser %}
<hr
/>
<script
type=
"text/javascript"
src=
"/static/admin/js/jquery.min.js"
></script>
<script
type=
"text/javascript"
src=
"/static/admin/js/jquery.init.js"
></script>
{{ group_perm_form.media }}
<h3>
{% trans "Group permissions" %}
</h3>
<div
id=
"group-detail-permissions"
>
{% crispy group_perm_form %}
</div>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"/static/admin/css/widgets.css"
/>
{% endif %}
</div>
</div>
</div>
</div>
</div>
<script
src=
"{{ STATIC_URL}}dashboard/group-details.js"
></script>
{% endblock %}
circle/dashboard/urls.py
View file @
0b3c1d59
...
...
@@ -38,7 +38,8 @@ from .views import (
get_vm_screenshot
,
ProfileView
,
toggle_use_gravatar
,
UnsubscribeFormView
,
UserKeyDelete
,
UserKeyDetail
,
UserKeyCreate
,
VmTraitsUpdate
,
VmRawDataUpdate
VmTraitsUpdate
,
VmRawDataUpdate
,
GroupPermissionsView
,
)
urlpatterns
=
patterns
(
...
...
@@ -166,6 +167,9 @@ urlpatterns = patterns(
url
(
r'^group/(?P<group_pk>\d+)/create/$'
,
UserCreationView
.
as_view
(),
name
=
"dashboard.views.create-user"
),
url
(
r'^group/(?P<group_pk>\d+)/permissions/$'
,
GroupPermissionsView
.
as_view
(),
name
=
"dashboard.views.group-permissions"
),
url
(
r'^sshkey/delete/(?P<pk>\d+)/$'
,
UserKeyDelete
.
as_view
(),
...
...
circle/dashboard/views.py
View file @
0b3c1d59
...
...
@@ -62,7 +62,7 @@ from .forms import (
UserCreationForm
,
GroupProfileUpdateForm
,
UnsubscribeForm
,
VmSaveForm
,
UserKeyForm
,
CirclePasswordChangeForm
,
VmCreateDiskForm
,
VmDownloadDiskForm
,
TraitsForm
,
RawDataForm
TraitsForm
,
RawDataForm
,
GroupPermissionForm
)
from
.tables
import
(
...
...
@@ -828,12 +828,18 @@ class GroupDetailView(CheckedDetailView):
context
[
'acl'
]
=
get_group_acl_data
(
self
.
object
)
context
[
'group_profile_form'
]
=
GroupProfileUpdate
.
get_form_object
(
self
.
request
,
self
.
object
.
profile
)
if
self
.
request
.
user
.
is_superuser
:
context
[
'group_perm_form'
]
=
GroupPermissionForm
(
instance
=
self
.
object
)
return
context
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
object
=
self
.
get_object
()
if
not
self
.
get_has_level
()(
request
.
user
,
'operator'
):
raise
PermissionDenied
()
if
request
.
POST
.
get
(
'new_name'
):
return
self
.
__set_name
(
request
)
if
request
.
POST
.
get
(
'list-new-name'
):
...
...
@@ -895,6 +901,17 @@ class GroupDetailView(CheckedDetailView):
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
class
GroupPermissionsView
(
SuperuserRequiredMixin
,
UpdateView
):
model
=
Group
form_class
=
GroupPermissionForm
slug_field
=
"pk"
slug_url_kwarg
=
"group_pk"
def
get_success_url
(
self
):
return
"
%
s#group-detail-permissions"
%
(
self
.
get_object
()
.
groupprofile
.
get_absolute_url
())
class
AclUpdateView
(
LoginRequiredMixin
,
View
,
SingleObjectMixin
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
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