Skip to content

Commit

Permalink
rename route
Browse files Browse the repository at this point in the history
  • Loading branch information
ajatprabha committed Oct 19, 2018
1 parent 8dcaf84 commit 4a58598
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/project/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from account.api.permissions import IsApprovedMentor, IsStudent
from project.api.serializers import ProjectSerializer, StudentProposalSerializer, StudentProposalApproveSerializer
from project.models import StudentProposal, Project
# from account.models import StudentProfile


class ProjectViewSet(ModelViewSet):
Expand All @@ -19,12 +18,12 @@ def get_permissions(self):
"""
Instantiates and returns the list of permissions that this view requires.
"""
if self.action in ['retrieve', 'list', 'all_students']:
if self.action in ['retrieve', 'list', 'proposals']:
self.permission_classes = [AllowAny]
return super().get_permissions()

@action(methods=['get'], detail=True)
def all_students(self, request, pk=None):
def all_proposals(self, request, pk=None):
proposals = get_object_or_404(Project, pk=pk).studentproposal_set.all()
serializer = StudentProposalSerializer(proposals, many=True)
return Response(serializer.data, status=status.HTTP_200_OK)
Expand All @@ -35,14 +34,6 @@ class StudentProposalViewSet(ModelViewSet):
queryset = StudentProposal.objects.all()
permission_classes = (IsStudent,)

# def create(self, request, *args, **kwargs):
# serializer = self.get_serializer(data=request.data)
# serializer.is_valid(raise_exception=True)
# serializer.instance.student = StudentProfile.objects.get(user=self.request.user)
# self.perform_create(serializer)
# headers = self.get_success_headers(serializer.data)
# return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)

def get_permissions(self):
if self.action in ['retrieve', 'list']:
self.permission_classes = (IsStudent,)
Expand Down

0 comments on commit 4a58598

Please sign in to comment.