Skip to content

Commit

Permalink
Updating new views
Browse files Browse the repository at this point in the history
  • Loading branch information
rosiejeays committed Sep 15, 2023
1 parent a9d0fc3 commit f23ecd8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions crowdfunding/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,19 @@ def delete(self,request,pk):

class UserProjectView(APIView):
def get(self,request):
projects = Project.objects.all().filter(is_deleted=False,owner=request.user)
serializer = ProjectSerializer(projects, many=True)
return Response(serializer.data)
if request.user.is_authenticated:
projects = Project.objects.all().filter(is_deleted=False,owner=request.user)
serializer = ProjectSerializer(projects, many=True)
return Response(serializer.data)
else:
return Response({ "detail": "No projects to view." })

class UserPledgeView(APIView):
def get(self,request):
pledges = Pledge.objects.all().filter(is_deleted=False,supporter=request.user)
serializer = PledgeSerializer(pledges,many=True)
return Response(serializer.data)
if request.user.is_authenticated:
pledges = Pledge.objects.all().filter(is_deleted=False,supporter=request.user)
serializer = PledgeSerializer(pledges,many=True)
return Response(serializer.data)
else:
return Response({ "detail": "No pledges to view." })

0 comments on commit f23ecd8

Please sign in to comment.