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
a22a7c66
authored
Feb 24, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: exclude permissions better
parent
211e28fe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
7 deletions
+41
-7
circle/dashboard/forms.py
+41
-7
No files found.
circle/dashboard/forms.py
View file @
a22a7c66
...
...
@@ -1428,18 +1428,52 @@ class RawDataForm(forms.ModelForm):
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
,
queryset
=
None
,
widget
=
FilteredSelectMultiple
(
_
(
"permissions"
),
is_stacked
=
False
)
)
def
get_filtered_permissions
(
self
):
""" Collected with this + djcelery source
def get_model_classes_in_module(module):
import sys
import inspect
from django.db.models import Model
classes = []
for name, obj in inspect.getmembers(sys.modules[module]):
if inspect.isclass(obj) and issubclass(obj, Model):
classes.append(name.lower())
return classes
"""
excluded_objs
=
[
"tag"
,
"taggeditem"
,
"level"
,
"objectlevel"
,
"permission"
,
"contenttype"
,
"migrationhistory"
,
"site"
,
"session"
,
"intervalschedule"
,
"crontabschedule"
,
"periodictask"
,
"periodictasks"
,
"workerstate"
,
"taskstate"
,
"taskmeta"
,
"tasksetmeta"
,
"logentry"
,
"baseresourceconfigmodel"
,
"instance"
,
"instanceactivity"
,
"instancetemplate"
,
"interface"
,
"interfacetemplate"
,
"lease"
,
"namedbaseresourceconfig"
,
"node"
,
"nodeactivity"
,
"trait"
,
"virtualmachinedescmodel"
,
"aclbase"
,
"connectcommand"
,
"favourite"
,
"futuremember"
,
"groupprofile"
,
"model"
,
"notification"
,
"profile"
,
"timestampedmodel"
,
"userkey"
,
"datastore"
,
"disk"
,
"model"
,
"timestampedmodel"
,
"aclbase"
,
"blacklistitem"
,
"domain"
,
"ethernetdevice"
,
"firewall"
,
"host"
,
"record"
,
"rule"
,
"switchport"
,
"vlan"
,
"vlangroup"
,
"sender"
,
]
exclude_add
=
[
"add_
%
s"
%
l
for
l
in
excluded_objs
]
exclude_change
=
[
"change_
%
s"
%
l
for
l
in
excluded_objs
]
exclude_delete
=
[
"delete_
%
s"
%
l
for
l
in
excluded_objs
+
[
"user"
]]
return
Permission
.
objects
.
exclude
(
codename__in
=
exclude_add
)
.
exclude
(
codename__in
=
exclude_change
)
.
exclude
(
codename__in
=
exclude_delete
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
GroupPermissionForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'permissions'
]
.
queryset
=
self
.
get_filtered_permissions
()
class
Meta
:
model
=
Group
fields
=
(
'permissions'
,
)
...
...
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