Compare commits

..

18 Commits

Author SHA1 Message Date
Danhia 9ad64e72bc Merge pull request 'doc(tools): Broken link GEF' (#83) from Starthur/website:main into main
Reviewed-on: 42CTF/website#83
Reviewed-by: Danhia <danhia@protonmail.com>
2023-02-05 23:20:19 +01:00
Danhia 9d0a420cac Merge pull request 'Separate profile page for events' (#69) from Danhia/website:event/fix-chall-slug into main
Reviewed-on: 42CTF/website#69
Reviewed-by: Starthur <contact+42ctf@arthur-trt.fr>
2023-02-05 23:13:44 +01:00
Starthur 7120a80c1d
doc(tools): Broken link GEF 2023-02-01 18:41:53 +01:00
Starthur fe71460537 Merge branch 'main' into event/fix-chall-slug 2022-10-13 20:23:21 +02:00
Danhia 32bbc392d6 Merge pull request 'Facilitate access to the user's profile' (#82) from UncleReaton/website:main into main
Reviewed-on: 42CTF/website#82
Reviewed-by: Danhia <danhia@protonmail.com>
2022-10-10 21:03:09 +02:00
UncleReaton acf306097a Change user.userprofileinfo.user to user 2022-10-10 21:01:31 +02:00
UncleReaton dc955fc189 Add a button to view the user's profile by clicking on their score on the navbar 2022-10-10 20:37:11 +02:00
UncleReaton e304f7cd15 Add a button to view the user's profile from their edit page 2022-10-10 20:27:31 +02:00
Danhia 73cf94515d Merge pull request 'Added command to prune users who never logged in' (#80) from Danhia/website:management/prune-users into main
Well maybe it will remove all users from the db but we can't know until we try it, can we ?
2022-09-30 16:24:18 +02:00
Danhia 94237bd9b6 Added command to prune users who never logged in 2022-09-30 16:20:17 +02:00
Starthur a983aafba2 Merge pull request 'Repare search' (#79) from Starthur/website:main into main
Reviewed-on: 42CTF/website#79
2022-08-29 14:02:22 +02:00
Starthur cce09ed254
Repare search 2022-08-29 14:01:05 +02:00
Danhia c2e58c4f92 Merge pull request 'Fix logo size and position with some highly advanced CSS' (#78) from Danhia/website:scoreboard/fix-network into main
Reviewed-on: 42CTF/website#78
2022-08-27 11:38:16 +02:00
Danhia eba672d067 Merge branch 'main' into scoreboard/fix-network 2022-08-27 11:37:40 +02:00
Danhia 1a6c31f5e8 fix logo size and position with some highly advanced CSS 2022-08-27 11:36:07 +02:00
Danhia bd17ad5f8f Merge pull request 'Fix missing url in top3 network scoreboard' (#77) from Danhia/website:scoreboard/fix-network into main
Reviewed-on: 42CTF/website#77
2022-08-27 11:18:28 +02:00
Danhia 40984a2a0c fix missing url in top3 network scoreboard 2022-08-27 11:10:20 +02:00
Danhia 00acec6fdb separate profile page for events 2022-08-16 18:03:39 +02:00
9 changed files with 210 additions and 13 deletions

View File

@ -10,7 +10,7 @@ class userprofile(admin.ModelAdmin):
#list display #list display
list_display = ['user', 'score', 'last_submission_date', 'campus'] list_display = ['user', 'score', 'last_submission_date', 'campus']
# search list # search list
search_fields = ['score', 'user__username', 'campus'] search_fields = ['score', 'user__username', 'campus__name']
@admin.register(Campus) @admin.register(Campus)
class campus(admin.ModelAdmin): class campus(admin.ModelAdmin):

View File

@ -0,0 +1,24 @@
from collections import defaultdict
from django.core.management.base import BaseCommand, CommandError
from accounts import models as acc_models
from django.contrib.auth import models as auth_models
from django.contrib.auth.models import timezone
from datetime import timedelta
class Command(BaseCommand):
help = 'Remove all users who never logged in'
def handle(self, *args, **options):
all_users = acc_models.UserProfileInfo.objects.filter(score=0).select_related()
to_remove = []
for elem in all_users:
user = elem.user
if user.last_login is None and user.date_joined < timezone.now() - timedelta(hours=72):
to_remove.append(user)
print("You are going to remove {} users.".format(len(to_remove)))
answer = input("Continue ? [y/N] ")
if answer.lower() in ["y","yes"]:
for elem in to_remove:
elem.delete()
print("Users have been successfully pruned.")

View File

@ -92,6 +92,13 @@
{% endif %} {% endif %}
<li class="list-group-item">{% trans "Registered since" %} {{ user.date_joined|date:"Y-m-d" }}</li> <li class="list-group-item">{% trans "Registered since" %} {{ user.date_joined|date:"Y-m-d" }}</li>
</ul> </ul>
<ul class="list-group">
<form method='GET' action="{% url 'accounts:profile' user %}">
<li class="list-group-item">
<input class="form-control" type="submit" value="{% trans " View my profile" %}">
</li>
</form>
</ul>
<ul class="list-group"> <ul class="list-group">
<form method='GET' action="{% url 'accounts:delete_account' %}"> <form method='GET' action="{% url 'accounts:delete_account' %}">
{%csrf_token%} {%csrf_token%}

View File

@ -0,0 +1,166 @@
{% extends 'base.html' %}
{% block content %}
{% load i18n %}
{% load key_value %}
{% load is_member %}
{% ismember user.userprofileinfo as is_member %}
<div class="row">
<div class="col-sm-12 col-md-9">
<a href="{% url 'events:event_info' event_slug=event.slug %}">< Back to event</a>
<div>
<h4>{% trans "Challenges Solved by" %} <span class="{{ is_member }}">{{ user.username }} - {{ event.name }}</span></h4>
{% if solves%}
<div class="table table-dark">
<div class="card-body">
<div id="time-chart"></div>
</div>
</div>
<table class="table table-dark">
<thead>
<tr>
<th scope="col">{% trans "Challenge Name" %}</th>
<th scope="col">{% trans "Category" %}</th>
<th scope="col">{% trans "Points" %}</th>
<th scope="col">{% trans "Date" %}</th>
</tr>
</thead>
<tbody>
{% for s in solves %}
<tr>
<th scope="row"><a href="{% url 'events:event_chall_info' event_slug=event.slug chall_slug=s.ctf.slug %}">{{ s.ctf.name }}</a></th>
<td>{{ s.ctf.category.name}}</td>
<td>{{ s.ctf.points }}</td>
<td>{{ s.flag_date|date:"Y-m-d H:i:s" }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>{% trans "It seems that this user has not solved any challenge yet..." %}</p>
{% endif %}
</div>
</div>
<div class="d-none d-md-block col-10 col-md-3 right-sidebar">
<ul class="list-group">
<li class="list-group-item {{ is_member }}">{{ user.username }}</li>
<li class="list-group-item">{% trans "Score" %} : {{ score }}</li>
<li class="list-group-item">{% trans "Rank" %} : {{ rank }}</li>
{% if user.userprofileinfo.portfolio_site %}
<li class="list-group-item">
<a href="{{ user.userprofileinfo.portfolio_site }}" target="_blank">
{{ user.userprofileinfo.portfolio_site }}
</a>
</li>
{% endif %}
{% if member %}
<li class="list-group-item is-member">{% trans "Status: Member" %}</li>
{% else %}
<li class="list-group-item">{% trans "Status: Visitor" %}</li>
{% endif %}
<li class="list-group-item">{% trans "Registered since" %} {{ user.date_joined|date:"d-m-Y" }}</li>
</ul>
<ul class="list-group">
<li class="list-group-item">{% trans "Categories stats" %}</li>
{% for cat in catsDatas %}
<li class="list-group-item" style="padding-bottom: 3;padding-top: 0;">
<span>{{ cat.0 }}</span>
<div class="progress">
{% if cat.3 == '0' %}
<div class="progress-bar bg-success" role="progressbar" style="width: 0%;color:#d9d9d9;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0 %</div>
{% else %}
<div class="progress-bar bg-success" role="progressbar" style="width: {{ cat.3 }}%" aria-valuenow="{{ cat.3 }}" aria-valuemin="0" aria-valuemax="100">{{ cat.3 }} %</div>
{% endif %}
</div>
</li>
{% endfor %}
</ul>
<ul class="list-group">
<ul class="list-group">
<li class="list-group-item">{% trans "Challenges created" %}</li>
{% if created %}
{% for creat in created %}
<li class="list-group-item"><a href="{% url 'ctf' cat_slug=creat.category.slug ctf_slug=creat.slug %}">{{ creat.name }}</a></li>
{% endfor %}
{% else %}
<li class="list-group-item">{% trans "It seems that this user has not created any challenge yet..." %}</li>
{% endif %}
</ul>
</ul>
</div>
</div>
<script src="https://code.highcharts.com/highcharts.src.js"></script>
<script>
Highcharts.theme={colors:["#2b908f","#90ee7e","#f45b5b","#7798BF","#aaeeee","#ff0066","#eeaaee","#55BF3B","#DF5353","#7798BF","#aaeeee"],chart:{backgroundColor:{linearGradient:{x1:0,y1:0,x2:1,y2:1},stops:[[0,"#1D1D1D"],[1,"#1D1D1D"]]},style:{fontFamily:"'Unica One', sans-serif"},plotBorderColor:"#606063"},title:{style:{color:"#E0E0E3",textTransform:"uppercase",fontSize:"20px"}},subtitle:{style:{color:"#E0E0E3",textTransform:"uppercase"}},xAxis:{gridLineColor:"#707073",labels:{style:{color:"#E0E0E3"}},lineColor:"#707073",minorGridLineColor:"#505053",tickColor:"#707073",title:{style:{color:"#A0A0A3"}}},yAxis:{gridLineColor:"#707073",labels:{style:{color:"#E0E0E3"}},lineColor:"#707073",minorGridLineColor:"#505053",tickColor:"#707073",tickWidth:1,title:{style:{color:"#A0A0A3"}}},tooltip:{backgroundColor:"rgba(0, 0, 0, 0.85)",style:{color:"#F0F0F0"}},plotOptions:{series:{dataLabels:{color:"#F0F0F3",style:{fontSize:"13px"}},marker:{lineColor:"#333"}},boxplot:{fillColor:"#505053"},candlestick:{lineColor:"white"},errorbar:{color:"white"}},legend:{backgroundColor:"#1D1D1D",itemStyle:{color:"#E0E0E3"},itemHoverStyle:{color:"#FFF"},itemHiddenStyle:{color:"#606063"},title:{style:{color:"#C0C0C0"}}},credits:{style:{color:"#666"}},labels:{style:{color:"#707073"}},drilldown:{activeAxisLabelStyle:{color:"#F0F0F3"},activeDataLabelStyle:{color:"#F0F0F3"}},navigation:{buttonOptions:{symbolStroke:"#DDDDDD",theme:{fill:"#505053"}}},rangeSelector:{buttonTheme:{fill:"#505053",stroke:"#000000",style:{color:"#CCC"},states:{hover:{fill:"#707073",stroke:"#000000",style:{color:"white"}},select:{fill:"#000003",stroke:"#000000",style:{color:"white"}}}},inputBoxBorderColor:"#505053",inputStyle:{backgroundColor:"#333",color:"silver"},labelStyle:{color:"silver"}},navigator:{handles:{backgroundColor:"#666",borderColor:"#AAA"},outlineColor:"#CCC",maskFill:"rgba(255,255,255,0.1)",series:{color:"#7798BF",lineColor:"#A6C7ED"},xAxis:{gridLineColor:"#505053"}},scrollbar:{barBackgroundColor:"#808083",barBorderColor:"#808083",buttonArrowColor:"#CCC",buttonBackgroundColor:"#606063",buttonBorderColor:"#606063",rifleColor:"#FFF",trackBackgroundColor:"#404043",trackBorderColor:"#404043"}};
Highcharts.setOptions(Highcharts.theme);
Highcharts.chart('time-chart', {
title: {
text: 'Points earned for each category'
},
yAxis: {
title: {
text: 'Points earned'
}
},
xAxis: {
type: 'datetime',
labels: {
formatter: function() {
return Highcharts.dateFormat('%d.%b %Y',
this.value);
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
plotOptions: {
pointStart: {{ user.date_joined|timestamp_fromdate }},
series: {
label: {
connectorAllowed: false
},
allowPointSelect: true,
marker: {
enabled: true
}
}
},
series: [
{
name: 'Total',
data: {{ solved|safe }}
},
{% for cat in cats %}
{
name: '{{ cat.name }}',
data: {{ pointDatas|keyvalue:cat.name|safe }},
visible: false,
},
{% endfor %}
],
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
});
</script>
{% endblock %}

View File

@ -289,7 +289,7 @@ def profile(request, user_name, event_slug):
somme += s.ctf.points somme += s.ctf.points
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,'events/profile.html', {'user':user_obj, 'solves':solves,'solved':solved,'catsDatas': catsDatas, 'pointDatas': pointDatas,
'rank': rank, 'score' : somme, 'cats':cats}) 'rank': rank, 'score' : somme, 'cats':cats, 'event': event_info})

View File

@ -16,7 +16,7 @@
- <a href="https://cutter.re">cutter</a></br> - <a href="https://cutter.re">cutter</a></br>
- <a href="https://github.com/ReFirmLabs/binwalk">binwalk</a></br> - <a href="https://github.com/ReFirmLabs/binwalk">binwalk</a></br>
- <a href="https://rada.re">r2</a></br> - <a href="https://rada.re">r2</a></br>
- <a href="https://gef.readthedocs.io/en/master/">gdb/gef</a></br> - <a href="https://hugsy.github.io/gef/">gdb/gef</a></br>
- qemu-user</br> - qemu-user</br>
<br> <br>
{% trans "If you want to solve the challenges on your own machine, we recommend you to use a Linux operating system."%} {% trans "If you want to solve the challenges on your own machine, we recommend you to use a Linux operating system."%}

View File

@ -8,30 +8,30 @@
<div class="col-12"> <div class="col-12">
<div class="row justify-content-md-center justify-content-sm-center"> <div class="row justify-content-md-center justify-content-sm-center">
<div class="col-4 col-sm-3 col-md-2 podium podium-two text-center"> <div class="col-4 col-sm-3 col-md-2 podium podium-two text-center">
<img src="{{ top3.1.0.logo }}" alt="{{ top3.1.0 }}" width="100%"/> <img src="{{ top3.1.0.logo }}" alt="{{ top3.1.0 }}"/>
<h3>#2 :</h3> <h3>#2 :</h3>
<p> <p>
Score : {{ top3.1.1 }} Score : {{ top3.1.1 }}
<br> <br>
{{ top3.1.0 }} <a href="{% url 'scoreboard:campus' campus=top3.1.0 %}">{{ top3.1.0 }}</a>
</p> </p>
</div> </div>
<div class="col-4 col-sm-3 col-md-2 podium podium-one text-center"> <div class="col-4 col-sm-3 col-md-2 podium podium-one text-center">
<img src="{{ top3.0.0.logo }}" alt="{{ top3.0.0 }}" width="100%"/> <img src="{{ top3.0.0.logo }}" alt="{{ top3.0.0 }}"/>
<h3>#1 : </h3> <h3>#1 : </h3>
<p> <p>
Score : {{ top3.0.1 }} Score : {{ top3.0.1 }}
<br> <br>
{{ top3.0.0 }} <a href="{% url 'scoreboard:campus' campus=top3.0.0 %}">{{ top3.0.0 }}</a>
</p> </p>
</div> </div>
<div class="col-4 col-sm-3 col-md-2 podium podium-three text-center"> <div class="col-4 col-sm-3 col-md-2 podium podium-three text-center">
<img src="{{ top3.2.0.logo }}" alt="{{ top3.2.0 }}" width="100%"/> <img src="{{ top3.2.0.logo }}" alt="{{ top3.2.0 }}"/>
<h3>#3 : </h3> <h3>#3 : </h3>
<p> <p>
Score : {{ top3.2.1 }} Score : {{ top3.2.1 }}
<br> <br>
{{ top3.2.0 }} <a href="{% url 'scoreboard:campus' campus=top3.2.0 %}">{{ top3.2.0 }}</a>
</p> </p>
</div> </div>
</div> </div>

View File

@ -320,7 +320,7 @@ footer {
vertical-align: bottom; vertical-align: bottom;
} }
.podium h3 {margin-top:-5%;} .podium h3 {margin-top:-5%;}
.podium img{position:relative;top: -55px} .podium img{position:relative;top: -55px; max-height: 50px; max-width: 100%;}
.podium-one{ .podium-one{
background-color: #313131; background-color: #313131;
height: 25vh;} height: 25vh;}

View File

@ -95,7 +95,7 @@
<a href="{% url 'accounts:edit' %}" class="nav-link">{{ request.user.username }}</a> <a href="{% url 'accounts:edit' %}" class="nav-link">{{ request.user.username }}</a>
</li> </li>
<li class="nav-item dropdown"> <li class="nav-item dropdown">
<span class="nav-link">{{ request.user.userprofileinfo.score }}</span> <a class="nav-link" href="{% url 'accounts:profile' user %}">{{ request.user.userprofileinfo.score }}</a>
</li> </li>
<li class="nav-item dropdown"> <li class="nav-item dropdown">
<a class="nav-link" href="{% url 'accounts:out' %}">{% translate "Logout" %}</a> <a class="nav-link" href="{% url 'accounts:out' %}">{% translate "Logout" %}</a>