Skip to content
Snippets Groups Projects
Commit e29e9a82 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

first approach at filtering viewed compounds based on permissions

WIP on #68
parent 2b1c8e9c
No related branches found
No related tags found
No related merge requests found
Pipeline #20614 passed
...@@ -564,6 +564,16 @@ class CompoundListView(ListView): ...@@ -564,6 +564,16 @@ class CompoundListView(ListView):
self.filter_context = {} self.filter_context = {}
# get queryset # get queryset
qs = super().get_queryset() qs = super().get_queryset()
# compounds can be accessed only if they are validated or
# if the current user is an admin OR their contributor
current_user = self.request.user
if current_user.is_anonymous:
qs = qs.exclude(compoundaction__ppi__contribution__validated=False)
elif not current_user.is_superuser:
qs = qs.exclude(
Q(compoundaction__ppi__contribution__validated=False),
~Q(compoundaction__ppi__contribution__contributor=current_user),
)
# add filters # add filters
self.filter_context[ self.filter_context[
"disabled" "disabled"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment