From e52697ad7ea76d262037e52cb21256613fe6a738 Mon Sep 17 00:00:00 2001 From: Joshua Sangmeister Date: Tue, 19 May 2020 12:49:35 +0200 Subject: [PATCH] Adds migration to remove deprecated slides --- .../0014_remove_deprecated_slides.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 openslides/assignments/migrations/0014_remove_deprecated_slides.py diff --git a/openslides/assignments/migrations/0014_remove_deprecated_slides.py b/openslides/assignments/migrations/0014_remove_deprecated_slides.py new file mode 100644 index 000000000..3e014d478 --- /dev/null +++ b/openslides/assignments/migrations/0014_remove_deprecated_slides.py @@ -0,0 +1,27 @@ +from django.db import migrations + + +def remove_deprecated_slides(apps, schema_editor): + Projector = apps.get_model("core", "Projector") + for projector in Projector.objects.all(): + new_history = [] + for entry in projector.elements_history: + new_entry = [] + for subentry in entry: + if subentry["name"] != "assignments/poll": + new_entry.append(subentry) + if len(new_entry): + new_history.append(new_entry) + projector.elements_history = new_history + projector.save(skip_autoupdate=True) + + +class Migration(migrations.Migration): + + dependencies = [ + ("assignments", "0013_rename_verbose_poll_types"), + ] + + operations = [ + migrations.RunPython(remove_deprecated_slides), + ]