]> git.parisson.com Git - teleforma.git/commitdiff
Add a field to configure max number of script for a same session : https://trackers...
authorYoan Le Clanche <yoanl@pilotsystems.net>
Thu, 8 Jun 2023 07:49:45 +0000 (09:49 +0200)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Thu, 8 Jun 2023 07:49:45 +0000 (09:49 +0200)
teleforma/exam/views.py
teleforma/migrations/0026_period_nb_script_per_session.py [new file with mode: 0644]
teleforma/models/core.py

index 4fda97aa29fc7ede0fc16cdca7f19bb94c9c011a..7a7107d1a6250a3d4e65e005f6fdf23318de4006 100755 (executable)
@@ -278,7 +278,8 @@ class ScriptCreateView(ScriptMixinView, CreateView):
     def form_valid(self, form):
         scripts = Script.objects.filter(course=form.cleaned_data['course'], session=form.cleaned_data['session'],
                                         author=self.request.user, period=self.period).exclude(status=0)
-        if scripts:
+        nb_script_per_session = self.period.nb_script_per_session or 1
+        if len(scripts) >= nb_script_per_session:
             messages.error(self.request, _(
                 "Error: you have already submitted a script for this session, the same course and the same type!"))
             return redirect('teleforma-exam-script-create', self.period.id)
diff --git a/teleforma/migrations/0026_period_nb_script_per_session.py b/teleforma/migrations/0026_period_nb_script_per_session.py
new file mode 100644 (file)
index 0000000..6b69960
--- /dev/null
@@ -0,0 +1,18 @@
+# Generated by Django 3.2.13 on 2023-06-08 09:24
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('teleforma', '0025_auto_20230607_1038'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='period',
+            name='nb_script_per_session',
+            field=models.IntegerField(default=1, verbose_name='nombre maximal de copies par session'),
+        ),
+    ]
index d7b8cc7a67b1ec5a7a1bfe898d25eaaeb4602dd4..489238038c15eb5d4a56693a9346baff42f3009a 100755 (executable)
@@ -189,6 +189,8 @@ class Period(models.Model):
         _("date de fin d'examens"), null=True, blank=True)
     nb_script = models.IntegerField(
         _("nombre maximal de copies"), null=True, blank=True)
+    nb_script_per_session = models.IntegerField(
+        "nombre maximal de copies par session", default=1)
     date_close_accounts = models.DateField(
         "date de fermeture des comptes étudiants", null=True, blank=True)
     date_inscription_start = models.DateField(