Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
AURA
steering
Commits
8708bdbd
Verified
Commit
8708bdbd
authored
1 year ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
fix: don’t limit the user queryset if the method is safe or the requesting is superuser
Closes
#177
parent
7c56e3b2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#7751
failed
1 year ago
Stage: build
Stage: test
Stage: deploy
Stage: release
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/views.py
+6
-7
6 additions, 7 deletions
program/views.py
with
6 additions
and
7 deletions
program/views.py
+
6
−
7
View file @
8708bdbd
...
...
@@ -265,12 +265,12 @@ class APIUserViewSet(
search_fields
=
[
"
username
"
,
"
first_name
"
,
"
last_name
"
,
"
email
"
]
def
get_queryset
(
self
):
"""
The queryset contains all the users if the requesting user is a
superuser, otherwise it
only contains the requesting user.
"""
"""
The queryset contains all the users if the
method is safe or
requesting user is a
superuser, otherwise it
only contains the requesting user.
"""
user
=
self
.
request
.
user
if
user
.
is_superuser
:
if
self
.
request
.
method
in
permissions
.
SAFE_METHODS
or
user
.
is_superuser
:
return
User
.
objects
.
all
()
else
:
return
User
.
objects
.
filter
(
pk
=
user
.
id
)
...
...
@@ -306,7 +306,7 @@ class APIImageViewSet(viewsets.ModelViewSet):
pagination_class
=
LimitOffsetPagination
def
get_queryset
(
self
):
"""
The queryset contains all the images if the method is safe, otherwise it only
include
s
"""
The queryset contains all the images if the method is safe, otherwise it only
contain
s
the images owned by the requesting user.
"""
if
self
.
request
.
method
in
permissions
.
SAFE_METHODS
:
...
...
@@ -715,9 +715,8 @@ class APINoteViewSet(
serializer_class
=
NoteSerializer
def
get_queryset
(
self
):
"""
The queryset contains all the notes if the method is safe or the requesting user is
member of the privileged group, otherwise it only includes the notes for show owned by the
requesting user.
"""
"""
The queryset contains all the notes if the method is safe or the requesting user is a
superuser, otherwise it only contains the notes for shows owned by the requesting user.
"""
user
=
self
.
request
.
user
...
...
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