OpenSlides/openslides/core/migrations/0001_initial.py

160 lines
5.4 KiB
Python
Raw Normal View History

2016-03-02 01:29:47 +01:00
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-03-02 01:22
from __future__ import unicode_literals
2016-01-09 18:49:38 +01:00
import uuid
2016-03-02 01:29:47 +01:00
import django.db.models.deletion
import jsonfield.fields
2016-01-09 18:49:38 +01:00
from django.conf import settings
from django.db import migrations, models
import openslides.utils.models
def add_default_projector(apps, schema_editor):
"""
2016-01-09 18:49:38 +01:00
Adds default projector and activates clock.
"""
# We get the model from the versioned app registry;
# if we directly import it, it will be the wrong version.
2019-01-06 16:22:33 +01:00
Projector = apps.get_model("core", "Projector")
2016-01-09 18:49:38 +01:00
projector_config = {}
2019-01-06 16:22:33 +01:00
projector_config[uuid.uuid4().hex] = {"name": "core/clock", "stable": True}
# We use bulk_create here because we do not want model's save() method
# to be called because we do not want our autoupdate signals to be
# triggered.
Projector.objects.bulk_create([Projector(config=projector_config)])
class Migration(migrations.Migration):
2016-03-02 01:29:47 +01:00
initial = True
dependencies = [
2019-01-06 16:22:33 +01:00
("mediafiles", "0001_initial"),
2016-01-09 18:49:38 +01:00
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
2016-01-09 18:49:38 +01:00
migrations.CreateModel(
2019-01-06 16:22:33 +01:00
name="ChatMessage",
2016-01-09 18:49:38 +01:00
fields=[
2019-01-06 16:22:33 +01:00
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("message", models.TextField()),
("timestamp", models.DateTimeField(auto_now_add=True)),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
2016-01-09 18:49:38 +01:00
],
options={
2019-01-06 16:22:33 +01:00
"default_permissions": (),
"permissions": (("can_use_chat", "Can use the chat"),),
2016-01-09 18:49:38 +01:00
},
bases=(openslides.utils.models.RESTModelMixin, models.Model),
),
migrations.CreateModel(
2019-01-06 16:22:33 +01:00
name="ConfigStore",
2016-01-09 18:49:38 +01:00
fields=[
2019-01-06 16:22:33 +01:00
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("key", models.CharField(db_index=True, max_length=255, unique=True)),
("value", jsonfield.fields.JSONField()),
2016-01-09 18:49:38 +01:00
],
options={
2019-01-06 16:22:33 +01:00
"default_permissions": (),
"permissions": (("can_manage_config", "Can manage configuration"),),
2016-01-09 18:49:38 +01:00
},
),
migrations.CreateModel(
2019-01-06 16:22:33 +01:00
name="CustomSlide",
fields=[
2019-01-06 16:22:33 +01:00
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("title", models.CharField(max_length=256)),
("text", models.TextField(blank=True)),
("weight", models.IntegerField(default=0)),
(
"attachments",
models.ManyToManyField(blank=True, to="mediafiles.Mediafile"),
),
],
2019-01-06 16:22:33 +01:00
options={"default_permissions": (), "ordering": ("weight", "title")},
2015-06-29 12:08:15 +02:00
bases=(openslides.utils.models.RESTModelMixin, models.Model),
),
migrations.CreateModel(
2019-01-06 16:22:33 +01:00
name="Projector",
fields=[
2019-01-06 16:22:33 +01:00
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("config", jsonfield.fields.JSONField()),
("scale", models.IntegerField(default=0)),
("scroll", models.IntegerField(default=0)),
],
options={
2019-01-06 16:22:33 +01:00
"default_permissions": (),
"permissions": (
("can_see_projector", "Can see the projector"),
("can_manage_projector", "Can manage the projector"),
("can_see_frontpage", "Can see the front page"),
),
},
2015-06-29 12:08:15 +02:00
bases=(openslides.utils.models.RESTModelMixin, models.Model),
),
migrations.CreateModel(
2019-01-06 16:22:33 +01:00
name="Tag",
fields=[
2019-01-06 16:22:33 +01:00
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=255, unique=True)),
],
options={
2019-01-06 16:22:33 +01:00
"default_permissions": (),
"permissions": (("can_manage_tags", "Can manage tags"),),
"ordering": ("name",),
2015-06-29 12:08:15 +02:00
},
bases=(openslides.utils.models.RESTModelMixin, models.Model),
),
migrations.RunPython(add_default_projector),
]