Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translated registration error messages #261

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion competition/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def change_text(self, new_text):
if self.state != CommentPublishState.PUBLISHED:
self.text = new_text
else:
raise ValueError('Published comment can not be changed')
raise ValueError('Publikovaný komentár nemôže byť zmenený')

def can_user_modify(self, user):
return self.problem.can_user_modify(user)
Expand Down
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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dĺžeň

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
5 changes: 3 additions & 2 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,8 @@ def validate_email(self, email):
email = get_adapter().clean_email(email)
if email and EmailAddress.objects.filter(email__iexact=email).exists():
raise serializers.ValidationError(
"Používateľ s danou emailovou adresou už existuje.")
"Zadaná emailová adresa je už používaná." +
"Prosíme skús vyskúsať inú emailovú adresu.")
return email

def validate_password1(self, password):
Expand Down
Loading