Skip to content

Commit

Permalink
Changed some error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamín Mravec committed Nov 12, 2023
1 parent c98181e commit 8e4f571
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
22 changes: 11 additions & 11 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='Request neobsahoval súbor')
raise exceptions.ParseError(detail='Požiadávka neobsahovala súbor')
file = request.FILES['file']
if mime_type(file) != 'application/pdf':
raise exceptions.ParseError(
Expand Down Expand Up @@ -338,17 +338,17 @@ def upload_solutions_with_points(self, request, pk=None):
"""Nahrá .zip archív s opravenými riešeniami (pdf-kami)."""

if 'file' not in request.data:
raise exceptions.ParseError(detail='No file attached')
raise exceptions.ParseError(detail='Nie je priložený súbor')

zfile = request.data['file']

if not zipfile.is_zipfile(zfile):
raise exceptions.ParseError(
detail='Attached file is not a zip file')
detail='Priložený súbor nie je súbor s príponou zip.')

with zipfile.ZipFile(zfile) as zfile:
if zfile.testzip():
raise exceptions.ParseError(detail='Zip file is corrupted')
raise exceptions.ParseError(detail='Súbor zip je poškodený')

parsed_filenames = []
errors = []
Expand All @@ -367,20 +367,20 @@ def upload_solutions_with_points(self, request, pk=None):
except (IndexError, ValueError, AssertionError):
errors.append({
'filename': filename,
'status': 'Cannot parse file'
'status': 'Nie je možné analyzovať súbor'
})
continue
except EventRegistration.DoesNotExist:
errors.append({
'filename': filename,
'status': f'User registration with id {registration_pk} does not exist'
'status': f'Registrácia používateľa s id {registration_pk} neexistuje'
})
continue
except Solution.DoesNotExist:
errors.append({
'filename': filename,
'status': f'Solution with registration id {registration_pk}'
f'and problem id {problem_pk} does not exist'
'status': f'Riešenie s registračným id {registration_pk}'
f'a id úlohy {problem_pk} neexistuje'
})
continue

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='Request neobsahoval súbor')
raise exceptions.ParseError(detail='Požiadávka 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='Request neobsahoval súbor')
raise exceptions.ParseError(detail='Požiadávka neobsahovala súbor')

file = request.FILES['file']
if mime_type(file) != 'application/pdf':
Expand Down Expand Up @@ -830,7 +830,7 @@ def download_publication(self, request, pk=None):
def upload_publication(self, request):
"""Nahrá súbor publikácie"""
if 'file' not in request.data:
raise exceptions.ParseError(detail='Request neobsahoval súbor')
raise exceptions.ParseError(detail='Požiadavka neobsahovala súbor')

file = request.data['file']
if mime_type(file) not in ['application/pdf', 'application/zip']:
Expand Down
10 changes: 5 additions & 5 deletions user/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_auth_user(self, email, password):

def validate_auth_user_status(self, user):
if not user.is_active:
msg = 'User nie je aktívny'
msg = 'Používateľ nie je aktívny'
raise exceptions.ValidationError(msg)

def validate_email_verification_status(self, user):
Expand Down Expand Up @@ -177,7 +177,7 @@ def validate_email(self, email):
email = get_adapter().clean_email(email)
if email and EmailAddress.objects.filter(email__iexact=email).exists():
raise serializers.ValidationError(
"Entered email adress is already used! Please try again with another email adress.")
"Zadaná emailová adresa je už používaná. Prosíme skús vyskúsať inú emailovú adresu.")
return email

def validate_password1(self, password):
Expand All @@ -189,18 +189,18 @@ def validate_profile(self, profile):
'''
if not profile['gdpr']:
raise serializers.ValidationError(
'You have to confirm, that you are aware of the processing of personal data.')
'Musíš podvrdiť, že si si vedomý spracovania osobných údajov.')
return profile

def validate(self, attrs):
if attrs['password1'] != attrs['password2']:
raise serializers.ValidationError("Entered passwords do not match.")
raise serializers.ValidationError("Zadané heslá sa nezhodujú.")

# ak je zadana skola "ina skola", musi byt nejaky description skoly
if (attrs['profile']['school'].code == self.OTHER_SCHOOL_CODE and
len(attrs['new_school_description']) == 0):
raise serializers.ValidationError(
'You must enter a description of your school.')
'Musíš zadať popis tvojej školy.')

return attrs

Expand Down

0 comments on commit 8e4f571

Please sign in to comment.