Added posts creation and posts detail

This commit is contained in:
ITQ
2024-03-04 16:37:16 +03:00
parent 12bda5d3da
commit 4946122f2e
12 changed files with 180 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
from rest_framework import status
from rest_framework.permissions import BasePermission
class CanAccessPost(BasePermission):
message = "You do not have permission to access this post."
status_code = status.HTTP_404_NOT_FOUND
def has_object_permission(self, request, view, obj):
if (
obj.author.isPublic
or obj.author.check_for_friendship(request.user)
or obj.author == request.user
):
return True
return False