feat: add exportar field to Curso, defaulting extinct courses to false
Lets operators exclude a course from the aluno export file without deleting it. Existing courses already marked "Em extinção" are backfilled to exportar=False by the migration.
This commit is contained in:
parent
36d3386d2d
commit
d96bea6755
33
core/migrations/0014_curso_exportar.py
Normal file
33
core/migrations/0014_curso_exportar.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# Generated by Django 5.2.14 on 2026-07-06 18:46
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
def marcar_cursos_extintos_como_nao_exportar(apps, schema_editor):
|
||||||
|
Curso = apps.get_model("core", "Curso")
|
||||||
|
Curso.objects.filter(
|
||||||
|
situacao_funcionamento_curso__iregex=r"^em extin[cç][aã]o$"
|
||||||
|
).update(exportar=False)
|
||||||
|
|
||||||
|
|
||||||
|
def reverter(apps, schema_editor):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0013_pessoa_atualizado_manualmente_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='curso',
|
||||||
|
name='exportar',
|
||||||
|
field=models.BooleanField(default=True),
|
||||||
|
),
|
||||||
|
migrations.RunPython(
|
||||||
|
marcar_cursos_extintos_como_nao_exportar,
|
||||||
|
reverter,
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -68,6 +68,7 @@ class Curso(models.Model):
|
|||||||
situacao_funcionamento_curso = models.CharField(max_length=100, blank=True)
|
situacao_funcionamento_curso = models.CharField(max_length=100, blank=True)
|
||||||
licenciatura = models.BooleanField(default=False)
|
licenciatura = models.BooleanField(default=False)
|
||||||
ead = models.BooleanField(default=False)
|
ead = models.BooleanField(default=False)
|
||||||
|
exportar = models.BooleanField(default=True)
|
||||||
carga_horaria_total = models.PositiveIntegerField()
|
carga_horaria_total = models.PositiveIntegerField()
|
||||||
polo = models.ForeignKey(
|
polo = models.ForeignKey(
|
||||||
"Polo",
|
"Polo",
|
||||||
|
|||||||
@ -113,6 +113,7 @@ CRUD_CONFIGS = {
|
|||||||
"ead",
|
"ead",
|
||||||
"polo",
|
"polo",
|
||||||
"carga_horaria_total",
|
"carga_horaria_total",
|
||||||
|
"exportar",
|
||||||
),
|
),
|
||||||
search_fields=(
|
search_fields=(
|
||||||
("codigo_mec", "int"),
|
("codigo_mec", "int"),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user