Source code for api.posts.exceptions
from django.conf import settings
from django.utils.translation import gettext_lazy as _
from rest_framework import status
from rest_framework.exceptions import APIException
[docs]
class AlreadyLikedPostAPIException(APIException):
"""Already liked post"""
status_code = 400
default_detail = _("You already liked this post")
default_code = "post_already_liked"
[docs]
class UserNotLikeThisPostAPIException(APIException):
"""User not like this post"""
status_code = 400
default_detail = _("You're not liked this post you can't unlike")
default_code = "not_liked_post"
[docs]
class TooManyCategoriesExceptionAPIException(APIException):
"""Post contains more categories than allowed by the limits."""
status_code = status.HTTP_400_BAD_REQUEST
default_detail = _("Post contains more categories than allowed by the limits.")
default_code = "too_many_categories"
[docs]
class CategoriesDontExistAPIException(APIException):
"""Selected categories for post are don't exist or unavailable"""
status_code = status.HTTP_400_BAD_REQUEST
default_detail = _("Selected categories for post are do not exist or unavailable")
default_code = "categories_dont_exist"
[docs]
class AlreadyAddedToFavoritesAPIException(APIException):
"""Already has post in favorites"""
status_code = 400
default_detail = _("You already added to favorites this post")
default_code = "post_already_added_to_favorites"
[docs]
class UserNotHasThisPostInFavoritesAPIException(APIException):
"""User not like this post"""
status_code = 400
default_detail = _("You're don't have this post in favorites, you can't remove it from that")
default_code = "post_in_not_in_favorites"