mirror of https://github.com/interlegis/sigi.git
Sesóstris Vieira
7 months ago
4 changed files with 21 additions and 25 deletions
@ -0,0 +1,21 @@ |
|||
from django.core.management.base import BaseCommand |
|||
from sigi.apps.eventos.models import Evento |
|||
from django.utils import timezone |
|||
|
|||
|
|||
class Command(BaseCommand): |
|||
help = "Carrega dados de participantes de eventos do Moodle para o SIGI" |
|||
|
|||
def handle(self, *args, **options): |
|||
for evento in Evento.objects.exclude(moodle_courseid=None).filter( |
|||
data_termino__lt=timezone.localtime() |
|||
): |
|||
try: |
|||
evento.sincroniza_saberes() |
|||
self.stdout.write( |
|||
self.style.SUCCESS(f"✔ {evento.nome} sincronizado.") |
|||
) |
|||
except Evento.SaberesSyncException as err: |
|||
self.stdout.write( |
|||
self.style.ERROR(f"✖ {evento.nome}: {err.message}") |
|||
) |
@ -1,25 +0,0 @@ |
|||
# Generated by Django 5.0.4 on 2024-05-28 13:41 |
|||
|
|||
from django.db import migrations |
|||
from django.utils import timezone |
|||
from sigi.apps.eventos.models import Evento |
|||
|
|||
|
|||
def carga(apps, schema_editor): |
|||
for evento in Evento.objects.exclude(moodle_courseid=None).filter( |
|||
data_termino__lt=timezone.localtime() |
|||
): |
|||
try: |
|||
evento.sincroniza_saberes() |
|||
print(f"\t{evento.nome} sincronizado.") |
|||
except Evento.SaberesSyncException as err: |
|||
print(f"\tERRO: {evento.nome}: {err.message}") |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
("eventos", "0063_participantesevento_and_more"), |
|||
] |
|||
|
|||
operations = [migrations.RunPython(carga, migrations.RunPython.noop)] |
Loading…
Reference in new issue