events added, need to smooth html and css
This commit is contained in:
parent
0f231a4988
commit
06dc8188a0
|
@ -1,5 +1,12 @@
|
||||||
from .models import UserProfileInfo
|
from .models import UserProfileInfo
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
admin.site.register(UserProfileInfo)
|
#admin.site.register(UserProfileInfo)
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
|
||||||
|
@admin.register(UserProfileInfo)
|
||||||
|
class userprofile(admin.ModelAdmin):
|
||||||
|
#list display
|
||||||
|
list_display = ['user', 'score', 'last_submission_date']
|
||||||
|
# search list
|
||||||
|
search_fields = ['score', 'user__username']
|
|
@ -121,11 +121,11 @@ def profile(request, user_name):
|
||||||
|
|
||||||
for cat in cats:
|
for cat in cats:
|
||||||
# prepare categories
|
# prepare categories
|
||||||
solved_count = CTF_flags.objects.filter(user=user_obj, ctf__category__name=cat.name).count()
|
solved_count = CTF_flags.objects.filter(user=user_obj, ctf__event=None , ctf__category__name=cat.name).count()
|
||||||
max_count = CTF.objects.filter(category__name=cat.name).count()
|
max_count = CTF.objects.filter(category__name=cat.name, event=None).count()
|
||||||
# get datas
|
# get datas
|
||||||
somme = 0
|
somme = 0
|
||||||
solved = CTF_flags.objects.filter(user=user_obj, ctf__category__name=cat.name).order_by('flag_date')
|
solved = CTF_flags.objects.filter(user=user_obj, ctf__category__name=cat.name, ctf__event=None).order_by('flag_date')
|
||||||
pointDatas[cat.name] = []
|
pointDatas[cat.name] = []
|
||||||
pointDatas[cat.name].append([user_obj.date_joined.timestamp() * 1000, 0])
|
pointDatas[cat.name].append([user_obj.date_joined.timestamp() * 1000, 0])
|
||||||
percent = (solved_count / max_count) * 100
|
percent = (solved_count / max_count) * 100
|
||||||
|
@ -134,7 +134,7 @@ def profile(request, user_name):
|
||||||
somme += flag.ctf.points
|
somme += flag.ctf.points
|
||||||
pointDatas[cat.name].append([flag.flag_date.timestamp() * 1000, somme])
|
pointDatas[cat.name].append([flag.flag_date.timestamp() * 1000, somme])
|
||||||
|
|
||||||
solves = CTF_flags.objects.filter(user=user_obj).order_by('-flag_date')
|
solves = CTF_flags.objects.filter(user=user_obj, ctf__event=None).order_by('-flag_date')
|
||||||
solved = []
|
solved = []
|
||||||
somme = 0
|
somme = 0
|
||||||
solved.append([user_obj.date_joined.timestamp() * 1000, 0])
|
solved.append([user_obj.date_joined.timestamp() * 1000, 0])
|
||||||
|
|
|
@ -2,7 +2,24 @@ from django.contrib import admin
|
||||||
from .models import Category, CTF, CTF_flags
|
from .models import Category, CTF, CTF_flags
|
||||||
|
|
||||||
admin.site.register(Category)
|
admin.site.register(Category)
|
||||||
admin.site.register(CTF)
|
#admin.site.register(CTF)
|
||||||
admin.site.register(CTF_flags)
|
#admin.site.register(CTF_flags)
|
||||||
|
|
||||||
|
@admin.register(CTF_flags)
|
||||||
|
class ctf_flags(admin.ModelAdmin):
|
||||||
|
#list display
|
||||||
|
list_display = ['user', 'ctf', 'flag_date']
|
||||||
|
#list Filter
|
||||||
|
list_filter = ('ctf__category', 'ctf', 'user','flag_date')
|
||||||
|
# search list
|
||||||
|
search_fields = ['ctf__category__name', 'ctf__name', 'user__username']
|
||||||
|
|
||||||
|
@admin.register(CTF)
|
||||||
|
class ctf(admin.ModelAdmin):
|
||||||
|
#list display
|
||||||
|
list_display = ['name', 'event', 'category']
|
||||||
|
#list Filter
|
||||||
|
list_filter = ('category', 'event')
|
||||||
|
# search list
|
||||||
|
search_fields = ['category__name', 'name', 'author__username']
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 3.2.7 on 2021-10-18 14:23
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('events', '0001_initial'),
|
||||||
|
('ctfs', '0004_auto_20210907_1407'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='ctf',
|
||||||
|
name='event',
|
||||||
|
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='events.event'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 3.2.7 on 2021-10-19 15:03
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('events', '0002_alter_event_password'),
|
||||||
|
('ctfs', '0005_ctf_event'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='ctf',
|
||||||
|
name='event',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='events.event'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,5 +1,6 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from events.models import Event
|
||||||
|
|
||||||
class Category(models.Model):
|
class Category(models.Model):
|
||||||
name = models.CharField(max_length=200)
|
name = models.CharField(max_length=200)
|
||||||
|
@ -17,6 +18,7 @@ class CTF(models.Model):
|
||||||
description_de = models.TextField(blank=True)
|
description_de = models.TextField(blank=True)
|
||||||
file = models.FileField(blank=True, upload_to='challenges')
|
file = models.FileField(blank=True, upload_to='challenges')
|
||||||
ctf_url = models.URLField(blank=True)
|
ctf_url = models.URLField(blank=True)
|
||||||
|
event = models.ForeignKey(Event, null=True, blank=True, on_delete=models.CASCADE)
|
||||||
points = models.PositiveSmallIntegerField()
|
points = models.PositiveSmallIntegerField()
|
||||||
slug = models.SlugField(max_length=55)
|
slug = models.SlugField(max_length=55)
|
||||||
pub_date = models.DateTimeField('Date published')
|
pub_date = models.DateTimeField('Date published')
|
||||||
|
|
|
@ -6,79 +6,79 @@
|
||||||
<div class="ctf-block">
|
<div class="ctf-block">
|
||||||
<div class="ctf-head">
|
<div class="ctf-head">
|
||||||
<h3>{{ ctf.name }}</h3>
|
<h3>{{ ctf.name }}</h3>
|
||||||
<small>{% trans "Published date" %} : {{ ctf.pub_date }}</small>
|
<small>{% trans "Published date" %} : {{ ctf.pub_date }}</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="ctf-body">
|
<div class="ctf-body">
|
||||||
{% if description %}
|
{% if description %}
|
||||||
{{ description|safe }}
|
{{ description|safe }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% trans "No translation available. Please try another language (English or French)." %}
|
{% trans "No translation available. Please try another language (English or French)." %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="ctf-footer">
|
<div class="ctf-footer">
|
||||||
{% if request.user.is_authenticated %}
|
{% if request.user.is_authenticated %}
|
||||||
{% if valitated == True %}
|
{% if valitated == True %}
|
||||||
<p>{% trans "Congratulation !" %}</p>
|
<p>{% trans "Congratulation !" %}</p>
|
||||||
{% elif alvalitated == True %}
|
{% elif alvalitated == True %}
|
||||||
<p>{% trans "Already flagged" %}</p>
|
<p>{% trans "Already flagged" %}</p>
|
||||||
{% if ctf.ctf_url %}
|
{% if ctf.ctf_url %}
|
||||||
<a class="begin-ctf-link" target="_blank" href="{{ ctf.ctf_url }}">{% trans "Start the challenge" %}</a></br>
|
<a class="begin-ctf-link" target="_blank" href="{{ ctf.ctf_url }}">{% trans "Start the challenge" %}</a></br>
|
||||||
{% elif ctf.file %}
|
{% elif ctf.file %}
|
||||||
<a class="begin-ctf-link" target="_blank" href="{{ ctf.file.url }}">{% trans "Download" %}</a></br>
|
<a class="begin-ctf-link" target="_blank" href="{{ ctf.file.url }}">{% trans "Download" %}</a></br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if failed %}
|
{% if failed %}
|
||||||
<p>{% trans "Wrong flag ! You can do it !" %}</p>
|
<p>{% trans "Wrong flag ! You can do it !" %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if ctf.ctf_url %}
|
{% if ctf.ctf_url %}
|
||||||
<a class="begin-ctf-link" target="_blank" href="{{ ctf.ctf_url }}">{% trans "Start the challenge" %}</a></br>
|
<a class="begin-ctf-link" target="_blank" href="{{ ctf.ctf_url }}">{% trans "Start the challenge" %}</a></br>
|
||||||
{% elif ctf.file %}
|
{% elif ctf.file %}
|
||||||
<a class="begin-ctf-link" target="_blank" href="{{ ctf.file.url }}">{% trans "Download" %}</a></br>
|
<a class="begin-ctf-link" target="_blank" href="{{ ctf.file.url }}">{% trans "Download" %}</a></br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<form method="post" class="submitflag-form">
|
<form method="post" class="submitflag-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="text" name="flag" maxlength="48" required="" id="id_flag">
|
<input type="text" name="flag" maxlength="48" required="" id="id_flag">
|
||||||
<input class="form-control" type="submit" value=">">
|
<input class="form-control" type="submit" value=">">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4>{% trans "Solved by" %}</h4>
|
<h4>{% trans "Solved by" %}</h4>
|
||||||
{% if solved_list %}
|
{% if solved_list %}
|
||||||
<table class="table table-dark">
|
<table class="table table-dark">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">{% trans "Username" %}</th>
|
<th scope="col">{% trans "Username" %}</th>
|
||||||
<th scope="col">{% trans "Website" %}</th>
|
<th scope="col">{% trans "Website" %}</th>
|
||||||
<th scope="col">{% trans "Score" %}</th>
|
<th scope="col">{% trans "Score" %}</th>
|
||||||
<th scope="col">{% trans "Date" %}</th>
|
<th scope="col">{% trans "Date" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for s in solved_list %}
|
{% for s in solved_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><a class="profile_link" href="{% url 'accounts:profile' user_name=s.user.username %}"> {{ s.user.username }}</a></th>
|
<th scope="row"><a class="profile_link" href="{% url 'accounts:profile' user_name=s.user.username %}"> {{ s.user.username }}</a></th>
|
||||||
<td>{{ s.user.userprofileinfo.portfolio_site }}</td>
|
<td>{{ s.user.userprofileinfo.portfolio_site }}</td>
|
||||||
<td>{{ s.user.userprofileinfo.score }}</td>
|
<td>{{ s.user.userprofileinfo.score }}</td>
|
||||||
<td>{{ s.flag_date }}</td>
|
<td>{{ s.flag_date }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>{% trans "Nobody have solved this CTF." %}</p>
|
<p>{% trans "Nobody have solved this CTF." %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-none d-md-block col-10 col-md-3 right-sidebar">
|
<div class="d-none d-md-block col-10 col-md-3 right-sidebar">
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
<li class="list-group-item">{% trans "Author" %} : {{ ctf.author.username }}</li>
|
<li class="list-group-item">{% trans "Author" %} : {{ ctf.author.username }}</li>
|
||||||
<li class="list-group-item">{% trans "Point reward" %} : {{ ctf.points }}</li>
|
<li class="list-group-item">{% trans "Point reward" %} : {{ ctf.points }}</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -21,10 +21,10 @@ def get_description_by_lang(ctf):
|
||||||
|
|
||||||
def category(request, cat_slug):
|
def category(request, cat_slug):
|
||||||
cat = get_object_or_404(Category, slug=cat_slug)
|
cat = get_object_or_404(Category, slug=cat_slug)
|
||||||
ctfs = CTF.objects.filter(category=cat).order_by('points')
|
ctfs = CTF.objects.filter(category=cat, event=None).order_by('points')
|
||||||
for ex in ctfs:
|
for ex in ctfs:
|
||||||
ex.solved_num = CTF_flags.objects.filter(ctf=ex).count()
|
ex.solved_num = CTF_flags.objects.filter(ctf=ex).count()
|
||||||
ex.solved = ex.solved_by(request.user)
|
ex.solved = ex.solved_by(request.user)
|
||||||
return render(request, 'ctfs/ctfs_list.html', {'ctfs' : ctfs, 'cat' : cat})
|
return render(request, 'ctfs/ctfs_list.html', {'ctfs' : ctfs, 'cat' : cat})
|
||||||
|
|
||||||
def ctf(request, cat_slug, ctf_slug):
|
def ctf(request, cat_slug, ctf_slug):
|
||||||
|
@ -46,18 +46,12 @@ def ctf(request, cat_slug, ctf_slug):
|
||||||
profil.last_submission_date = timezone.now()
|
profil.last_submission_date = timezone.now()
|
||||||
profil.score += ctf_info.points
|
profil.score += ctf_info.points
|
||||||
profil.save()
|
profil.save()
|
||||||
return render(request, 'ctfs/ctf_info.html', {'form' : form, 'ctf' : ctf_info, 'solved_list': solved_list, 'valitated': True, 'description': description})
|
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'valitated': True, 'description': description})
|
||||||
else:
|
else:
|
||||||
return render(request, 'ctfs/ctf_info.html', {'form' : form, 'ctf' : ctf_info, 'solved_list': solved_list, 'failed': True, 'description': description})
|
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'failed': True, 'description': description})
|
||||||
else:
|
else:
|
||||||
form = submit_flag()
|
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': True, 'description': description})
|
||||||
return render(request, 'ctfs/ctf_info.html', {'form' : form, 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': True, 'description': description})
|
|
||||||
else:
|
else:
|
||||||
form = submit_flag()
|
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'description': description})
|
||||||
return render(request, 'ctfs/ctf_info.html', {'form' : form, 'ctf' : ctf_info, 'solved_list': solved_list, 'description': description})
|
|
||||||
else:
|
else:
|
||||||
form = submit_flag()
|
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': flagged, 'description': description})
|
||||||
return render(request, 'ctfs/ctf_info.html', {'form' : form, 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': flagged, 'description': description})
|
|
||||||
|
|
||||||
|
|
||||||
# Create your views here.
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
from .models import Event, Scores
|
||||||
|
|
||||||
|
#admin.site.register(Event)
|
||||||
|
#admin.site.register(Scores)
|
||||||
|
|
||||||
|
@admin.register(Event)
|
||||||
|
class event(admin.ModelAdmin):
|
||||||
|
#list display
|
||||||
|
list_display = ['name', 'start_date', 'end_date']
|
||||||
|
# search list
|
||||||
|
search_fields = ['name', 'slug', 'description', 'password']
|
||||||
|
|
||||||
|
@admin.register(Scores)
|
||||||
|
class score(admin.ModelAdmin):
|
||||||
|
#list display
|
||||||
|
list_display = ['user', 'event', 'score']
|
||||||
|
#list Filter
|
||||||
|
list_filter = ('event',)
|
||||||
|
# search list
|
||||||
|
search_fields = ['user__username', 'score', 'event__name']
|
||||||
|
|
||||||
|
# Register your models here.
|
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class EventsConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'events'
|
|
@ -0,0 +1,4 @@
|
||||||
|
from django import forms
|
||||||
|
|
||||||
|
class submit_flag(forms.Form):
|
||||||
|
flag = forms.CharField(label="Flag", max_length=100)
|
|
@ -0,0 +1,46 @@
|
||||||
|
# Generated by Django 3.2.7 on 2021-10-18 14:19
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django.utils.timezone
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Event',
|
||||||
|
fields=[
|
||||||
|
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||||
|
('name', models.CharField(max_length=200)),
|
||||||
|
('logo', models.CharField(max_length=200)),
|
||||||
|
('img', models.CharField(max_length=200)),
|
||||||
|
('description', models.TextField()),
|
||||||
|
('start_date', models.DateTimeField()),
|
||||||
|
('end_date', models.DateTimeField()),
|
||||||
|
('password', models.CharField(max_length=200)),
|
||||||
|
('slug', models.SlugField(max_length=55)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Scores',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('score', models.PositiveIntegerField(db_index=True, default=0)),
|
||||||
|
('last_submission_date', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Last Submission Date')),
|
||||||
|
('event', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='events.event')),
|
||||||
|
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'ordering': ['-score', 'last_submission_date', 'user__username'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.2.7 on 2021-10-18 14:43
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('events', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='event',
|
||||||
|
name='password',
|
||||||
|
field=models.CharField(blank=True, max_length=200),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Generated by Django 3.2.7 on 2021-10-19 15:19
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('events', '0002_alter_event_password'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='scores',
|
||||||
|
name='event',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='events.event'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='scores',
|
||||||
|
name='user',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,26 @@
|
||||||
|
from django.db import models
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.contrib.auth.models import timezone
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
class Event(models.Model):
|
||||||
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||||
|
name = models.CharField(max_length=200)
|
||||||
|
logo = models.CharField(max_length=200)
|
||||||
|
img = models.CharField(max_length=200)
|
||||||
|
description = models.TextField()
|
||||||
|
start_date = models.DateTimeField()
|
||||||
|
end_date = models.DateTimeField()
|
||||||
|
password = models.CharField(max_length=200, blank=True)
|
||||||
|
slug = models.SlugField(max_length=55)
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
class Scores(models.Model):
|
||||||
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
|
event = models.ForeignKey(Event, on_delete=models.CASCADE)
|
||||||
|
score = models.PositiveIntegerField(default=0, db_index=True)
|
||||||
|
last_submission_date = models.DateTimeField('Last Submission Date', default=timezone.now)
|
||||||
|
class Meta:
|
||||||
|
ordering = ['-score', 'last_submission_date', 'user__username']
|
|
@ -0,0 +1,87 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
{% block content %}
|
||||||
|
{% load i18n %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12 col-md-9">
|
||||||
|
<div class="ctf-block">
|
||||||
|
<a href="{% url 'events:event_info' event_slug=event.slug %}">< Back to event</a>
|
||||||
|
<div class="ctf-head">
|
||||||
|
<h2>Event - {{ event.name }}</h2>
|
||||||
|
<h4>{{ ctf.name }}</h4>
|
||||||
|
<small>{% trans "Published date" %} : {{ ctf.pub_date }}</small>
|
||||||
|
</div>
|
||||||
|
<div class="ctf-body">
|
||||||
|
{% if description %}
|
||||||
|
{{ description|safe }}
|
||||||
|
{% else %}
|
||||||
|
{% trans "No translation available. Please try another language (English or French)." %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="ctf-footer">
|
||||||
|
{% if request.user.is_authenticated %}
|
||||||
|
{% if valitated == True %}
|
||||||
|
<p>{% trans "Congratulation !" %}</p>
|
||||||
|
{% elif alvalitated == True %}
|
||||||
|
<p>{% trans "Already flagged" %}</p>
|
||||||
|
{% if ctf.ctf_url %}
|
||||||
|
<a class="begin-ctf-link" target="_blank" href="{{ ctf.ctf_url }}">{% trans "Start the challenge" %}</a></br>
|
||||||
|
{% elif ctf.file %}
|
||||||
|
<a class="begin-ctf-link" target="_blank" href="{{ ctf.file.url }}">{% trans "Download" %}</a></br>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{% if failed %}
|
||||||
|
<p>{% trans "Wrong flag ! You can do it !" %}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% if ctf.ctf_url %}
|
||||||
|
<a class="begin-ctf-link" target="_blank" href="{{ ctf.ctf_url }}">{% trans "Start the challenge" %}</a></br>
|
||||||
|
{% elif ctf.file %}
|
||||||
|
<a class="begin-ctf-link" target="_blank" href="{{ ctf.file.url }}">{% trans "Download" %}</a></br>
|
||||||
|
{% endif %}
|
||||||
|
<form method="post" action="{% url 'events:submit_event_flag' event_slug=event.slug chall_slug=ctf.slug %}" class="submitflag-form">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="text" name="flag" maxlength="48" required="" id="id_flag">
|
||||||
|
<input class="form-control" type="submit" value=">">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h4>{% trans "Solved by" %}</h4>
|
||||||
|
{% if solved_list %}
|
||||||
|
<table class="table table-dark">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">{% trans "Username" %}</th>
|
||||||
|
<th scope="col">{% trans "Website" %}</th>
|
||||||
|
<th scope="col">{% trans "Score" %}</th>
|
||||||
|
<th scope="col">{% trans "Date" %}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for s in solved_list %}
|
||||||
|
<tr>
|
||||||
|
<th scope="row"><a class="profile_link" href="{% url 'accounts:profile' user_name=s.user.username %}"> {{ s.user.username }}</a></th>
|
||||||
|
<td>{{ s.user.userprofileinfo.portfolio_site }}</td>
|
||||||
|
<td>{{ s.user.userprofileinfo.score }}</td>
|
||||||
|
<td>{{ s.flag_date }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<p>{% trans "Nobody have solved this CTF." %}</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">{% trans "Author" %} : {{ ctf.author.username }}</li>
|
||||||
|
<li class="list-group-item">{% trans "Point reward" %} : {{ ctf.points }}</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
{% block content %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% load is_flagged %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12 col-md-9">
|
||||||
|
<div class="ctf-block">
|
||||||
|
<div class="ctf-head">
|
||||||
|
<h3>{{ event.name }}</h3>
|
||||||
|
{% if ended == True %}
|
||||||
|
<small>{% trans "This event is over." %}</small>
|
||||||
|
{% else %}
|
||||||
|
<small>{% trans "This event start at" %} : {{ event.start_date }}</small>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="ctf-body">
|
||||||
|
{% if event.description %}
|
||||||
|
{{ event.description|safe }}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="ctf-footer">
|
||||||
|
{% if begun == True %}
|
||||||
|
<h4>{% trans "Challenges" %}</h4>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
{% if ctfs %}
|
||||||
|
{% for ctf in ctfs %}
|
||||||
|
<div class="col-md-4">
|
||||||
|
{% isflagged request.user ctf as flagged%}
|
||||||
|
<a href="{% url 'events:event_chall_info' event_slug=event.slug chall_slug=ctf.slug %}">
|
||||||
|
<div class="chall-card {{flagged}}">
|
||||||
|
<p>{{ ctf.category }}</p>
|
||||||
|
<p>{{ ctf.name }} - {{ ctf.points }}</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% if request.user.is_authenticated %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<h4>{% trans "The event has not started yet." %}</h4>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h4>{% trans "ScoreBoard" %}</h4>
|
||||||
|
{% if solved_list %}
|
||||||
|
<table class="table table-dark">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">{% trans "Rank" %}</th>
|
||||||
|
<th scope="col">{% trans "Username" %}</th>
|
||||||
|
<th scope="col">{% trans "Website" %}</th>
|
||||||
|
<th scope="col">{% trans "Score" %}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for s in solved_list %}
|
||||||
|
<tr>
|
||||||
|
<th scope="row"># {{ forloop.counter0|add:1 }}</th>
|
||||||
|
<th scope="row">
|
||||||
|
<a class="profile_link" href="{% url 'accounts:profile' user_name=s.user.username %}"> {{ s.user.username }}</a>
|
||||||
|
</th>
|
||||||
|
<td>{{ s.user.userprofileinfo.site }}</td>
|
||||||
|
<td>{{ s.score }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<p>{% trans "Nobody have solved this CTF." %}</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">{{ event.name }}</li>
|
||||||
|
<li class="list-group-item">{% trans "Start at" %} : {{ event.start_date }}</li>
|
||||||
|
<li class="list-group-item">{% trans "End at" %} : {{ event.end_date }}</li>
|
||||||
|
{% if ended == False and IsRegistered == False %}
|
||||||
|
<form method='POST' action="{% url 'events:subscribe_event' event_slug=event.slug %}">
|
||||||
|
{%csrf_token%}
|
||||||
|
<li class="list-group-item">
|
||||||
|
<input class="form-control" type="submit" value="{% trans "Subscribe" %}">
|
||||||
|
</li>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
{% block content %}
|
||||||
|
{% load i18n %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12 col-md-9">
|
||||||
|
<div class="ctf-block">
|
||||||
|
<div class="ctf-head">
|
||||||
|
<h3>{{ event.name }}</h3>
|
||||||
|
<small>{% trans "This event start at" %} : {{ event.start_date }}</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ctf-footer">
|
||||||
|
{% if logged == True %}
|
||||||
|
<h4>{% trans "This event is password protected" %}</h4>
|
||||||
|
<small>{% trans "You need to submit the event password to gain access to this event." %}</small>
|
||||||
|
<form method="post" action="{% url 'events:submit_pwd' event_slug=event.slug %}" class="submitflag-form">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="text" name="password" maxlength="48" required="">
|
||||||
|
<input class="form-control" type="submit" value=">">
|
||||||
|
</form>
|
||||||
|
{% else %}
|
||||||
|
<h4>{% trans "You need to be logged to access this event." %}</h4>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</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">{{ event.name }}</li>
|
||||||
|
<li class="list-group-item">{% trans "Start at" %} : {{ event.start_date }}</li>
|
||||||
|
<li class="list-group-item">{% trans "End at" %} : {{ event.end_date }}</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
{% block content %}
|
||||||
|
{% load i18n %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<h3>Events</h3>
|
||||||
|
</div>
|
||||||
|
{% if events %}
|
||||||
|
{% for ev in events %}
|
||||||
|
{% if request.user.is_authenticated %}
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
{% endif %}
|
||||||
|
{% if curdate > ev.end_date %}
|
||||||
|
<div class="col-md-3 is-over">
|
||||||
|
{% else %}
|
||||||
|
<div class="col-md-3">
|
||||||
|
{% endif %}
|
||||||
|
<div class="event-card">
|
||||||
|
<img
|
||||||
|
src="{{ev.img}}"
|
||||||
|
class="card-img-top"
|
||||||
|
alt="..."
|
||||||
|
/>
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">{{ ev.name }}</h5>
|
||||||
|
<p class="card-text">
|
||||||
|
Some quick example text to build on the card title and make up the bulk of the
|
||||||
|
card's content.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<ul class="list-group list-group-flush text-center">
|
||||||
|
<li class="list-group-item">{{ ev.start_date }} <br> - <br> {{ ev.end_date }}</li>
|
||||||
|
</ul>
|
||||||
|
<div class="card-body text-center">
|
||||||
|
<a href="{% url 'events:event_info' event_slug=ev.slug %}" class="card-link">See more</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<p>{% trans "No events available." %}</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,10 @@
|
||||||
|
from django import template
|
||||||
|
from ctfs.models import CTF_flags
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def isflagged(user, ctf):
|
||||||
|
if CTF_flags.objects.filter(user=user, ctf=ctf):
|
||||||
|
return "success-msg"
|
||||||
|
return ""
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
|
@ -0,0 +1,13 @@
|
||||||
|
from django.urls import path
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
app_name = "events"
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', views.events, name='events'),
|
||||||
|
path('<str:event_slug>', views.event, name='event_info'),
|
||||||
|
path('<str:event_slug>/challenge/<str:chall_slug>', views.chall_event_info, name='event_chall_info'),
|
||||||
|
path('pwd/<str:event_slug>', views.submit_pwd, name='submit_pwd'),
|
||||||
|
path('submitEventFlag/<str:event_slug>/<str:chall_slug>', views.submit_event_flag, name='submit_event_flag'),
|
||||||
|
path('subscribe/<str:event_slug>', views.subscribe_to_event, name='subscribe_event')
|
||||||
|
]
|
|
@ -0,0 +1,143 @@
|
||||||
|
from django.shortcuts import render, get_object_or_404, redirect
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.contrib.auth.models import timezone
|
||||||
|
from .forms import submit_flag
|
||||||
|
from .models import Event, Scores
|
||||||
|
from ctfs.models import CTF, CTF_flags
|
||||||
|
from django.utils.translation import get_language
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
def events(request):
|
||||||
|
list_events = Event.objects.filter().order_by('-end_date', 'start_date')
|
||||||
|
return render(request, 'events/events_list.html', {'events' : list_events, 'curdate': timezone.now()})
|
||||||
|
|
||||||
|
def chall_event_info(request, event_slug, chall_slug):
|
||||||
|
event_info = get_object_or_404(Event, slug=event_slug)
|
||||||
|
ctf_info = get_object_or_404(CTF, event__slug=event_info.slug, slug=chall_slug)
|
||||||
|
if request.user.is_authenticated and not request.user.is_staff:
|
||||||
|
userScore = Scores.objects.filter(event=event_info, user=request.user)
|
||||||
|
if not userScore:
|
||||||
|
return redirect('/')
|
||||||
|
solved_list = CTF_flags.objects.filter(ctf=ctf_info).order_by('flag_date')
|
||||||
|
description = get_description_by_lang(ctf_info)
|
||||||
|
return render(request, 'events/ctf_info.html', { 'ctf' : ctf_info, 'event':event_info, 'solved_list': solved_list, 'description': description})
|
||||||
|
|
||||||
|
def event(request, event_slug):
|
||||||
|
event_info = get_object_or_404(Event, slug=event_slug)
|
||||||
|
IsRegistered = False
|
||||||
|
if request.user.is_authenticated:
|
||||||
|
userScore = Scores.objects.filter(event=event_info, user=request.user)
|
||||||
|
if userScore:
|
||||||
|
IsRegistered = True
|
||||||
|
if event_info.password:
|
||||||
|
if request.user.is_authenticated:
|
||||||
|
if request.user.is_staff is False:
|
||||||
|
if not userScore:
|
||||||
|
return render(request, 'events/event_pwd.html', {'event' : event_info, 'logged': True})
|
||||||
|
else:
|
||||||
|
return render(request, 'events/event_pwd.html', {'event' : event_info, 'logged': False})
|
||||||
|
ended = False
|
||||||
|
if timezone.now() >= event_info.end_date:
|
||||||
|
ended = True
|
||||||
|
begun = False
|
||||||
|
if timezone.now() >= event_info.start_date:
|
||||||
|
begun = True
|
||||||
|
challenges = CTF.objects.filter(event=event_info).order_by('category', 'points')
|
||||||
|
solved_list = Scores.objects.filter(event=event_info).order_by('-score', 'last_submission_date', 'user__username')
|
||||||
|
return render(request, 'events/event_info.html', {'event' : event_info, 'IsRegistered': IsRegistered, 'ctfs': challenges, 'solved_list':solved_list, 'ended': ended, 'begun': begun})
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def submit_event_flag(request, event_slug, chall_slug):
|
||||||
|
ev = get_object_or_404(Event, slug=event_slug)
|
||||||
|
response = redirect('events:event_chall_info', event_slug=event_slug, chall_slug=chall_slug)
|
||||||
|
if timezone.now() >= ev.end_date:
|
||||||
|
response['Location'] += '?EventIsOver'
|
||||||
|
return response
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
ctf_info = CTF.objects.get(event=ev, slug=chall_slug)
|
||||||
|
if not ctf_info:
|
||||||
|
response['Location'] += '?ChallengeNotFound'
|
||||||
|
return response
|
||||||
|
flagged = False
|
||||||
|
if CTF_flags.objects.filter(user=request.user, ctf=ctf_info):
|
||||||
|
flagged = True
|
||||||
|
response['Location'] += '?AlreadyFlagged'
|
||||||
|
return response
|
||||||
|
try:
|
||||||
|
score = Scores.objects.get(user=request.user, event=ev)
|
||||||
|
except:
|
||||||
|
score = None
|
||||||
|
if score:
|
||||||
|
form = submit_flag(data=request.POST)
|
||||||
|
if flagged == False and form.is_valid():
|
||||||
|
if ctf_info.flag == request.POST.get('flag'):
|
||||||
|
new = CTF_flags(user = request.user, ctf = ctf_info, flag_date = timezone.now())
|
||||||
|
new.save()
|
||||||
|
score.last_submission_date = timezone.now()
|
||||||
|
score.score += ctf_info.points
|
||||||
|
score.save()
|
||||||
|
response['Location'] += '?Congrat'
|
||||||
|
return response
|
||||||
|
else:
|
||||||
|
response['Location'] += '?WrongFlag'
|
||||||
|
return response
|
||||||
|
else:
|
||||||
|
response['Location'] += '?ErrorInForm'
|
||||||
|
return response
|
||||||
|
return response
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def submit_pwd(request, event_slug):
|
||||||
|
response = redirect('events:event_info', event_slug=event_slug)
|
||||||
|
if request.method == 'POST':
|
||||||
|
if request.user.is_authenticated:
|
||||||
|
ev = get_object_or_404(Event, slug=event_slug)
|
||||||
|
if ev == False:
|
||||||
|
response['Location'] += '?NoEventFound'
|
||||||
|
return response
|
||||||
|
|
||||||
|
if request.POST.get('password') != ev.password:
|
||||||
|
response['Location'] += '?WrongPassword'
|
||||||
|
return response
|
||||||
|
|
||||||
|
if Scores.objects.filter(user=request.user, event=ev).exists():
|
||||||
|
response['Location'] += '?AlreadyRegistered'
|
||||||
|
return response
|
||||||
|
else:
|
||||||
|
new = Scores(user=request.user, event=ev, score=0)
|
||||||
|
new.save()
|
||||||
|
return redirect('events:event_info', event_slug=event_slug)
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def subscribe_to_event(request, event_slug):
|
||||||
|
response = redirect('events:event_info', event_slug=event_slug)
|
||||||
|
if request.method == 'POST':
|
||||||
|
if request.user.is_authenticated:
|
||||||
|
ev = get_object_or_404(Event, slug=event_slug)
|
||||||
|
if ev == False:
|
||||||
|
response['Location'] += '?NoEventFound'
|
||||||
|
return response
|
||||||
|
if timezone.now() >= ev.end_date:
|
||||||
|
response['Location'] += '?SubscriptionIsOver'
|
||||||
|
return response
|
||||||
|
if Scores.objects.filter(user=request.user, event=ev).exists():
|
||||||
|
response['Location'] += '?AlreadyRegistered'
|
||||||
|
return response
|
||||||
|
else:
|
||||||
|
new = Scores(user=request.user, event=ev, score=0)
|
||||||
|
new.save()
|
||||||
|
return redirect('events:event_info', event_slug=event_slug)
|
|
@ -32,7 +32,7 @@ def home(request):
|
||||||
response = HttpResponseRedirect(url_translated)
|
response = HttpResponseRedirect(url_translated)
|
||||||
return response
|
return response
|
||||||
news = new.objects.order_by('-pub_date')[:5]
|
news = new.objects.order_by('-pub_date')[:5]
|
||||||
latest_ctfs = CTF.objects.order_by('-pub_date')[:5]
|
latest_ctfs = CTF.objects.filter(event=None).order_by('-pub_date')[:5]
|
||||||
top10 = UserProfileInfo.objects.select_related().order_by('-score', 'last_submission_date', 'user__username')[:10]
|
top10 = UserProfileInfo.objects.select_related().order_by('-score', 'last_submission_date', 'user__username')[:10]
|
||||||
nb_flags = CTF_flags.objects.count()
|
nb_flags = CTF_flags.objects.count()
|
||||||
nb_users = UserProfileInfo.objects.count()
|
nb_users = UserProfileInfo.objects.count()
|
||||||
|
|
|
@ -33,6 +33,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'home.apps.HomeConfig',
|
'home.apps.HomeConfig',
|
||||||
'ctfs.apps.CtfsConfig',
|
'ctfs.apps.CtfsConfig',
|
||||||
|
'events.apps.EventsConfig',
|
||||||
'accounts.apps.AccountsConfig',
|
'accounts.apps.AccountsConfig',
|
||||||
'scoreboard.apps.ScoreboardConfig',
|
'scoreboard.apps.ScoreboardConfig',
|
||||||
'django.contrib.sites',
|
'django.contrib.sites',
|
||||||
|
|
|
@ -32,5 +32,6 @@ urlpatterns += i18n_patterns(
|
||||||
re_path('^accounts/login/', defaults.page_not_found, {'exception': Exception()}),
|
re_path('^accounts/login/', defaults.page_not_found, {'exception': Exception()}),
|
||||||
path('accounts/', include('accounts.urls')),
|
path('accounts/', include('accounts.urls')),
|
||||||
path('accounts/', include('django.contrib.auth.urls')),
|
path('accounts/', include('django.contrib.auth.urls')),
|
||||||
path('scoreboard/', include('scoreboard.urls'))
|
path('scoreboard/', include('scoreboard.urls')),
|
||||||
|
path('events/', include('events.urls'))
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,50 +5,50 @@
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div>
|
<div>
|
||||||
<h4>Scoreboard</h4>
|
<h4>Scoreboard</h4>
|
||||||
<table class="table table-dark">
|
<table class="table table-dark">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">{% trans "Rank" %}</th>
|
<th scope="col">{% trans "Rank" %}</th>
|
||||||
<th scope="col">{% trans "Username" %}</th>
|
<th scope="col">{% trans "Username" %}</th>
|
||||||
<th scope="col">{% trans "Website" %}</th>
|
<th scope="col">{% trans "Website" %}</th>
|
||||||
<th scope="col">{% trans "Score" %}</th>
|
<th scope="col">{% trans "Score" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for s in scores %}
|
{% for s in scores %}
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"># {{ forloop.counter0|add:scores.start_index }}</th>
|
<th scope="row"># {{ forloop.counter0|add:scores.start_index }}</th>
|
||||||
<th><a class="profile_link" href="{% url 'accounts:profile' user_name=s.user.username %}"> {{ s.user.username }}</a></th>
|
<th><a class="profile_link" href="{% url 'accounts:profile' user_name=s.user.username %}"> {{ s.user.username }}</a></th>
|
||||||
<td>
|
<td>
|
||||||
{% if s.user.userprofileinfo.portfolio_site %}
|
{% if s.user.userprofileinfo.portfolio_site %}
|
||||||
<a href="{{ s.user.userprofileinfo.portfolio_site }}" target="_blank">{{ s.user.userprofileinfo.portfolio_site }}</a>
|
<a href="{{ s.user.userprofileinfo.portfolio_site }}" target="_blank">{{ s.user.userprofileinfo.portfolio_site }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ s.user.userprofileinfo.score }}</td>
|
<td>{{ s.user.userprofileinfo.score }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
<span class="step-links">
|
<span class="step-links">
|
||||||
{% if scores.has_previous %}
|
{% if scores.has_previous %}
|
||||||
<a href="?page=1">« {% trans "First" %}</a>
|
<a href="?page=1">« {% trans "First" %}</a>
|
||||||
<a href="?page={{ scores.previous_page_number }}">{% trans "Previous" %}</a>
|
<a href="?page={{ scores.previous_page_number }}">{% trans "Previous" %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<span class="current">
|
<span class="current">
|
||||||
{% trans "Page "%} {{ scores.number }} / {{ scores.paginator.num_pages }}.
|
{% trans "Page "%} {{ scores.number }} / {{ scores.paginator.num_pages }}.
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{% if scores.has_next %}
|
||||||
|
<a href="?page={{ scores.next_page_number }}">{% trans "Next" %}</a>
|
||||||
|
<a href="?page={{ scores.paginator.num_pages }}">{% trans "Last" %}»</a>
|
||||||
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% if scores.has_next %}
|
</div>
|
||||||
<a href="?page={{ scores.next_page_number }}">{% trans "Next" %}</a>
|
|
||||||
<a href="?page={{ scores.paginator.num_pages }}">{% trans "Last" %}»</a>
|
|
||||||
{% endif %}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
body {background-color: #121212;color: #D9D9D9}
|
body {background-color: #121212;color: #D9D9D9}
|
||||||
.card-body {background-color: #1D1D1D;}
|
.card-body {background-color: #1D1D1D;}
|
||||||
|
a{color:#cecece;}
|
||||||
|
a:hover{color:#a9a9a9;text-decoration: none;}
|
||||||
.main-div{margin-top: 40px;}
|
.main-div{margin-top: 40px;}
|
||||||
footer {text-align: center;}
|
footer {text-align: center;}
|
||||||
.news-card {margin-bottom: 20px; border: none;}
|
.news-card {margin-bottom: 20px; border: none;}
|
||||||
|
@ -41,9 +43,25 @@ input[type=submit]:hover {background-color:#000}
|
||||||
.submitflag-form input[type=submit]:hover {background-color:#000}
|
.submitflag-form input[type=submit]:hover {background-color:#000}
|
||||||
.edit-infos-grp input{width: 100%;}
|
.edit-infos-grp input{width: 100%;}
|
||||||
.message {display: block; padding:5px; text-align:center;margin-bottom: 10px;}
|
.message {display: block; padding:5px; text-align:center;margin-bottom: 10px;}
|
||||||
.success-msg {background-color: #42b35e4f;}
|
.success-msg {background-color: #42b35e4f!important;}
|
||||||
.error-msg {background-color: #9542428c;}
|
.error-msg {background-color: #9542428c;}
|
||||||
.progress {background-color: #2d2d2d;}
|
.progress {background-color: #2d2d2d;}
|
||||||
.bg-success {
|
.bg-success {
|
||||||
background-color: #d9d9d9 !important;color: #000;
|
background-color: #d9d9d9 !important;color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.event-card {
|
||||||
|
background-color: #1d1d1d;
|
||||||
|
min-height: 50vh;
|
||||||
|
margin-bottom: 13.37px;
|
||||||
|
}
|
||||||
|
.card-img-top{
|
||||||
|
height:150px;
|
||||||
|
}
|
||||||
|
.chall-card{
|
||||||
|
background-color: #131313;
|
||||||
|
min-height: 100px;
|
||||||
|
border-radius: 2px;
|
||||||
|
margin-bottom: 13.37px;
|
||||||
|
}
|
||||||
|
.is-over {opacity: 50%;}
|
|
@ -2,89 +2,93 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<!-- Bootstrap CSS -->
|
<!-- Bootstrap CSS -->
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||||
<link rel="stylesheet" href="{% static "css/style.css" %}">
|
<link rel="stylesheet" href="{% static "css/style.css" %}">
|
||||||
<!-- Primary Meta Tags -->
|
<!-- Primary Meta Tags -->
|
||||||
<title>42CTF</title>
|
<title>42CTF</title>
|
||||||
<meta name="title" content="42CTF">
|
<meta name="title" content="42CTF">
|
||||||
<meta name="description" content="42CTF est une plateforme de challenge en sécurité informatique par les étudiants de l'école 42.">
|
<meta name="description" content="42CTF est une plateforme de challenge en sécurité informatique par les étudiants de l'école 42.">
|
||||||
|
|
||||||
<!-- Open Graph / Facebook -->
|
<!-- Open Graph / Facebook -->
|
||||||
<meta property="og:type" content="website">
|
<meta property="og:type" content="website">
|
||||||
<meta property="og:url" content="https://www.42ctf.org/">
|
<meta property="og:url" content="https://www.42ctf.org/">
|
||||||
<meta property="og:title" content="42CTF">
|
<meta property="og:title" content="42CTF">
|
||||||
<meta property="og:description" content="42CTF est une plateforme de challenge en sécurité informatique par les étudiants de l'école 42.">
|
<meta property="og:description" content="42CTF est une plateforme de challenge en sécurité informatique par les étudiants de l'école 42.">
|
||||||
<meta property="og:image" content="{% static "img/og_img.png" %}">
|
<meta property="og:image" content="{% static "img/og_img.png" %}">
|
||||||
|
|
||||||
<!-- Twitter -->
|
<!-- Twitter -->
|
||||||
<meta property="twitter:card" content="summary_large_image">
|
<meta property="twitter:card" content="summary_large_image">
|
||||||
<meta property="twitter:url" content="https://www.42ctf.org/">
|
<meta property="twitter:url" content="https://www.42ctf.org/">
|
||||||
<meta property="twitter:title" content="42CTF">
|
<meta property="twitter:title" content="42CTF">
|
||||||
<meta property="twitter:description" content="42CTF est une plateforme de challenge en sécurité informatique par les étudiants de l'école 42.">
|
<meta property="twitter:description" content="42CTF est une plateforme de challenge en sécurité informatique par les étudiants de l'école 42.">
|
||||||
<meta property="twitter:image" content="{% static "img/og_img.png" %}">
|
<meta property="twitter:image" content="{% static "img/og_img.png" %}">
|
||||||
|
|
||||||
<meta name="Description" content="42CTF est une plateforme de challenge en sécurité informatique par les étudiants de l'école 42.">
|
<meta name="Description" content="42CTF est une plateforme de challenge en sécurité informatique par les étudiants de l'école 42.">
|
||||||
<meta name="keywords" content="hack, hacking, challenge, solution, exercice, hacking challenge, hack challenge, exercice hack, exercice hacking, capture the flag, CTF, security, sécurité, Documentation,Applicatif,Cryptologie,Challenges,Outils,Réseaux,CrackinWebW Client,Programmation,Cryptanaly,Application,Présentation,Réseau,Stéganographie,Web Serveur,Cracking,Réaliste,Classement,Challenges, Hacking et Sécurité Informatique,App Script,Capture The Flag,App Système,Forensic,Web," />
|
<meta name="keywords" content="hack, hacking, challenge, solution, exercice, hacking challenge, hack challenge, exercice hack, exercice hacking, capture the flag, CTF, security, sécurité, Documentation,Applicatif,Cryptologie,Challenges,Outils,Réseaux,CrackinWebW Client,Programmation,Cryptanaly,Application,Présentation,Réseau,Stéganographie,Web Serveur,Cracking,Réaliste,Classement,Challenges, Hacking et Sécurité Informatique,App Script,Capture The Flag,App Système,Forensic,Web," />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<!-- As a link -->
|
<!-- As a link -->
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark">
|
<nav class="navbar navbar-expand-lg navbar-dark">
|
||||||
<a class="navbar-brand" href="{% url "home" %}"><img src="{% static "img/cover.png" %}" width="110px"/></a>
|
<a class="navbar-brand" href="{% url "home" %}"><img src="{% static "img/cover.png" %}" width="110px"/></a>
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<ul class="navbar-nav mr-auto">
|
<ul class="navbar-nav mr-auto">
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
CTFs
|
CTFs
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
{% if cats %}
|
{% if cats %}
|
||||||
{% for c in cats %}
|
{% for c in cats %}
|
||||||
<a class="dropdown-item" href="{% url 'category' cat_slug=c.slug %}">{{ c.name }}</a>
|
<a class="dropdown-item" href="{% url 'category' cat_slug=c.slug %}">{{ c.name }}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="dropdown-item">{% translate "No category available." %}</a>
|
<a class="dropdown-item">{% translate "No category available." %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="{% url 'scoreboard:scoreboard' %}">{% translate "Scoreboard" %}</a>
|
||||||
|
<li class="nav-item">
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="{% url 'scoreboard:scoreboard' %}">{% translate "Scoreboard" %}</a>
|
<a class="nav-link" href="{% url 'events:events' %}">{% translate "Events" %}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="navbar-nav ">
|
<ul class="navbar-nav ">
|
||||||
{% get_current_language as LANGUAGE_CODE %}
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
{% get_available_languages as languages %}
|
{% get_available_languages as languages %}
|
||||||
{% for lang_code, lang_name in languages %}
|
{% for lang_code, lang_name in languages %}
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="flag_link" href="{% url 'set_language' lang_code %}?next={{request.path|slice:"3:"}}">
|
<a class="flag_link" href="{% url 'set_language' lang_code %}?next={{request.path|slice:"3:"}}">
|
||||||
<img class="flag_img" src="{% static "img/"|add:lang_code|add:".svg" %}" alt="flag {{ lang_name }}"/>
|
<img class="flag_img" src="{% static "img/"|add:lang_code|add:".svg" %}" alt="flag {{ lang_name }}"/>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if request.user.is_authenticated %}
|
{% if request.user.is_authenticated %}
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<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>
|
<span class="nav-link">{{ request.user.userprofileinfo.score }}</span>
|
||||||
</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>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link" href="{% url 'accounts:signin' %}">{% translate "Login" %}</a>
|
<a class="nav-link" href="{% url 'accounts:signin' %}">{% translate "Login" %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="{% url 'accounts:signup' %}">{% translate "Sign Up" %}</a>
|
<a class="nav-link" href="{% url 'accounts:signup' %}">{% translate "Sign Up" %}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -99,7 +103,7 @@
|
||||||
<a href="https://discord.gg/DwZqPpA">
|
<a href="https://discord.gg/DwZqPpA">
|
||||||
<img width="250px" src="https://discordapp.com/api/guilds/606162827274616845/widget.png?style=banner2">
|
<img width="250px" src="https://discordapp.com/api/guilds/606162827274616845/widget.png?style=banner2">
|
||||||
</a>
|
</a>
|
||||||
<p style="padding-top:10px">Made with <img src="{% static "img/smoke.png" %}" width="20px" style="margin-top:-5px"> by <a href="https://ix-56h.github.io/">ix-56h</a></p>
|
<p style="padding-top:10px">Made with <img src="{% static "img/smoke.png" %}" width="20px" style="margin-top:-5px"> by <a href="https://ix-56h.github.io/">ix-56h</a></p>
|
||||||
</footer>
|
</footer>
|
||||||
<!-- Optional JavaScript -->
|
<!-- Optional JavaScript -->
|
||||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||||
|
@ -107,5 +111,6 @@
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue