diff --git a/src/accounts/templates/accounts/profile.html b/src/accounts/templates/accounts/profile.html index 969b29e..c80fe1f 100644 --- a/src/accounts/templates/accounts/profile.html +++ b/src/accounts/templates/accounts/profile.html @@ -18,7 +18,7 @@ {% for s in solves %} - {{ s.ctf.name }} + {{ s.ctf.name }} {{ s.ctf.category.name}} {{ s.ctf.points }} {{ s.flag_date|date:"Y-m-d H:i:s" }} diff --git a/src/change_lang.py b/src/change_lang.py new file mode 100644 index 0000000..78f17ee --- /dev/null +++ b/src/change_lang.py @@ -0,0 +1,26 @@ +from django.template import Library +from django.core.urlresolvers import resolve, reverse +from django.utils.translation import activate, get_language + +register = Library() + +@register.simple_tag(takes_context=True) +def change_lang(context, lang=None, *args, **kwargs): + """ + Get active page's url by a specified language + Usage: {% change_lang 'en' %} + """ + + path = context['request'].path + url_parts = resolve( path ) + + url = path + cur_language = get_language() + try: + activate(lang) + url = reverse( url_parts.view_name, kwargs=url_parts.kwargs ) + finally: + activate(cur_language) + + + return "%s" % url diff --git a/src/ctfs/migrations/0004_auto_20210907_1407.py b/src/ctfs/migrations/0004_auto_20210907_1407.py new file mode 100644 index 0000000..ed6825d --- /dev/null +++ b/src/ctfs/migrations/0004_auto_20210907_1407.py @@ -0,0 +1,28 @@ +# Generated by Django 3.2.7 on 2021-09-07 14:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ctfs', '0003_auto_20191003_1947'), + ] + + operations = [ + migrations.AddField( + model_name='ctf', + name='description_de', + field=models.TextField(blank=True), + ), + migrations.AddField( + model_name='ctf', + name='description_en', + field=models.TextField(blank=True), + ), + migrations.AddField( + model_name='ctf', + name='description_ru', + field=models.TextField(blank=True), + ), + ] diff --git a/src/ctfs/models.py b/src/ctfs/models.py index a9a41ce..4958f77 100644 --- a/src/ctfs/models.py +++ b/src/ctfs/models.py @@ -12,6 +12,9 @@ class CTF(models.Model): name = models.CharField(max_length=200) flag = models.CharField(max_length=100) 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) points = models.PositiveSmallIntegerField() diff --git a/src/ctfs/templates/ctfs/.ctfs_list.html.swp b/src/ctfs/templates/ctfs/.ctfs_list.html.swp deleted file mode 100644 index de31984..0000000 Binary files a/src/ctfs/templates/ctfs/.ctfs_list.html.swp and /dev/null differ diff --git a/src/ctfs/templates/ctfs/ctf_info.html b/src/ctfs/templates/ctfs/ctf_info.html index 1e5243c..70043c6 100644 --- a/src/ctfs/templates/ctfs/ctf_info.html +++ b/src/ctfs/templates/ctfs/ctf_info.html @@ -9,7 +9,11 @@ {% trans "Published date" %} : {{ ctf.pub_date }}
- {{ ctf.description|safe }} + {% if description %} + {{ description|safe }} + {% else %} + {% trans "No translation available for this challenge. Try another lang (French or English)." %} + {% endif %}