Separate motion state access level migration
This commit is contained in:
parent
841d80a35b
commit
06147affe5
@ -3,21 +3,8 @@
|
|||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
def transform_required_permission_to_see_field(apps, schema_editor):
|
|
||||||
"""
|
|
||||||
Sets new access_level of states to EXTENDED_MANAGERS_AND_SUBMITTER
|
|
||||||
if required_permission_to_see is given
|
|
||||||
"""
|
|
||||||
# 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")
|
|
||||||
for state in State.objects.all():
|
|
||||||
if state.required_permission_to_see:
|
|
||||||
state.access_level = 1
|
|
||||||
state.save(skip_autoupdate=True)
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
""" Note: this is a combined migration to execute code in a seperate transaction """
|
||||||
|
|
||||||
dependencies = [("motions", "0020_auto_20190119_1425")]
|
dependencies = [("motions", "0020_auto_20190119_1425")]
|
||||||
|
|
||||||
@ -37,7 +24,5 @@ class Migration(migrations.Migration):
|
|||||||
],
|
],
|
||||||
default=0,
|
default=0,
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
migrations.RunPython(transform_required_permission_to_see_field),
|
|
||||||
migrations.RemoveField(model_name="state", name="required_permission_to_see"),
|
|
||||||
]
|
]
|
24
openslides/motions/migrations/0021_state_access_level_2.py
Normal file
24
openslides/motions/migrations/0021_state_access_level_2.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Generated by Django 2.1.5 on 2019-02-01 11:58
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
def transform_required_permission_to_see_field(apps, schema_editor):
|
||||||
|
"""
|
||||||
|
Sets new access_level of states to EXTENDED_MANAGERS_AND_SUBMITTER
|
||||||
|
if required_permission_to_see is given
|
||||||
|
"""
|
||||||
|
# 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")
|
||||||
|
for state in State.objects.all():
|
||||||
|
if state.required_permission_to_see:
|
||||||
|
state.access_level = 1
|
||||||
|
state.save(skip_autoupdate=True)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [("motions", "0021_state_access_level_1")]
|
||||||
|
|
||||||
|
operations = [migrations.RunPython(transform_required_permission_to_see_field)]
|
12
openslides/motions/migrations/0021_state_access_level_3.py
Normal file
12
openslides/motions/migrations/0021_state_access_level_3.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Generated by Django 2.1.5 on 2019-02-01 11:58
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [("motions", "0021_state_access_level_2")]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(model_name="state", name="required_permission_to_see")
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user