diff --git a/src/accounts/templates/accounts/profile.html b/src/accounts/templates/accounts/profile.html index c80fe1f..fa00efd 100644 --- a/src/accounts/templates/accounts/profile.html +++ b/src/accounts/templates/accounts/profile.html @@ -5,9 +5,15 @@

Challenges Solved by {{ user.username }}

- {% if solves%} - - + {% if solves%} + +
+
+ +
+
+
+ @@ -44,7 +50,79 @@ {% endif %}
  • {% trans "Member since" %} {{ user.date_joined|date:"Y-m-d" }}
  • + + + + + {% endblock %} diff --git a/src/accounts/views/views.py b/src/accounts/views/views.py index a791f7b..c6f04b4 100644 --- a/src/accounts/views/views.py +++ b/src/accounts/views/views.py @@ -2,7 +2,7 @@ from django.shortcuts import render, redirect, get_object_or_404 from django.utils.translation import gettext_lazy as _ from django import forms -from ctfs.models import CTF_flags +from ctfs.models import Category, CTF_flags from ..forms import UserForm,UserProfileInfoForm, UserInfosUpdateForm, UserUpdateForm from django.contrib.auth import authenticate, login, logout from django.contrib.auth.models import User @@ -113,9 +113,26 @@ def edit(request): @login_required def profile(request, user_name): + globalLabels= [] + globalDatas = [] + timeLabels = [] + timeDatas= [] + user_obj = get_object_or_404(User, username=user_name) + cats = Category.objects.all() + for cat in cats: + globalLabels.append(cat.name) + solved_count = CTF_flags.objects.filter(user=user_obj, ctf__category__name=cat).order_by('-flag_date').count() + globalDatas.append(solved_count) + + solves = CTF_flags.objects.filter(user=user_obj).order_by('flag_date') + somme = 0 + for flag in solves: + timeLabels.append(flag.flag_date.strftime('%Y-%m-%d')) + somme += flag.ctf.points + timeDatas.append(somme) solves = CTF_flags.objects.filter(user=user_obj).order_by('-flag_date') - return render(request,'accounts/profile.html', {'user':user_obj, 'solves':solves}) + return render(request,'accounts/profile.html', {'user':user_obj, 'solves':solves,'globalLabels': globalLabels, 'globalDatas': globalDatas, 'timeLabels': timeLabels, 'timeDatas': timeDatas}) # Create your views here. def rank(request, token): diff --git a/src/static/css/style.css b/src/static/css/style.css index 6c2877a..5ba7b0a 100644 --- a/src/static/css/style.css +++ b/src/static/css/style.css @@ -17,7 +17,7 @@ pre {background-color: #000; color: #cecece; padding-left: 15px; font-weight: bo .dropdown-item:hover {background-color: #1D1D1D; color: #FFFFFF} .flag_link {margin-right: 6px} -.flag_img {margin-top: 10px;width: 28px;border-radius: 100%;} +.flag_img {margin-top: 10px;width: 28px;} .table-dark {background-color: #1D1D1D} .table-dark td, .table-dark th, .table-dark thead th {border: none} diff --git a/src/statics/css/style.css b/src/statics/css/style.css index 6c2877a..5ba7b0a 100644 --- a/src/statics/css/style.css +++ b/src/statics/css/style.css @@ -17,7 +17,7 @@ pre {background-color: #000; color: #cecece; padding-left: 15px; font-weight: bo .dropdown-item:hover {background-color: #1D1D1D; color: #FFFFFF} .flag_link {margin-right: 6px} -.flag_img {margin-top: 10px;width: 28px;border-radius: 100%;} +.flag_img {margin-top: 10px;width: 28px;} .table-dark {background-color: #1D1D1D} .table-dark td, .table-dark th, .table-dark thead th {border: none} diff --git a/src/templates/base.html b/src/templates/base.html index b9b5012..2db024b 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -106,6 +106,7 @@ +
    {% trans "Challenge Name" %} {% trans "Category" %}