Use a selector to choose a problem number

This commit is contained in:
Yohann D'ANELLO 2021-01-12 18:02:00 +01:00
parent d75ba1f890
commit 170326d503
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
3 changed files with 37 additions and 0 deletions

View File

@ -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'),
),
]

View File

@ -4,12 +4,14 @@
import os import os
from address.models import AddressField from address.models import AddressField
from django.conf import settings
from django.core.validators import RegexValidator from django.core.validators import RegexValidator
from django.db import models from django.db import models
from django.db.models import Index from django.db.models import Index
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.utils import timezone from django.utils import timezone
from django.utils.crypto import get_random_string from django.utils.crypto import get_random_string
from django.utils.text import format_lazy
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from registration.models import VolunteerRegistration from registration.models import VolunteerRegistration
from tfjm.lists import get_sympa_client from tfjm.lists import get_sympa_client
@ -331,6 +333,9 @@ class Solution(models.Model):
problem = models.PositiveSmallIntegerField( problem = models.PositiveSmallIntegerField(
verbose_name=_("problem"), verbose_name=_("problem"),
choices=[
(i, format_lazy(_("Problem #{problem}"), problem=i)) for i in range(1, settings.PROBLEM_COUNT + 1)
],
) )
final_solution = models.BooleanField( final_solution = models.BooleanField(

View File

@ -236,3 +236,6 @@ GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
# Use local Jquery # Use local Jquery
JQUERY_URL = False JQUERY_URL = False
# Custom parameters
PROBLEM_COUNT = 8