#112 WIP: Restructure CompensationAction
* changes action_type from ForeignKey into M2M * adds migration * changes form widget * WIP: changes rendering on detail view of compensation * TEST NOT CHECKED YET!pull/115/head
parent
1028c19f87
commit
2b66189590
@ -0,0 +1,39 @@
|
|||||||
|
# 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',
|
||||||
|
)
|
||||||
|
]
|
Loading…
Reference in New Issue