Compare commits
No commits in common. "06593b26f9bc5655dd50c4306bd5e4608d988a18" and "8f32ef9a6e3dfbd594d007e7a2a3e6c06f8d443d" have entirely different histories.
06593b26f9
...
8f32ef9a6e
|
@ -16,6 +16,7 @@ from secrets import token_hex
|
|||
from accounts.models import UserProfileInfo
|
||||
|
||||
from django.contrib.auth.models import timezone
|
||||
import os
|
||||
|
||||
from . import connection
|
||||
|
||||
|
@ -154,7 +155,6 @@ def profile(request, user_name):
|
|||
|
||||
return render(request,'accounts/profile.html', {'user':user_obj, 'solves':solves,'solved':solved,'catsDatas': catsDatas, 'pointDatas': pointDatas,
|
||||
'rank': rank, 'score' : somme, 'member' : member, 'cats':cats})
|
||||
<<<<<<< HEAD
|
||||
|
||||
@login_required
|
||||
def delete_account(request):
|
||||
|
@ -182,4 +182,4 @@ def rank(request, token):
|
|||
break
|
||||
rank += 1
|
||||
data = {"rank": rank}
|
||||
return JsonResponse(data)
|
||||
return JsonResponse(data)
|
|
@ -8,6 +8,19 @@ from django.utils.translation import get_language
|
|||
from math import log
|
||||
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):
|
||||
if ctf.category.name == "-Intro-":
|
||||
return
|
||||
|
@ -37,6 +50,7 @@ def ctf(request, cat_slug, ctf_slug):
|
|||
ctf_info = get_object_or_404(CTF, slug=ctf_slug, event=None)
|
||||
flagged = False
|
||||
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 CTF_flags.objects.filter(user=request.user, ctf=ctf_info):
|
||||
flagged = True
|
||||
|
@ -52,12 +66,12 @@ def ctf(request, cat_slug, ctf_slug):
|
|||
profil.score += ctf_info.points
|
||||
profil.save()
|
||||
actualize_points(ctf_info)
|
||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'valitated': True, 'date': timezone.now()})
|
||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'valitated': True, 'description': description, 'date': timezone.now()})
|
||||
else:
|
||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'failed': True, 'date': timezone.now()})
|
||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'failed': True, 'description': description, 'date': timezone.now()})
|
||||
else:
|
||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': True, 'date': timezone.now()})
|
||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': True, 'description': description, 'date': timezone.now()})
|
||||
else:
|
||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'date': timezone.now()})
|
||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'description': description, 'date': timezone.now()})
|
||||
else:
|
||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': flagged, 'date': timezone.now()})
|
||||
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': flagged, 'description': description, 'date': timezone.now()})
|
||||
|
|
Loading…
Reference in New Issue