Skip to content
Snippets Groups Projects
Verified Commit d7db9623 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

feat: add migration to set contributors, language & topic on notes

parent 91f9f0c8
No related branches found
No related tags found
No related merge requests found
Pipeline #7784 passed
# Generated by Django 4.2.11 on 2024-03-29 18:40
from django.db import migrations
def set_contributors(apps, _):
Note = apps.get_model("program", "Note")
for note in Note.objects.filter(contributors=None).exclude(
timeslot__schedule__show__hosts=None
):
note.contributors.set(note.timeslot.schedule.show.hosts.values_list("id", flat=True))
note.save()
def set_language(apps, _):
Note = apps.get_model("program", "Note")
for note in Note.objects.filter(language=None).exclude(
timeslot__schedule__show__language=None
):
note.language.set(note.timeslot.schedule.show.language.values_list("id", flat=True))
note.save()
def set_topic(apps, _):
Note = apps.get_model("program", "Note")
for note in Note.objects.filter(topic=None).exclude(timeslot__schedule__show__topic=None):
note.topic.set(note.timeslot.schedule.show.topic.values_list("id", flat=True))
class Migration(migrations.Migration):
dependencies = [
("program", "0085_attach_notes"),
]
operations = [
migrations.RunPython(code=set_contributors),
migrations.RunPython(code=set_language),
migrations.RunPython(code=set_topic),
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment