OpenSlides/openslides/core/migrations/0008_countdown_message.py

108 lines
3.9 KiB
Python
Raw Normal View History

# -*- 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),
]