From e73c7b6b050364846504a6e79368093ebe1cca44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjam=C3=ADn=20Mravec?= Date: Sun, 12 Nov 2023 15:33:23 +0100 Subject: [PATCH] Added gettext_lazy to user serializer --- competition/views.py | 6 +++--- user/serializers.py | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/competition/views.py b/competition/views.py index ea1cf4a9..8a9f8a13 100644 --- a/competition/views.py +++ b/competition/views.py @@ -266,7 +266,7 @@ def upload_model_solution(self, request, pk=None): """Nahrá užívateľské riešenie k úlohe""" problem: Problem = self.get_object() if 'file' not in request.FILES: - raise exceptions.ParseError(detail='Požiadávka neobsahovala súbor') + raise exceptions.ParseError(detail='Požiadavka neobsahovala súbor') file = request.FILES['file'] if mime_type(file) != 'application/pdf': raise exceptions.ParseError( @@ -518,7 +518,7 @@ def file_corrected(self, request, pk=None): def upload_solution_file(self, request, pk=None): solution: Solution = self.get_object() if 'file' not in request.FILES: - raise exceptions.ParseError(detail='Požiadávka neobsahovala súbor') + raise exceptions.ParseError(detail='Požiadavka neobsahovala súbor') file = request.FILES['file'] if mime_type(file) != 'application/pdf': @@ -535,7 +535,7 @@ def upload_solution_file(self, request, pk=None): def upload_corrected_solution_file(self, request, pk=None): solution: Solution = self.get_object() if 'file' not in request.FILES: - raise exceptions.ParseError(detail='Požiadávka neobsahovala súbor') + raise exceptions.ParseError(detail='Požiadavka neobsahovala súbor') file = request.FILES['file'] if mime_type(file) != 'application/pdf': diff --git a/user/serializers.py b/user/serializers.py index fce7e12a..51b2076c 100644 --- a/user/serializers.py +++ b/user/serializers.py @@ -5,6 +5,7 @@ from django.core.mail import send_mail from django.template.loader import render_to_string from django_typomatic import ts_interface +from django.utils.translation import gettext_lazy from rest_framework import exceptions, serializers from competition.models import Grade @@ -176,9 +177,9 @@ class Meta: def validate_email(self, email): email = get_adapter().clean_email(email) if email and EmailAddress.objects.filter(email__iexact=email).exists(): - raise serializers.ValidationError( - "Zadaná emailová adresa je už používaná." + + text = gettext_lazy("Zadaná emailová adresa je už používaná." + "Prosíme skús vyskúsať inú emailovú adresu.") + raise serializers.ValidationError(text) return email def validate_password1(self, password):