hotfix for 0 division when there is an empty category in profile page

This commit is contained in:
Danhia 2022-02-02 19:34:22 +01:00
parent 6337a0dcdb
commit 911c9f6732
1 changed files with 3 additions and 2 deletions

View File

@ -124,7 +124,8 @@ def profile(request, user_name):
member = True
else:
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 = {}
for cat in cats:
@ -151,7 +152,7 @@ def profile(request, user_name):
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,
'rank': rank, 'score' : somme, 'member' : member})
'rank': rank, 'score' : somme, 'member' : member, 'cats':cats})
def rank(request, token):
all_users = UserProfileInfo.objects.filter(score__gt=0).select_related().order_by('-score', 'last_submission_date', 'user__username')