Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Merge requests
!1131
Access right mixin
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Access right mixin
right-mixins
into
master
Overview
9
Commits
22
Pipelines
0
Changes
1
All threads resolved!
Hide all comments
Merged
Valentin Rigal
requested to merge
right-mixins
into
master
4 years ago
Overview
9
Commits
22
Pipelines
0
Changes
1
All threads resolved!
Hide all comments
Expand
Closes
#588 (closed)
Edited
4 years ago
by
Valentin Rigal
0
0
Merge request reports
Viewing commit
8bcf5870
Prev
Next
Show latest version
1 file
+
7
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
8bcf5870
Handle anonymous user
· 8bcf5870
Valentin Rigal
authored
4 years ago
arkindex/project/mixins.py
+
7
−
0
Options
@@ -32,8 +32,15 @@ class ACLMixin(object):
"""
Return a model queryset matching a given access level for this user
"""
# Handle specific cases (i.e. admin or anonymous user)
if
self
.
user
.
is_admin
or
self
.
user
.
is_internal
:
return
model
.
objects
.
all
()
elif
user
.
is_anonymous
:
if
level
>
Role
.
Guest
.
value
or
not
public
:
return
model
.
objects
.
none
()
else
:
return
model
.
objects
.
filter
(
public
=
True
)
queryset
=
model
.
objects
\
.
filter
(
# Filter instances with direct and groups rights for this user (They may be duplicated)
Loading