@@ -0,0 +1,6 @@ +from django.utils.translation import gettext as _ + + +class AlreadyConfirmed(Exception): + def __str__(self): + return _('User is already confirmed') @@ -8,6 +8,7 @@ from django.db.transaction import atomic from django.utils.translation import gettext_lazy as _ from rest_framework.request import Request +from authentication.exceptions.business_host_exceptions.already_confirmed import AlreadyConfirmed from authentication.exceptions.business_host_exceptions.not_allowed_ip import ( NotAllowedIP, ) @@ -185,9 +186,14 @@ class UserService: raise EmailTokenNotFound user = token.user - if not user.is_confirmed: - user.is_confirmed = True - user.save() + try: + if user.is_confirmed: + raise AlreadyConfirmed + else: + user.is_confirmed = True + user.save() + finally: + token.delete() @classmethod def request_password_change(cls, request: Request): @@ -37,6 +37,7 @@ from authentication.exceptions.business_account import ( BusinessAccountNotFound, UnconfirmedUserChangePass, ) +from authentication.exceptions.business_host_exceptions.already_confirmed import AlreadyConfirmed from authentication.exceptions.business_host_exceptions.not_allowed_ip import ( NotAllowedIP, ) @@ -481,7 +482,7 @@ class ConfirmUserAPIView(APIView): try: UserService.confirm_user(request) return Response({'detail': 'user confirmed'}, status=status.HTTP_200_OK) - except EmailTokenNotFound as exc: + except (EmailTokenNotFound, AlreadyConfirmed) as exc: return Response({'detail': f'{exc}'}, status=status.HTTP_400_BAD_REQUEST) except Exception as exc: logger.exception(exc) @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-05-06 17:58+0300\n" +"POT-Creation-Date: 2026-05-08 12:06+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -68,6 +68,10 @@ msgstr "У вас недостаточно прав для выполнения msgid "User is already a business account for another company" msgstr "Пользователь уже является сотрудником другой компании" +#: authentication/exceptions/business_host_exceptions/already_confirmed.py:6 +msgid "User is already confirmed" +msgstr "Аккаунт уже подтвержден" + #: authentication/exceptions/business_host_exceptions/already_has_plan.py:7 msgid "" "You already have an active tariff plan. You must request a cancellation of " @@ -557,23 +561,23 @@ msgstr "Приглашенный аккаунт может принять или msgid "Error occured when proceed email sending" msgstr "Случилась ошибка во время отправки email" -#: authentication/services/user_services.py:164 +#: authentication/services/user_services.py:165 msgid "No user like this in a database" msgstr "Такой пользователь отсутствует" -#: authentication/services/user_services.py:181 +#: authentication/services/user_services.py:182 msgid "token is not provided" msgstr "" -#: authentication/services/user_services.py:205 +#: authentication/services/user_services.py:211 msgid "No email token provided" msgstr "Токен не получен" -#: authentication/services/user_services.py:215 +#: authentication/services/user_services.py:221 msgid "Passwords do not match" msgstr "Пароли не совпадают" -#: authentication/services/user_services.py:253 +#: authentication/services/user_services.py:259 msgid "Current password is wrong" msgstr "Текущий пароль неверен" @@ -1047,7 +1051,7 @@ msgstr "Соответствующая версия не найдена" msgid "Image is ready" msgstr "Изображение готово" -#: ml_model/services/elevenlabs_music.py:46 +#: ml_model/services/elevenlabs_music.py:45 msgid "Duration cannot be less than 5 seconds" msgstr "Длительность не может быть меньше 5 секунд" @@ -1065,11 +1069,6 @@ msgstr "" "Режим «Плавное движение» доступен только для 5-секундных видео в качестве " "540p и 720p" -#: ml_model/services/minimaxmusic.py:58 -#: ml_model/services/minimaxmusic_lite.py:62 -msgid "Lyrics is too long" -msgstr "Текст песни слишком длинный" - #: ml_model/services/minio_service.py:37 ml_model/services/minio_service.py:55 #: ml_model/services/minio_service.py:63 ml_model/services/minio_service.py:72 msgid "Unknown bucket destination" @@ -1079,6 +1078,10 @@ msgstr "Неизвестный бакет для загрузки" msgid "No image given for improving" msgstr "Нет изображения для улучшения" +#: ml_model/tasks.py:136 +msgid "Lyrics is too long" +msgstr "Текст песни слишком длинный" + #: ml_model/views.py:65 msgid "Model data cannot be retrieved" msgstr "Невозможно получить данные модели" @@ -1616,9 +1619,6 @@ msgstr "Пресеты общие для всех — их нельзя удал #~ msgid "Issued achievement" #~ msgstr "Выданное достижение" -#~ msgid "Account is already confirmed" -#~ msgstr "Аккаунт уже подтвержден" - #~ msgid "Stories" #~ msgstr "Истории"