Skip to content
Snippets Groups Projects
Commit 0e2a6b8a authored by Nik | Klampfradler's avatar Nik | Klampfradler Committed by Tom Teichler
Browse files

Rewrite migration for Django strangeness

parent 6c642d8b
No related branches found
No related tags found
1 merge request!10Resolve "[Info mailings] sent_to works globally instead of per event"
Pipeline #57901 failed
......@@ -12,12 +12,14 @@ def migrate_to_new_through(apps, schema_editor):
db_alias = schema_editor.connection.alias
for event in Event.objects.using(db_alias).iterator():
for info_mailing in event.info_mailings.all():
through = Through.objects.create(event=event, info_mailing=info_mailing)
for person in info_mailing.sent_to.all():
if EventRegistration.objects.filter(person_id=person.id, event_id=event.id).exists():
through.sent_to.add(person)
for through_old in Event.info_mailings.through.objects.all():
event = through_old.event
info_mailing = through_old.infomailing
through = Through.objects.create(event=event, info_mailing=info_mailing)
for person in info_mailing.sent_to.all():
if EventRegistration.objects.filter(person_id=person.id, event_id=event.id).exists():
through.sent_to.add(person)
class Migration(migrations.Migration):
......
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