Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
0885a946
Commit
0885a946
authored
6 years ago
by
Carlos Vega
Browse files
Options
Downloads
Patches
Plain Diff
removed unnecessary code
parent
b9797d8d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!192
Feature/add way to change password and PERMISSIONS
Pipeline
#7587
passed
6 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/decorators.py
+1
-16
1 addition, 16 deletions
smash/web/decorators.py
with
1 addition
and
16 deletions
smash/web/decorators.py
+
1
−
16
View file @
0885a946
...
...
@@ -62,7 +62,7 @@ class PermissionDecorator:
@staticmethod
def
get_permissions
():
if
PermissionDecorator
.
permissions_queryset
is
None
and
len
(
PermissionDecorator
.
codenames
)
>
0
:
if
PermissionDecorator
.
permissions_queryset
is
None
or
len
(
PermissionDecorator
.
codenames
)
>
len
(
PermissionDecorator
.
permissions_queryset
)
:
PermissionDecorator
.
permissions_queryset
=
Permission
.
objects
.
filter
(
codename__in
=
PermissionDecorator
.
codenames
)
return
PermissionDecorator
.
permissions_queryset
...
...
@@ -81,21 +81,6 @@ class PermissionDecorator:
#variables to be used on decorator call
self
.
perm_codename
=
perm_codename
# since the decorators are executed during code interpretation, we need to avoid executing
# the rest of the code if we are in the process of ./manage migrate or makemigrations
# since Permission won't be already migrated
if
is_django_migrating
():
return
query_result
=
Permission
.
objects
.
filter
(
codename
=
perm_codename
)
if
len
(
query_result
)
<
0
:
logger
.
warn
(
'
Codename {} used in PermissionDecorator does not exist.
'
.
format
(
perm_codename
))
raise
ValueError
if
query_result
[
0
].
id
not
in
PermissionDecorator
.
permission_ids
:
#avoid re-query if the permissions remain the same
PermissionDecorator
.
permission_ids
.
add
(
query_result
[
0
].
id
)
PermissionDecorator
.
permissions_queryset
=
Permission
.
objects
.
filter
(
id__in
=
PermissionDecorator
.
permission_ids
).
all
()
def
__call__
(
self
,
func
):
'''
This method is also called when the function is decorated
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment