From 5e02041f0c3506bdd95aa50e1c37ef22f4fe995a Mon Sep 17 00:00:00 2001 From: Danhia Date: Tue, 15 Feb 2022 18:13:43 +0100 Subject: [PATCH] put challenges descriptions outside of the db --- .gitmodules | 3 +++ .../migrations/0008_auto_20220215_1713.py | 26 +++++++++++++++++++ src/ctfs/models.py | 3 +-- src/ctfs/templates/challenges | 1 + src/ctfs/templates/ctfs/ctf_info.html | 12 +++++---- src/ctfs/templatetags/__init__.py | 0 src/ctfs/templatetags/get_chall.py | 14 ++++++++++ .../migrations/0009_auto_20220215_1706.py | 23 ++++++++++++++++ 8 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 .gitmodules create mode 100644 src/ctfs/migrations/0008_auto_20220215_1713.py create mode 160000 src/ctfs/templates/challenges create mode 100644 src/ctfs/templatetags/__init__.py create mode 100644 src/ctfs/templatetags/get_chall.py create mode 100644 src/events/migrations/0009_auto_20220215_1706.py diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5a57697 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/ctfs/templates/challenges"] + path = src/ctfs/templates/challenges + url = https://gitea.42ctf.org/42CTF/challenges-descriptions.git diff --git a/src/ctfs/migrations/0008_auto_20220215_1713.py b/src/ctfs/migrations/0008_auto_20220215_1713.py new file mode 100644 index 0000000..59d007c --- /dev/null +++ b/src/ctfs/migrations/0008_auto_20220215_1713.py @@ -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), + ), + ] diff --git a/src/ctfs/models.py b/src/ctfs/models.py index afec01c..50a418b 100644 --- a/src/ctfs/models.py +++ b/src/ctfs/models.py @@ -15,10 +15,9 @@ class CTF(models.Model): disabled = models.BooleanField(default=False) description = 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') 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) points = models.PositiveSmallIntegerField() slug = models.SlugField(max_length=55) diff --git a/src/ctfs/templates/challenges b/src/ctfs/templates/challenges new file mode 160000 index 0000000..18fac39 --- /dev/null +++ b/src/ctfs/templates/challenges @@ -0,0 +1 @@ +Subproject commit 18fac3978d21dc824bcffa2bc960aa2bf6b4abd9 diff --git a/src/ctfs/templates/ctfs/ctf_info.html b/src/ctfs/templates/ctfs/ctf_info.html index 3eab7f2..453697f 100644 --- a/src/ctfs/templates/ctfs/ctf_info.html +++ b/src/ctfs/templates/ctfs/ctf_info.html @@ -2,6 +2,8 @@ {% block content %} {% load i18n %} {% load is_member %} +{% load get_chall %} +{% get_current_language as lang %}
@@ -15,11 +17,11 @@
{% else %}
- {% if description %} - {{ description|safe }} - {% else %} - {% trans "No translation available. Please try another language (English or French)." %} - {% endif %} + {% get_chall_by_lang ctf lang as content %} + {{ content | safe }} +