diff --git a/openslides/agenda/migrations/0002_duration.py b/openslides/agenda/migrations/0002_item_duration.py similarity index 71% rename from openslides/agenda/migrations/0002_duration.py rename to openslides/agenda/migrations/0002_item_duration.py index 990f3d13b..17b1cbc25 100644 --- a/openslides/agenda/migrations/0002_duration.py +++ b/openslides/agenda/migrations/0002_item_duration.py @@ -6,23 +6,31 @@ from django.db import migrations, models def convert_duration(apps, schema_editor): - Item = apps.get_model('agenda', 'item') + """ + Converts the values of the old duration CharField to new duration + IntegerField. It uses the temporary field for proper renaming the field + in the end. + """ + Item = apps.get_model('agenda', 'Item') for item in Item.objects.all(): duration = item.duration item.duration_tmp = None if is_int(duration): - # assuming that these are minutes + # Assuming that these are minutes. item.duration_tmp = int(duration) elif isinstance(duration, str): + # Assuming format (h)h:(m)m. If not, new value is None. split = duration.split(':') - # assuming format (h)h:(m)m if len(split) == 2 and is_int(split[0]) and is_int(split[1]): - # duration = hours * 60 + minutes + # Calculate new duration: hours * 60 + minutes. item.duration_tmp = int(split[0]) * 60 + int(split[1]) item.save(skip_autoupdate=True) def is_int(s): + """ + Short helper for duration conversion. + """ try: int(s) except (ValueError, TypeError): @@ -43,7 +51,9 @@ class Migration(migrations.Migration): name='duration_tmp', field=models.IntegerField(blank=True, null=True), ), - migrations.RunPython(convert_duration), + migrations.RunPython( + convert_duration + ), migrations.RemoveField( model_name='item', name='duration', diff --git a/openslides/assignments/migrations/0003_auto_20160907_0946.py b/openslides/assignments/migrations/0002_assignmentpoll_pollmethod.py similarity index 70% rename from openslides/assignments/migrations/0003_auto_20160907_0946.py rename to openslides/assignments/migrations/0002_assignmentpoll_pollmethod.py index b45036247..61846ad89 100644 --- a/openslides/assignments/migrations/0003_auto_20160907_0946.py +++ b/openslides/assignments/migrations/0002_assignmentpoll_pollmethod.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.9.9 on 2016-09-07 09:46 +# Generated by Django 1.10.2 on 2016-10-24 11:11 from __future__ import unicode_literals from django.db import migrations, models @@ -8,14 +8,10 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('assignments', '0002_assignmentpoll_yesno'), + ('assignments', '0001_initial'), ] operations = [ - migrations.RemoveField( - model_name='assignmentpoll', - name='yesno', - ), migrations.RemoveField( model_name='assignmentpoll', name='yesnoabstain', diff --git a/openslides/assignments/migrations/0002_assignmentpoll_yesno.py b/openslides/assignments/migrations/0002_assignmentpoll_yesno.py deleted file mode 100644 index 7a025546c..000000000 --- a/openslides/assignments/migrations/0002_assignmentpoll_yesno.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.7 on 2016-06-09 14:20 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('assignments', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='assignmentpoll', - name='yesno', - field=models.BooleanField(default=False), - ), - ] diff --git a/openslides/core/migrations/0002_misc_features.py b/openslides/core/migrations/0002_misc_features.py new file mode 100644 index 000000000..587226117 --- /dev/null +++ b/openslides/core/migrations/0002_misc_features.py @@ -0,0 +1,238 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.4 on 2016-12-11 21:13 +from __future__ import unicode_literals + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + +import openslides.utils.models + + +def move_custom_slides_to_topics(apps, schema_editor): + """ + Move all custom slides to new topic model. + """ + # We get the model from the versioned app registry; + # if we directly import it, it will be the wrong version. + ContentType = apps.get_model('contenttypes', 'ContentType') + CustomSlide = apps.get_model('core', 'CustomSlide') + Item = apps.get_model('agenda', 'Item') + Topic = apps.get_model('topics', 'Topic') + + # Copy data. + content_type_custom_slide = ContentType.objects.get_for_model(CustomSlide) + content_type_topic = ContentType.objects.get_for_model(Topic) + for custom_slide in CustomSlide.objects.all(): + # This line does not create a new Item because this migration model has + # no method 'get_agenda_title()'. See agenda/signals.py. + topic = Topic.objects.create(title=custom_slide.title, text=custom_slide.text) + topic.attachments.add(*custom_slide.attachments.all()) + item = Item.objects.get(object_id=custom_slide.pk, content_type=content_type_custom_slide) + item.object_id = topic.pk + item.content_type = content_type_topic + item.save(skip_autoupdate=True) + + # Delete old data. + CustomSlide.objects.all().delete() + content_type_custom_slide.delete() + + +def name_default_projector(apps, schema_editor): + """ + Set the name of the default projector to 'Defaultprojector' + """ + Projector = apps.get_model('core', 'Projector') + Projector.objects.filter(pk=1).update(name='Default projector') + + +def remove_old_countdowns_messages(apps, schema_editor): + """ + Remove old countdowns and messages created by 2.0 from projector elements which are unusable in 2.1. + """ + Projector = apps.get_model('core', 'Projector') + projector = Projector.objects.get(pk=1) + + projector_config = projector.config + for key, value in list(projector.config.items()): + if value.get('name') in ('core/countdown', 'core/message'): + del projector_config[key] + projector.config = projector_config + projector.save(skip_autoupdate=True) + + +def add_projection_defaults(apps, schema_editor): + """ + Adds projectiondefaults for messages and countdowns. + """ + Projector = apps.get_model('core', 'Projector') + ProjectionDefault = apps.get_model('core', 'ProjectionDefault') + # The default projector (pk=1) is always available. + default_projector = Projector.objects.get(pk=1) + + projectiondefaults = [] + + projectiondefaults.append(ProjectionDefault( + name='agenda_all_items', + display_name='Agenda', + projector=default_projector)) + projectiondefaults.append(ProjectionDefault( + name='topics', + display_name='Topics', + projector=default_projector)) + projectiondefaults.append(ProjectionDefault( + name='agenda_list_of_speakers', + display_name='List of speakers', + projector=default_projector)) + projectiondefaults.append(ProjectionDefault( + name='agenda_current_list_of_speakers', + display_name='Current list of speakers', + projector=default_projector)) + projectiondefaults.append(ProjectionDefault( + name='motions', + display_name='Motions', + projector=default_projector)) + projectiondefaults.append(ProjectionDefault( + name='motionBlocks', + display_name='Motion Blocks', + projector=default_projector)) + projectiondefaults.append(ProjectionDefault( + name='assignments', + display_name='Elections', + projector=default_projector)) + projectiondefaults.append(ProjectionDefault( + name='users', + display_name='Participants', + projector=default_projector)) + projectiondefaults.append(ProjectionDefault( + name='mediafiles', + display_name='Files', + projector=default_projector)) + projectiondefaults.append(ProjectionDefault( + name='messages', + display_name='Messages', + projector=default_projector)) + projectiondefaults.append(ProjectionDefault( + name='countdowns', + display_name='Countdowns', + projector=default_projector)) + + # Create all new projectiondefaults + ProjectionDefault.objects.bulk_create(projectiondefaults) + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('sessions', '0001_initial'), + ('contenttypes', '0002_remove_content_type_name'), + ('core', '0001_initial'), + ('agenda', '0001_initial'), # ('agenda', '0002_item_duration') is not required but would be also ok. + ('topics', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Countdown', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('description', models.CharField(blank=True, max_length=256)), + ('running', models.BooleanField(default=False)), + ('default_time', models.PositiveIntegerField(default=60)), + ('countdown_time', models.FloatField(default=60)), + ], + options={ + 'default_permissions': (), + }, + bases=(openslides.utils.models.RESTModelMixin, models.Model), + ), + migrations.CreateModel( + name='ProjectionDefault', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=256)), + ('display_name', models.CharField(max_length=256)), + ], + options={ + 'default_permissions': (), + }, + bases=(openslides.utils.models.RESTModelMixin, models.Model), + ), + migrations.CreateModel( + name='ProjectorMessage', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('message', models.TextField(blank=True)), + ], + options={ + 'default_permissions': (), + }, + bases=(openslides.utils.models.RESTModelMixin, models.Model), + ), + migrations.CreateModel( + name='Session', + fields=[ + ('session_ptr', models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to='sessions.Session')), + ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + options={ + 'default_permissions': (), + }, + bases=('sessions.session',), + ), + migrations.RunPython( + move_custom_slides_to_topics + ), + migrations.RemoveField( + model_name='customslide', + name='attachments', + ), + migrations.DeleteModel( + name='CustomSlide', + ), + migrations.AlterModelOptions( + name='chatmessage', + options={'default_permissions': (), 'permissions': (('can_use_chat', 'Can use the chat'), ('can_manage_chat', 'Can manage the chat'))}, + ), + migrations.AddField( + model_name='projector', + name='blank', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='projector', + name='height', + field=models.PositiveIntegerField(default=768), + ), + migrations.AddField( + model_name='projector', + name='name', + field=models.CharField(blank=True, max_length=255, unique=True), + ), + migrations.AddField( + model_name='projector', + name='width', + field=models.PositiveIntegerField(default=1024), + ), + migrations.AddField( + model_name='projectiondefault', + name='projector', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='projectiondefaults', to='core.Projector'), + ), + migrations.RunPython( + name_default_projector + ), + migrations.RunPython( + remove_old_countdowns_messages + ), + migrations.RunPython( + add_projection_defaults + ), + ] diff --git a/openslides/core/migrations/0002_session.py b/openslides/core/migrations/0002_session.py deleted file mode 100644 index fea7eb7be..000000000 --- a/openslides/core/migrations/0002_session.py +++ /dev/null @@ -1,35 +0,0 @@ -import django.db.models.deletion -from django.conf import settings -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('sessions', '0001_initial'), - ('core', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='Session', - fields=[ - ('session_ptr', - models.OneToOneField( - auto_created=True, - on_delete=django.db.models.deletion.CASCADE, - parent_link=True, - primary_key=True, - serialize=False, - to='sessions.Session')), - ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - options={ - 'verbose_name_plural': 'sessions', - 'abstract': False, - 'verbose_name': 'session', - }, - bases=('sessions.session',), - ), - ] diff --git a/openslides/core/migrations/0003_auto_20160815_1911.py b/openslides/core/migrations/0003_auto_20160815_1911.py deleted file mode 100644 index 2f3e47d2f..000000000 --- a/openslides/core/migrations/0003_auto_20160815_1911.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 1.9.9 on 2016-08-15 19:11 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('core', '0002_session'), - ] - - operations = [ - migrations.AlterModelOptions( - name='session', - options={'default_permissions': ()}, - ), - ] diff --git a/openslides/core/migrations/0004_projector_resolution.py b/openslides/core/migrations/0004_projector_resolution.py deleted file mode 100644 index 7d2417784..000000000 --- a/openslides/core/migrations/0004_projector_resolution.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.9 on 2016-08-25 11:56 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('core', '0003_auto_20160815_1911'), - ] - - operations = [ - migrations.AddField( - model_name='projector', - name='height', - field=models.PositiveIntegerField(default=768), - ), - migrations.AddField( - model_name='projector', - name='width', - field=models.PositiveIntegerField(default=1024), - ), - ] diff --git a/openslides/core/migrations/0005_auto_20160918_2104.py b/openslides/core/migrations/0005_auto_20160918_2104.py deleted file mode 100644 index 117751b90..000000000 --- a/openslides/core/migrations/0005_auto_20160918_2104.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.1 on 2016-09-18 19:04 -from __future__ import unicode_literals - -from django.db import migrations - - -def move_custom_slides_to_topics(apps, schema_editor): - # We get the model from the versioned app registry; - # if we directly import it, it will be the wrong version. - ContentType = apps.get_model('contenttypes', 'ContentType') - CustomSlide = apps.get_model('core', 'CustomSlide') - Item = apps.get_model('agenda', 'Item') - Topic = apps.get_model('topics', 'Topic') - - # Copy data. - content_type_custom_slide = ContentType.objects.get_for_model(CustomSlide) - content_type_topic = ContentType.objects.get_for_model(Topic) - for custom_slide in CustomSlide.objects.all(): - # This line does not create a new Item because this migration model has - # no method 'get_agenda_title()'. See agenda/signals.py. - topic = Topic.objects.create(title=custom_slide.title, text=custom_slide.text) - topic.attachments.add(*custom_slide.attachments.all()) - item = Item.objects.get(object_id=custom_slide.pk, content_type=content_type_custom_slide) - item.object_id = topic.pk - item.content_type = content_type_topic - item.save(skip_autoupdate=True) - - # Delete old data. - CustomSlide.objects.all().delete() - content_type_custom_slide.delete() - - -class Migration(migrations.Migration): - - dependencies = [ - ('core', '0004_projector_resolution'), - ('topics', '0001_initial'), - ] - - operations = [ - migrations.RunPython( - move_custom_slides_to_topics - ), - migrations.RemoveField( - model_name='customslide', - name='attachments', - ), - migrations.DeleteModel( - name='CustomSlide', - ), - ] diff --git a/openslides/core/migrations/0006_multiprojector.py b/openslides/core/migrations/0006_multiprojector.py deleted file mode 100644 index 638ceb839..000000000 --- a/openslides/core/migrations/0006_multiprojector.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.9 on 2016-08-29 09:37 -from __future__ import unicode_literals - -import django.db.models.deletion -from django.db import migrations, models - -import openslides.utils.models - - -def name_default_projector(apps, schema_editor): - """ - Set the name of the default projector to 'Defaultprojector' - """ - Projector = apps.get_model('core', 'Projector') - Projector.objects.filter(pk=1).update(name='Default projector') - - -class Migration(migrations.Migration): - - dependencies = [ - ('core', '0005_auto_20160918_2104'), - ] - - operations = [ - migrations.CreateModel( - name='ProjectionDefault', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=256)), - ('display_name', models.CharField(max_length=256)), - ], - options={ - 'default_permissions': (), - }, - bases=(openslides.utils.models.RESTModelMixin, models.Model), - ), - migrations.AddField( - model_name='projector', - name='name', - field=models.CharField(blank=True, max_length=255, unique=True), - ), - migrations.AddField( - model_name='projector', - name='blank', - field=models.BooleanField(blank=False, default=False), - ), - migrations.AddField( - model_name='projectiondefault', - name='projector', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='projectiondefaults', to='core.Projector'), - ), - migrations.RunPython(name_default_projector), - ] diff --git a/openslides/core/migrations/0007_manage_chat_permission.py b/openslides/core/migrations/0007_manage_chat_permission.py deleted file mode 100644 index 704fd4db1..000000000 --- a/openslides/core/migrations/0007_manage_chat_permission.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.1 on 2016-10-17 09:50 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('core', '0006_multiprojector'), - ] - - operations = [ - migrations.AlterModelOptions( - name='chatmessage', - options={'default_permissions': (), 'permissions': (('can_use_chat', 'Can use the chat'), ('can_manage_chat', 'Can manage the chat'))}, - ), - ] diff --git a/openslides/core/migrations/0008_countdown_message.py b/openslides/core/migrations/0008_countdown_message.py deleted file mode 100644 index fe31ad351..000000000 --- a/openslides/core/migrations/0008_countdown_message.py +++ /dev/null @@ -1,107 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.1 on 2016-10-21 09:07 -from __future__ import unicode_literals - -from django.db import migrations, models - -import openslides.utils.models - - -def add_projection_defaults(apps, schema_editor): - """ - Adds projectiondefaults for messages and countdowns. - """ - Projector = apps.get_model('core', 'Projector') - ProjectionDefault = apps.get_model('core', 'ProjectionDefault') - # the default projector (pk=1) is always available. - default_projector = Projector.objects.get(pk=1) - - projectiondefaults = [] - # It is possible that already some projectiondefaults exist if this - # is a database created with an older version of OS. - if not ProjectionDefault.objects.all().exists(): - projectiondefaults.append(ProjectionDefault( - name='agenda_all_items', - display_name='Agenda', - projector=default_projector)) - projectiondefaults.append(ProjectionDefault( - name='topics', - display_name='Topics', - projector=default_projector)) - projectiondefaults.append(ProjectionDefault( - name='agenda_list_of_speakers', - display_name='List of speakers', - projector=default_projector)) - projectiondefaults.append(ProjectionDefault( - name='agenda_current_list_of_speakers', - display_name='Current list of speakers', - projector=default_projector)) - projectiondefaults.append(ProjectionDefault( - name='motions', - display_name='Motions', - projector=default_projector)) - projectiondefaults.append(ProjectionDefault( - name='motionBlocks', - display_name='Motion Blocks', - projector=default_projector)) - projectiondefaults.append(ProjectionDefault( - name='assignments', - display_name='Elections', - projector=default_projector)) - projectiondefaults.append(ProjectionDefault( - name='users', - display_name='Participants', - projector=default_projector)) - projectiondefaults.append(ProjectionDefault( - name='mediafiles', - display_name='Files', - projector=default_projector)) - - # Now, these are new projectiondefaults - projectiondefaults.append(ProjectionDefault( - name='messages', - display_name='Messages', - projector=default_projector)) - projectiondefaults.append(ProjectionDefault( - name='countdowns', - display_name='Countdowns', - projector=default_projector)) - - # Create all new projectiondefaults - ProjectionDefault.objects.bulk_create(projectiondefaults) - - -class Migration(migrations.Migration): - - dependencies = [ - ('core', '0007_manage_chat_permission'), - ] - - operations = [ - migrations.CreateModel( - name='Countdown', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('description', models.CharField(max_length=256, blank=True)), - ('running', models.BooleanField(default=False)), - ('default_time', models.PositiveIntegerField(default=60)), - ('countdown_time', models.FloatField(default=60)), - ], - options={ - 'default_permissions': (), - }, - bases=(openslides.utils.models.RESTModelMixin, models.Model), - ), - migrations.CreateModel( - name='ProjectorMessage', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('message', models.TextField(blank=True)), - ], - options={ - 'default_permissions': (), - }, - bases=(openslides.utils.models.RESTModelMixin, models.Model), - ), - migrations.RunPython(add_projection_defaults), - ] diff --git a/openslides/mediafiles/migrations/0002_mediafile_private.py b/openslides/mediafiles/migrations/0002_mediafile_private.py index 213aa8d4e..cad7e4ca4 100644 --- a/openslides/mediafiles/migrations/0002_mediafile_private.py +++ b/openslides/mediafiles/migrations/0002_mediafile_private.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.9.6 on 2016-05-14 12:47 +# Generated by Django 1.10.4 on 2016-12-13 10:53 from __future__ import unicode_literals from django.db import migrations, models @@ -12,9 +12,17 @@ class Migration(migrations.Migration): ] operations = [ + migrations.AlterModelOptions( + name='mediafile', + options={'default_permissions': (), 'ordering': ['title'], 'permissions': ( + ('can_see', 'Can see the list of files'), + ('can_see_hidden', 'Can see hidden files'), + ('can_upload', 'Can upload files'), + ('can_manage', 'Can manage files'))}, + ), migrations.AddField( model_name='mediafile', - name='private', + name='hidden', field=models.BooleanField(default=False), ), ] diff --git a/openslides/mediafiles/migrations/0003_auto_20160514_1347.py b/openslides/mediafiles/migrations/0003_auto_20160514_1347.py deleted file mode 100644 index 82d4a0d9a..000000000 --- a/openslides/mediafiles/migrations/0003_auto_20160514_1347.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.6 on 2016-05-14 13:47 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('mediafiles', '0002_mediafile_private'), - ] - - operations = [ - migrations.AlterModelOptions( - name='mediafile', - options={ - 'default_permissions': (), - 'ordering': ['title'], - 'permissions': ( - ('can_see', 'Can see the list of files'), - ('can_see_private', 'Can see private files'), - ('can_upload', 'Can upload files'), - ('can_manage', 'Can manage files'))}, - ), - ] diff --git a/openslides/mediafiles/migrations/0004_auto_20161212_1612.py b/openslides/mediafiles/migrations/0004_auto_20161212_1612.py deleted file mode 100644 index 2d5b04366..000000000 --- a/openslides/mediafiles/migrations/0004_auto_20161212_1612.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.4 on 2016-12-12 15:12 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('mediafiles', '0003_auto_20160514_1347'), - ] - - operations = [ - migrations.AlterModelOptions( - name='mediafile', - options={ - 'default_permissions': (), - 'ordering': ['title'], - 'permissions': ( - ('can_see', 'Can see the list of files'), - ('can_see_hidden', 'Can see hidden files'), - ('can_upload', 'Can upload files'), - ('can_manage', 'Can manage files'))}, - ), - migrations.RenameField( - model_name='mediafile', - old_name='private', - new_name='hidden', - ), - ] diff --git a/openslides/motions/migrations/0002_misc_features.py b/openslides/motions/migrations/0002_misc_features.py new file mode 100644 index 000000000..f8c077ea2 --- /dev/null +++ b/openslides/motions/migrations/0002_misc_features.py @@ -0,0 +1,157 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.4 on 2016-12-11 21:23 +from __future__ import unicode_literals + +import django.db.models.deletion +import jsonfield.fields +from django.conf import settings +from django.db import migrations, models + +import openslides.utils.models + + +def change_label_of_state(apps, schema_editor): + """ + Changes the label of former state "commited a bill" to "refered to committee". + """ + # We get the model from the versioned app registry; + # if we directly import it, it will be the wrong version. + State = apps.get_model('motions', 'State') + + try: + state = State.objects.get(name='commited a bill') + except State.DoesNotExist: + # State does not exists, there is nothing to change. + pass + else: + state.name = 'refered to committee' + state.action_word = 'Refer to committee' + state.save(skip_autoupdate=True) + + +def add_recommendation_labels(apps, schema_editor): + """ + Adds recommendation labels to some of the built-in states. + """ + # We get the model from the versioned app registry; + # if we directly import it, it will be the wrong version. + State = apps.get_model('motions', 'State') + + name_label_map = { + 'accepted': 'Acceptance', + 'rejected': 'Rejection', + 'not decided': 'No decision', + 'permitted': 'Permission', + 'adjourned': 'Adjournment', + 'not concerned': 'No concernment', + 'refered to committee': 'Referral to committee', + 'rejected (not authorized)': 'Rejection (not authorized)', + } + for state in State.objects.all(): + if name_label_map.get(state.name): + state.recommendation_label = name_label_map[state.name] + state.save(skip_autoupdate=True) + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('motions', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='MotionBlock', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=255)), + ], + options={ + 'default_permissions': (), + }, + bases=(openslides.utils.models.RESTModelMixin, models.Model), + ), + migrations.CreateModel( + name='MotionChangeRecommendation', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('rejected', models.BooleanField(default=False)), + ('type', models.PositiveIntegerField(default=0)), + ('line_from', models.PositiveIntegerField()), + ('line_to', models.PositiveIntegerField()), + ('text', models.TextField(blank=True)), + ('creation_time', models.DateTimeField(auto_now=True)), + ('author', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), + ('motion_version', models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, related_name='change_recommendations', to='motions.MotionVersion')), + ], + options={ + 'default_permissions': (), + }, + bases=(openslides.utils.models.RESTModelMixin, models.Model), + ), + migrations.AlterModelOptions( + name='motion', + options={ + 'default_permissions': (), + 'ordering': ( + 'identifier', + ), + 'permissions': ( + ('can_see', 'Can see motions'), + ('can_create', 'Can create motions'), + ('can_support', 'Can support motions'), + ('can_see_and_manage_comments', 'Can see and manage comments'), + ('can_manage', 'Can manage motions') + ), + 'verbose_name': 'Motion', + }, + ), + migrations.AddField( + model_name='motion', + name='comments', + field=jsonfield.fields.JSONField(null=True), + ), + migrations.AddField( + model_name='motion', + name='origin', + field=models.CharField(blank=True, max_length=255), + ), + migrations.AddField( + model_name='motion', + name='recommendation', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='motions.State'), + ), + migrations.AddField( + model_name='state', + name='recommendation_label', + field=models.CharField(max_length=255, null=True), + ), + migrations.AddField( + model_name='state', + name='show_recommendation_extension_field', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='state', + name='show_state_extension_field', + field=models.BooleanField(default=False), + ), + migrations.AlterField( + model_name='motion', + name='state', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='motions.State'), + ), + migrations.AddField( + model_name='motion', + name='motion_block', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='motions.MotionBlock'), + ), + migrations.RunPython( + change_label_of_state + ), + migrations.RunPython( + add_recommendation_labels + ), + ] diff --git a/openslides/motions/migrations/0002_motion_origin.py b/openslides/motions/migrations/0002_motion_origin.py deleted file mode 100644 index 55887d1a6..000000000 --- a/openslides/motions/migrations/0002_motion_origin.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.7 on 2016-07-13 14:25 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('motions', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='motion', - name='origin', - field=models.CharField(blank=True, max_length=255), - ), - ] diff --git a/openslides/motions/migrations/0003_auto_20160819_0925.py b/openslides/motions/migrations/0003_auto_20160819_0925.py deleted file mode 100644 index 44f3914ca..000000000 --- a/openslides/motions/migrations/0003_auto_20160819_0925.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.7 on 2016-08-19 09:25 -from __future__ import unicode_literals - -import jsonfield.fields -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('motions', '0002_motion_origin'), - ] - - operations = [ - migrations.AlterModelOptions( - name='motion', - options={ - 'default_permissions': (), - 'ordering': ('identifier',), - 'permissions': ( - ('can_see', 'Can see motions'), - ('can_create', 'Can create motions'), - ('can_support', 'Can support motions'), - ('can_see_and_manage_comments', 'Can see and manage comments'), - ('can_manage', 'Can manage motions')), - 'verbose_name': 'Motion'}, - ), - migrations.AddField( - model_name='motion', - name='comments', - field=jsonfield.fields.JSONField(null=True), - ), - ] diff --git a/openslides/motions/migrations/0004_auto_20160907_2343.py b/openslides/motions/migrations/0004_auto_20160907_2343.py deleted file mode 100644 index 1b5739681..000000000 --- a/openslides/motions/migrations/0004_auto_20160907_2343.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.8 on 2016-09-07 23:43 -from __future__ import unicode_literals - -import django.db.models.deletion -from django.db import migrations, models - - -def change_label_of_state(apps, schema_editor): - """ - Changes the label of former state "commited a bill" to "refered to committee". - """ - # We get the model from the versioned app registry; - # if we directly import it, it will be the wrong version. - State = apps.get_model('motions', 'State') - - try: - state = State.objects.get(name='commited a bill') - except State.DoesNotExist: - # State does not exists, there is nothing to change. - pass - else: - state.name = 'refered to committee' - state.action_word = 'Refer to committee' - state.save(skip_autoupdate=True) - - -def add_recommendation_labels(apps, schema_editor): - """ - Adds recommendation labels to some of the built-in states. - """ - # We get the model from the versioned app registry; - # if we directly import it, it will be the wrong version. - State = apps.get_model('motions', 'State') - - name_label_map = { - 'accepted': 'Acceptance', - 'rejected': 'Rejection', - 'not decided': 'No decision', - 'permitted': 'Permission', - 'adjourned': 'Adjournment', - 'not concerned': 'No concernment', - 'refered to committee': 'Referral to committee', - 'rejected (not authorized)': 'Rejection (not authorized)', - } - for state in State.objects.all(): - if name_label_map.get(state.name): - state.recommendation_label = name_label_map[state.name] - state.save(skip_autoupdate=True) - - -class Migration(migrations.Migration): - - dependencies = [ - ('motions', '0003_auto_20160819_0925'), - ] - - operations = [ - migrations.AddField( - model_name='motion', - name='recommendation', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='motions.State'), - ), - migrations.AddField( - model_name='state', - name='recommendation_label', - field=models.CharField(max_length=255, null=True), - ), - migrations.AlterField( - model_name='motion', - name='state', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='motions.State'), - ), - migrations.RunPython( - change_label_of_state - ), - migrations.RunPython( - add_recommendation_labels - ), - ] diff --git a/openslides/motions/migrations/0005_motionchangerecommendation.py b/openslides/motions/migrations/0005_motionchangerecommendation.py deleted file mode 100644 index 44d34cd1a..000000000 --- a/openslides/motions/migrations/0005_motionchangerecommendation.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.1 on 2016-10-12 18:10 -from __future__ import unicode_literals - -import django.db.models.deletion -from django.conf import settings -from django.db import migrations, models - -import openslides.utils.models - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('motions', '0004_auto_20160907_2343'), - ] - - operations = [ - migrations.CreateModel( - name='MotionChangeRecommendation', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('status', models.PositiveIntegerField(default=0)), - ('line_from', models.PositiveIntegerField()), - ('line_to', models.PositiveIntegerField()), - ('text', models.TextField(blank=True)), - ('creation_time', models.DateTimeField(auto_now=True)), - ('author', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), - ('motion_version', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, - related_name='change_recommendations', to='motions.MotionVersion')), - ], - options={ - 'default_permissions': (), - }, - bases=(openslides.utils.models.RESTModelMixin, models.Model), - ), - ] diff --git a/openslides/motions/migrations/0006_auto_20161017_2020.py b/openslides/motions/migrations/0006_auto_20161017_2020.py deleted file mode 100644 index 2070ebc63..000000000 --- a/openslides/motions/migrations/0006_auto_20161017_2020.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.2 on 2016-10-17 18:20 -from __future__ import unicode_literals - -import django.db.models.deletion -from django.db import migrations, models - -import openslides.utils.models - - -class Migration(migrations.Migration): - - dependencies = [ - ('motions', '0005_motionchangerecommendation'), - ] - - operations = [ - migrations.CreateModel( - name='MotionBlock', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('title', models.CharField(max_length=255)), - ], - options={ - 'default_permissions': (), - }, - bases=(openslides.utils.models.RESTModelMixin, models.Model), - ), - migrations.AddField( - model_name='motion', - name='motion_block', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='motions.MotionBlock'), - ), - ] diff --git a/openslides/motions/migrations/0007_auto_20161027_1406.py b/openslides/motions/migrations/0007_auto_20161027_1406.py deleted file mode 100644 index 90e3abc03..000000000 --- a/openslides/motions/migrations/0007_auto_20161027_1406.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.2 on 2016-10-27 12:06 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('motions', '0006_auto_20161017_2020'), - ] - - operations = [ - migrations.AddField( - model_name='state', - name='show_recommendation_extension_field', - field=models.BooleanField(default=False), - ), - migrations.AddField( - model_name='state', - name='show_state_extension_field', - field=models.BooleanField(default=False), - ), - ] diff --git a/openslides/motions/migrations/0008_auto_20161116_2222.py b/openslides/motions/migrations/0008_auto_20161116_2222.py deleted file mode 100644 index 06eecba7d..000000000 --- a/openslides/motions/migrations/0008_auto_20161116_2222.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.1 on 2016-11-16 21:22 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('motions', '0007_auto_20161027_1406'), - ] - - operations = [ - migrations.RemoveField( - model_name='motionchangerecommendation', - name='status', - ), - migrations.AddField( - model_name='motionchangerecommendation', - name='rejected', - field=models.BooleanField(default=False), - ), - ] diff --git a/openslides/motions/migrations/0009_motionchangerecommendation_type.py b/openslides/motions/migrations/0009_motionchangerecommendation_type.py deleted file mode 100644 index b9dc7b5ea..000000000 --- a/openslides/motions/migrations/0009_motionchangerecommendation_type.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.3 on 2016-11-19 10:29 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('motions', '0008_auto_20161116_2222'), - ] - - operations = [ - migrations.AddField( - model_name='motionchangerecommendation', - name='type', - field=models.PositiveIntegerField(default=0), - ), - ] diff --git a/openslides/users/migrations/0002_user_is_committee.py b/openslides/users/migrations/0002_user_is_committee.py deleted file mode 100644 index 288b82010..000000000 --- a/openslides/users/migrations/0002_user_is_committee.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.7 on 2016-06-30 12:41 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('users', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='user', - name='is_committee', - field=models.BooleanField(default=False), - ), - ] diff --git a/openslides/users/migrations/0004_groups.py b/openslides/users/migrations/0002_user_misc_default_groups.py similarity index 76% rename from openslides/users/migrations/0004_groups.py rename to openslides/users/migrations/0002_user_misc_default_groups.py index 1adc3428c..810af7445 100644 --- a/openslides/users/migrations/0004_groups.py +++ b/openslides/users/migrations/0002_user_misc_default_groups.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.9.7 on 2016-08-01 14:54 +# Generated by Django 1.10.3 on 2016-11-14 11:16 from __future__ import unicode_literals -from django.db import migrations +from django.db import migrations, models def migrate_groups_and_user_permissions(apps, schema_editor): @@ -51,9 +51,22 @@ def migrate_groups_and_user_permissions(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ('users', '0003_user_number'), + ('auth', '0008_alter_user_username_max_length'), + ('users', '0001_initial'), ] operations = [ - migrations.RunPython(migrate_groups_and_user_permissions), + migrations.AddField( + model_name='user', + name='is_committee', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='user', + name='number', + field=models.CharField(blank=True, default='', max_length=50), + ), + migrations.RunPython( + migrate_groups_and_user_permissions + ), ] diff --git a/openslides/users/migrations/0003_user_number.py b/openslides/users/migrations/0003_user_number.py deleted file mode 100644 index 67ac02140..000000000 --- a/openslides/users/migrations/0003_user_number.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.7 on 2016-08-01 14:54 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('users', '0002_user_is_committee'), - ] - - operations = [ - migrations.AddField( - model_name='user', - name='number', - field=models.CharField(blank=True, default='', max_length=50), - ), - ]