From 170326d5033c1814d613f56873fcf421d3ca6eaf Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 12 Jan 2021 18:02:00 +0100 Subject: [PATCH] Use a selector to choose a problem number --- .../migrations/0007_auto_20210112_1801.py | 29 +++++++++++++++++++ apps/participation/models.py | 5 ++++ tfjm/settings.py | 3 ++ 3 files changed, 37 insertions(+) create mode 100644 apps/participation/migrations/0007_auto_20210112_1801.py diff --git a/apps/participation/migrations/0007_auto_20210112_1801.py b/apps/participation/migrations/0007_auto_20210112_1801.py new file mode 100644 index 0000000..f7615dc --- /dev/null +++ b/apps/participation/migrations/0007_auto_20210112_1801.py @@ -0,0 +1,29 @@ +# Generated by Django 3.0.11 on 2021-01-12 17:01 + +from django.db import migrations, models +import participation.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('participation', '0006_participation_final'), + ] + + operations = [ + migrations.AlterField( + model_name='solution', + name='file', + field=models.FileField(blank=True, default='', unique=True, upload_to=participation.models.get_solution_filename, verbose_name='file'), + ), + migrations.AlterField( + model_name='solution', + name='problem', + field=models.PositiveSmallIntegerField(choices=[(1, 'Problem #1'), (2, 'Problem #2'), (3, 'Problem #3'), (4, 'Problem #4'), (5, 'Problem #5'), (6, 'Problem #6'), (7, 'Problem #7'), (8, 'Problem #8')], verbose_name='problem'), + ), + migrations.AlterField( + model_name='synthesis', + name='file', + field=models.FileField(blank=True, default='', unique=True, upload_to=participation.models.get_random_synthesis_filename, verbose_name='file'), + ), + ] diff --git a/apps/participation/models.py b/apps/participation/models.py index 78db948..42e93f9 100644 --- a/apps/participation/models.py +++ b/apps/participation/models.py @@ -4,12 +4,14 @@ import os from address.models import AddressField +from django.conf import settings from django.core.validators import RegexValidator from django.db import models from django.db.models import Index from django.urls import reverse_lazy from django.utils import timezone from django.utils.crypto import get_random_string +from django.utils.text import format_lazy from django.utils.translation import gettext_lazy as _ from registration.models import VolunteerRegistration from tfjm.lists import get_sympa_client @@ -331,6 +333,9 @@ class Solution(models.Model): problem = models.PositiveSmallIntegerField( verbose_name=_("problem"), + choices=[ + (i, format_lazy(_("Problem #{problem}"), problem=i)) for i in range(1, settings.PROBLEM_COUNT + 1) + ], ) final_solution = models.BooleanField( diff --git a/tfjm/settings.py b/tfjm/settings.py index bfa8bd5..76f5f9b 100644 --- a/tfjm/settings.py +++ b/tfjm/settings.py @@ -236,3 +236,6 @@ GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY") # Use local Jquery JQUERY_URL = False + +# Custom parameters +PROBLEM_COUNT = 8