Skip to content

Commit 82658ad

Browse files
committed
Merge branch 'dev'
2 parents cb24b7c + 40cbebd commit 82658ad

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

projects/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
urlpatterns = [
1717
path("", ProjectList.as_view()),
18-
path("<int:pk>/collaborators", ProjectCollaborators.as_view()),
18+
path("<int:pk>/collaborators/", ProjectCollaborators.as_view()),
1919
path("<int:pk>/", ProjectDetail.as_view()),
2020
path("count/", ProjectCountView.as_view()),
2121
path("steps/", ProjectSteps.as_view()),

projects/views.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from rest_framework import generics, permissions, status
33
from rest_framework.response import Response
44
from rest_framework.views import APIView
5-
5+
from django.db.models import Q
66
from core.permissions import IsStaffOrReadOnly
77
from projects.filters import ProjectFilter
88
from projects.helpers import VERBOSE_STEPS
@@ -98,13 +98,15 @@ class ProjectCountView(generics.GenericAPIView):
9898
serializer_class = ProjectListSerializer
9999
# TODO: using this permission could result in a user not having verified email
100100
# creating a project; probably should make IsUserVerifiedOrReadOnly
101-
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
101+
permission_classes = [permissions.IsAuthenticated]
102102

103103
def get(self, request):
104104
return Response(
105105
{
106106
"all": self.get_queryset().filter(draft=False).count(),
107-
"my": self.get_queryset().filter(leader_id=request.user.id).count(),
107+
"my": self.get_queryset()
108+
.filter(Q(leader_id=request.user.id) | Q(collaborator__user=request.user))
109+
.count(),
108110
},
109111
status=status.HTTP_200_OK,
110112
)

0 commit comments

Comments
 (0)