forked from rc/aircox
cfr #121 Co-authored-by: Christophe Siraut <d@tobald.eu.org> Co-authored-by: bkfox <thomas bkfox net> Co-authored-by: Thomas Kairos <thomas@bkfox.net> Reviewed-on: rc/aircox#131 Co-authored-by: Chris Tactic <ctactic@noreply.git.radiocampus.be> Co-committed-by: Chris Tactic <ctactic@noreply.git.radiocampus.be>
32 lines
828 B
Python
32 lines
828 B
Python
from django.db import migrations, models, transaction
|
|
|
|
|
|
def init_groups_and_permissions(app, schema_editor):
|
|
from aircox import permissions
|
|
|
|
Program = app.get_model("aircox", "Program")
|
|
|
|
with transaction.atomic():
|
|
for program in Program.objects.all():
|
|
permissions.program.init(program)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
atomic = False
|
|
dependencies = [
|
|
("aircox", "0021_alter_schedule_timezone"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(init_groups_and_permissions),
|
|
migrations.AlterField(
|
|
model_name="program",
|
|
name="editors_group",
|
|
field=models.ForeignKey(
|
|
on_delete=models.deletion.CASCADE,
|
|
to="auth.group",
|
|
verbose_name="editors",
|
|
),
|
|
),
|
|
]
|