Skip to content

Commit

Permalink
Added gettext_lazy to user serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamín Mravec committed Nov 12, 2023
1 parent df3c6ca commit e73c7b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions competition/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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':
Expand All @@ -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':
Expand Down
5 changes: 3 additions & 2 deletions user/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit e73c7b6

Please sign in to comment.