Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
664fb7ae
Commit
664fb7ae
authored
May 07, 2018
by
Hugo LEVY-FALK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Utilisation de inutile.
parent
b1ac9fff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
8 deletions
+6
-8
re2o/acl.py
re2o/acl.py
+6
-8
No files found.
re2o/acl.py
View file @
664fb7ae
...
...
@@ -36,7 +36,7 @@ from django.shortcuts import redirect
from
django.urls
import
reverse
def
acl_base_decorator
(
method_name
,
*
targets
,
**
kwargs
):
def
acl_base_decorator
(
method_name
,
*
targets
,
on_instance
=
True
):
"""Base decorator for acl. It checks if the `request.user` has the
permission by calling model.method_name. If the flag on_instance is True,
tries to get an instance of the model by calling
...
...
@@ -82,12 +82,11 @@ on_instance=False)
on_instance=False)
```
But don't do that, it's silly.
**kwargs: There is only one keyword argument, `on_instance`, which
default value is `True`. When `on_instance` equals `False`, the
decorator runs the ACL method on the model class rather than on
an instance. If an instance need to fetched, it is done calling the
assumed existing method `get_instance` of the model, with the
arguments originally passed to the view.
on_instance: When `on_instance` equals `False`, the decorator runs the
ACL method on the model class rather than on an instance. If an
instance need to fetched, it is done calling the assumed existing
method `get_instance` of the model, with the arguments originally
passed to the view.
Returns:
The user is either redirected to their own page with an explanation
...
...
@@ -104,7 +103,6 @@ ModelC)
```
where `*args` and `**kwargs` are the original view arguments.
"""
on_instance
=
kwargs
.
get
(
'on_instance'
,
True
)
def
group_targets
():
"""This generator parses the targets of the decorator, yielding
...
...
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