DEV-446 Delete Stuff Post Handler & DEV-445 Create Stuff Post Handler#73
DEV-446 Delete Stuff Post Handler & DEV-445 Create Stuff Post Handler#73ZhaoSongZh7 wants to merge 3 commits intopreviewfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| @@ -1,4 +1,4 @@ | |||
| .controls { | |||
| an.controls { | |||
There was a problem hiding this comment.
can we put this file back lol
| {"error": "You already have a post."}, | ||
| status=status.HTTP_400_BAD_REQUEST | ||
| ) | ||
| StuffPost.objects.create(author=user, title=request.data.get("title"), description=request.data.get("description"), thumbnail_url=request.data.get("thumbnail_url"), category=request.data.get("category"), link_url=request.data.get("link_url"), tags=request.data.get("tags"), has_sent=False, created_at=timezone.now()) |
There was a problem hiding this comment.
Can we turn this into a Model Serializer for StuffPost? It can go at the top of this file. It should be similar to the EventSerializer in the calendar repo. author should be a read_only field. The author info can be injected in after.
| StuffPost.objects.filter(author=user).delete(); | ||
| return Response({"Status": "OK"}, status=status.HTTP_200_OK) | ||
| except StuffPost.DoesNotExist: | ||
| logger.error(f"Stuff post not found for user {user.email}") |
There was a problem hiding this comment.
don't forget to initialize the logger at the top
| ) | ||
| StuffPost.objects.create(author=user, title=request.data.get("title"), description=request.data.get("description"), thumbnail_url=request.data.get("thumbnail_url"), category=request.data.get("category"), link_url=request.data.get("link_url"), tags=request.data.get("tags"), has_sent=False, created_at=timezone.now()) | ||
| return Response({"status": "OK", "message": "Post made successfully"}, status=status.HTTP_200_OK) | ||
| except ValidationError as e: |
There was a problem hiding this comment.
we can make this similar to the except clause in your delete handler.
|
|
||
| return Response({"status": "OK", "message": "Stuff posts retrieved successfully"}, status=status.HTTP_200_OK) | ||
|
|
||
| def post(self, request) -> Response: |
There was a problem hiding this comment.
can we add logging to this handler too?
jfmath04
left a comment
There was a problem hiding this comment.
Left some comments for review!
References
Proposed Changes