forked from 42CTF/website
put challenges descriptions outside of the db
This commit is contained in:
parent
f75a034094
commit
5e02041f0c
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "src/ctfs/templates/challenges"]
|
||||||
|
path = src/ctfs/templates/challenges
|
||||||
|
url = https://gitea.42ctf.org/42CTF/challenges-descriptions.git
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Generated by Django 3.2.11 on 2022-02-15 16:13
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('ctfs', '0007_ctf_disabled'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='ctf',
|
||||||
|
name='description_de',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='ctf',
|
||||||
|
name='description_ru',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='ctf',
|
||||||
|
name='port',
|
||||||
|
field=models.PositiveSmallIntegerField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -15,10 +15,9 @@ class CTF(models.Model):
|
||||||
disabled = models.BooleanField(default=False)
|
disabled = models.BooleanField(default=False)
|
||||||
description = models.TextField(blank=True)
|
description = models.TextField(blank=True)
|
||||||
description_en = models.TextField(blank=True)
|
description_en = models.TextField(blank=True)
|
||||||
description_ru = 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)
|
||||||
|
port = models.PositiveSmallIntegerField(null=True, blank=True)
|
||||||
event = models.ForeignKey(Event, null=True, blank=True, on_delete=models.CASCADE)
|
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)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 18fac3978d21dc824bcffa2bc960aa2bf6b4abd9
|
|
@ -2,6 +2,8 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load is_member %}
|
{% load is_member %}
|
||||||
|
{% load get_chall %}
|
||||||
|
{% get_current_language as lang %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12 col-md-9">
|
<div class="col-sm-12 col-md-9">
|
||||||
<div class="ctf-block">
|
<div class="ctf-block">
|
||||||
|
@ -15,11 +17,11 @@
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="ctf-body">
|
<div class="ctf-body">
|
||||||
{% if description %}
|
{% get_chall_by_lang ctf lang as content %}
|
||||||
{{ description|safe }}
|
{{ content | safe }}
|
||||||
{% else %}
|
<!-- {% if ctf.port %}
|
||||||
{% trans "No translation available. Please try another language (English or French)." %}
|
<b>nc challenges.42ctf.org {{ ctf.port }}</b>
|
||||||
{% endif %}
|
{% endif %} -->
|
||||||
</div>
|
</div>
|
||||||
<div class="ctf-footer">
|
<div class="ctf-footer">
|
||||||
{% if request.user.is_authenticated %}
|
{% if request.user.is_authenticated %}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def get_chall_by_lang(chall, lang):
|
||||||
|
print(chall.slug)
|
||||||
|
filepath = "ctfs/templates/challenges/"+ lang + "/" + chall.slug + ".html"
|
||||||
|
print(filepath)
|
||||||
|
try:
|
||||||
|
with open(filepath) as fp:
|
||||||
|
return fp.read()
|
||||||
|
except:
|
||||||
|
return chall.description_en
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 3.2.11 on 2022-02-15 16:06
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('events', '0008_event_dynamic'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='eventplayer',
|
||||||
|
name='id',
|
||||||
|
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='team',
|
||||||
|
name='id',
|
||||||
|
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
|
||||||
|
),
|
||||||
|
]
|
Loading…
Reference in New Issue