]> git.parisson.com Git - teleforma.git/commitdiff
create group
authorGuillaume Pellerin <guillaume.pellerin@parisson.com>
Mon, 26 Jan 2026 21:32:58 +0000 (22:32 +0100)
committerGuillaume Pellerin <guillaume.pellerin@parisson.com>
Mon, 26 Jan 2026 21:32:58 +0000 (22:32 +0100)
teleforma/management/commands/teleforma-get-same-scripts.py

index ff35f8942c3cd46961ea1b4ceecfc218500eeb05..8c3ee23bbc2d92b8efd4523f450b107ae8950969 100644 (file)
@@ -1,6 +1,7 @@
 from django.core.management.base import BaseCommand
 from teleforma.exam.models import Script
 from teleforma.models import Period
+from teleforma.models.messages import StudentGroup
 from datetime import datetime, timedelta
 
 
@@ -11,8 +12,9 @@ class Command(BaseCommand):
         parser.add_argument('args', nargs='*')
 
     def handle(self, *args, **options):
-        name = args[0]
-        period = Period.objects.get(name=name)
+        period_name = args[0]
+        group_name = args[1]
+        period = Period.objects.get(name=period_name)
         users = []
         scripts = []
         ss = Script.objects.filter(period=period)
@@ -23,4 +25,11 @@ class Command(BaseCommand):
                     scripts.append(s)
                     if not s.author in users:
                         users.append(s.author.username)
-        print(users)
+        group = StudentGroup(name=group_name)
+        group.save()
+        for u in users:
+            students = u.student.all()
+            if students:
+                student = students[0]
+                group.students.add(student)
+