From: Guillaume Pellerin Date: Mon, 26 Jan 2026 21:32:58 +0000 (+0100) Subject: create group X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=75a13e436e8d2dd433165d5dfc8ca291edecdda4;p=teleforma.git create group --- diff --git a/teleforma/management/commands/teleforma-get-same-scripts.py b/teleforma/management/commands/teleforma-get-same-scripts.py index ff35f894..8c3ee23b 100644 --- a/teleforma/management/commands/teleforma-get-same-scripts.py +++ b/teleforma/management/commands/teleforma-get-same-scripts.py @@ -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) +