Merge pull request #2039 from normanjaeckel/FixRawSQLQuery
Used bulk_create to create the initial projector during migration. Fi…
This commit is contained in:
commit
21d9898645
@ -2,7 +2,6 @@
|
|||||||
# Generated by Django 1.9.2 on 2016-03-02 01:22
|
# Generated by Django 1.9.2 on 2016-03-02 01:22
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import json
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
@ -13,15 +12,21 @@ from django.db import migrations, models
|
|||||||
import openslides.utils.models
|
import openslides.utils.models
|
||||||
|
|
||||||
|
|
||||||
def add_default_projector_via_sql():
|
def add_default_projector(apps, schema_editor):
|
||||||
"""
|
"""
|
||||||
Adds default projector and activates clock.
|
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.
|
||||||
|
Projector = apps.get_model('core', 'Projector')
|
||||||
projector_config = {}
|
projector_config = {}
|
||||||
projector_config[uuid.uuid4().hex] = {
|
projector_config[uuid.uuid4().hex] = {
|
||||||
'name': 'core/clock',
|
'name': 'core/clock',
|
||||||
'stable': True}
|
'stable': True}
|
||||||
return ["INSERT INTO core_projector (config, scale, scroll) VALUES ('{}', 0, 0);".format(json.dumps(projector_config))]
|
# 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):
|
class Migration(migrations.Migration):
|
||||||
@ -105,5 +110,5 @@ class Migration(migrations.Migration):
|
|||||||
},
|
},
|
||||||
bases=(openslides.utils.models.RESTModelMixin, models.Model),
|
bases=(openslides.utils.models.RESTModelMixin, models.Model),
|
||||||
),
|
),
|
||||||
migrations.RunSQL(add_default_projector_via_sql()),
|
migrations.RunPython(add_default_projector),
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user