fixed error 500 when requesting german or russian translation
This commit is contained in:
parent
00962b40d3
commit
9b3ae741c1
|
@ -8,19 +8,6 @@ from django.utils.translation import get_language
|
||||||
from math import log
|
from math import log
|
||||||
from accounts.models import UserProfileInfo
|
from accounts.models import UserProfileInfo
|
||||||
|
|
||||||
def get_description_by_lang(ctf):
|
|
||||||
lang = get_language()
|
|
||||||
ret = None
|
|
||||||
if lang == "fr":
|
|
||||||
ret = ctf.description
|
|
||||||
elif lang == "en":
|
|
||||||
ret = ctf.description_en
|
|
||||||
elif lang == "de":
|
|
||||||
ret = ctf.description_de
|
|
||||||
elif lang == "ru":
|
|
||||||
ret = ctf.description_ru
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def actualize_points(ctf):
|
def actualize_points(ctf):
|
||||||
if ctf.category.name == "-Intro-":
|
if ctf.category.name == "-Intro-":
|
||||||
return
|
return
|
||||||
|
@ -50,7 +37,6 @@ def ctf(request, cat_slug, ctf_slug):
|
||||||
ctf_info = get_object_or_404(CTF, slug=ctf_slug, event=None)
|
ctf_info = get_object_or_404(CTF, slug=ctf_slug, event=None)
|
||||||
flagged = False
|
flagged = False
|
||||||
solved_list = CTF_flags.objects.filter(ctf=ctf_info).order_by('flag_date')
|
solved_list = CTF_flags.objects.filter(ctf=ctf_info).order_by('flag_date')
|
||||||
description = get_description_by_lang(ctf_info)
|
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
if CTF_flags.objects.filter(user=request.user, ctf=ctf_info):
|
if CTF_flags.objects.filter(user=request.user, ctf=ctf_info):
|
||||||
flagged = True
|
flagged = True
|
||||||
|
@ -66,12 +52,12 @@ def ctf(request, cat_slug, ctf_slug):
|
||||||
profil.score += ctf_info.points
|
profil.score += ctf_info.points
|
||||||
profil.save()
|
profil.save()
|
||||||
actualize_points(ctf_info)
|
actualize_points(ctf_info)
|
||||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'valitated': True, 'description': description, 'date': timezone.now()})
|
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'valitated': True, 'date': timezone.now()})
|
||||||
else:
|
else:
|
||||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'failed': True, 'description': description, 'date': timezone.now()})
|
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'failed': True, 'date': timezone.now()})
|
||||||
else:
|
else:
|
||||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': True, 'description': description, 'date': timezone.now()})
|
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': True, 'date': timezone.now()})
|
||||||
else:
|
else:
|
||||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'description': description, 'date': timezone.now()})
|
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'date': timezone.now()})
|
||||||
else:
|
else:
|
||||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': flagged, 'description': description, 'date': timezone.now()})
|
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': flagged, 'date': timezone.now()})
|
||||||
|
|
Loading…
Reference in New Issue