Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
5cf4f2b6
Unverified
Commit
5cf4f2b6
authored
Jan 02, 2018
by
Thom Wiggers
📐
Browse files
Restrict pizzas in API
parent
653943eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
website/pizzas/api/viewsets.py
View file @
5cf4f2b6
...
...
@@ -21,7 +21,11 @@ class PizzaViewset(GenericViewSet, ListModelMixin):
def
list
(
self
,
request
,
*
args
,
**
kwargs
):
if
(
PizzaEvent
.
current
()
or
request
.
user
.
has_perm
(
'pizzas.change_product'
)):
return
super
().
list
(
request
,
*
args
,
**
kwargs
)
queryset
=
self
.
get_queryset
()
if
not
request
.
user
.
has_perm
(
'pizzas.order_restricted_products'
):
queryset
=
queryset
.
exclude
(
restricted
=
True
)
serializer
=
serializers
.
PizzaSerializer
(
queryset
,
many
=
True
)
return
Response
(
serializer
.
data
)
raise
PermissionDenied
@
list_route
()
...
...
Write
Preview
Supports
Markdown
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