1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 14:54:22 +00:00

🐛 Fix private projects not being returned for the group owner

This commit is contained in:
Steffo 2021-10-14 03:27:15 +02:00
parent b8c9ee7a48
commit 8b08e08282

View file

@ -4,7 +4,6 @@ from django.db.models import Q
from sophon.core.models import ResearchGroup from sophon.core.models import ResearchGroup
from sophon.core.views import SophonGroupViewSet from sophon.core.views import SophonGroupViewSet
from . import models from . import models
@ -25,7 +24,8 @@ class ResearchProjectsByGroupViewSet(ResearchProjectViewSet):
Q(group__slug=self.kwargs["group_slug"]) & ( Q(group__slug=self.kwargs["group_slug"]) & (
Q(visibility="PUBLIC") | Q(visibility="PUBLIC") |
Q(visibility="INTERNAL") | Q(visibility="INTERNAL") |
Q(visibility="PRIVATE", group__members__in=[self.request.user]) Q(visibility="PRIVATE", group__members__in=[self.request.user]) |
Q(visibility="PRIVATE", group__owner=self.request.user)
) )
) )
@ -40,5 +40,6 @@ class ResearchProjectsBySlugViewSet(ResearchProjectViewSet):
return models.ResearchProject.objects.filter( return models.ResearchProject.objects.filter(
Q(visibility="PUBLIC") | Q(visibility="PUBLIC") |
Q(visibility="INTERNAL") | Q(visibility="INTERNAL") |
Q(visibility="PRIVATE", group__members__in=[self.request.user]) Q(visibility="PRIVATE", group__members__in=[self.request.user]) |
Q(visibility="PRIVATE", group__owner=self.request.user)
) )