hotfix for 0 division when there is an empty category in profile page
This commit is contained in:
parent
6337a0dcdb
commit
911c9f6732
|
@ -124,7 +124,8 @@ def profile(request, user_name):
|
||||||
member = True
|
member = True
|
||||||
else:
|
else:
|
||||||
member = False
|
member = False
|
||||||
cats = Category.objects.all()
|
all_cats = Category.objects.all()
|
||||||
|
cats = [cat for cat in all_cats if CTF.objects.filter(category__name=cat.name, event=None)]
|
||||||
pointDatas = {}
|
pointDatas = {}
|
||||||
|
|
||||||
for cat in cats:
|
for cat in cats:
|
||||||
|
@ -151,7 +152,7 @@ def profile(request, user_name):
|
||||||
solved.append([s.flag_date.timestamp() * 1000,somme])
|
solved.append([s.flag_date.timestamp() * 1000,somme])
|
||||||
|
|
||||||
return render(request,'accounts/profile.html', {'user':user_obj, 'solves':solves,'solved':solved,'catsDatas': catsDatas, 'pointDatas': pointDatas,
|
return render(request,'accounts/profile.html', {'user':user_obj, 'solves':solves,'solved':solved,'catsDatas': catsDatas, 'pointDatas': pointDatas,
|
||||||
'rank': rank, 'score' : somme, 'member' : member})
|
'rank': rank, 'score' : somme, 'member' : member, 'cats':cats})
|
||||||
|
|
||||||
def rank(request, token):
|
def rank(request, token):
|
||||||
all_users = UserProfileInfo.objects.filter(score__gt=0).select_related().order_by('-score', 'last_submission_date', 'user__username')
|
all_users = UserProfileInfo.objects.filter(score__gt=0).select_related().order_by('-score', 'last_submission_date', 'user__username')
|
||||||
|
|
Loading…
Reference in New Issue