mpeltriaux
3814c2749a
* changes action_type from ForeignKey into M2M * adds migration * changes form widget * WIP: changes rendering on detail view of compensation * TEST NOT CHECKED YET!
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
# Generated by Django 3.1.3 on 2022-02-10 13:02
|
|
|
|
from django.db import migrations, models
|
|
|
|
|
|
def migrate_actions(apps, schema_editor):
|
|
CompensationAction = apps.get_model('compensation', 'CompensationAction')
|
|
actions = CompensationAction.objects.all()
|
|
|
|
for action in actions:
|
|
action_type = action.action_type or []
|
|
action.action_type_tmp.set(action_type)
|
|
action.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('codelist', '0001_initial'),
|
|
('compensation', '0003_auto_20220202_0846'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name='compensationaction',
|
|
name='action_type_tmp',
|
|
field=models.ManyToManyField(blank=True, limit_choices_to={'code_lists__in': [1026], 'is_archived': False, 'is_selectable': True}, related_name='_compensationaction_action_type_+', to='codelist.KonovaCode'),
|
|
),
|
|
migrations.RunPython(migrate_actions),
|
|
migrations.RemoveField(
|
|
model_name='compensationaction',
|
|
name='action_type',
|
|
),
|
|
migrations.RenameField(
|
|
model_name='compensationaction',
|
|
old_name='action_type_tmp',
|
|
new_name='action_type',
|
|
)
|
|
]
|