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 TooManyLinkedMediaAPIException(APIException): """Post contains more media than allowed by the limits.""" status_code = status.HTTP_400_BAD_REQUEST default_detail = _("Post contains more media than allowed by the limits") default_code = "media_count"
[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 PostUnavailableForCommentingAPIException(APIException): """Selected categories for post are don't exist or unavailable""" status_code = status.HTTP_400_BAD_REQUEST default_detail = _("Post is unavailable for commenting") default_code = "post_unavailable_for_commenting"
[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"
[docs] class CommentLimitImageAPIException(APIException): """Comment limit exception""" status_code = 400 default_detail = _(f"Comment has limit on images. You can add maximum {settings.MAX_COMMENT_ITEMS}") default_code = "comment_image_limit"