forked from DGNum/gestioCOF
Add RunPython script to migration
This commit is contained in:
parent
44fbc92893
commit
608e67fe6a
1 changed files with 34 additions and 0 deletions
34
kfet/migrations/0049_auto_20170325_0110.py
Normal file
34
kfet/migrations/0049_auto_20170325_0110.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def adapt_operation_types(apps, schema_editor):
|
||||
Operation = apps.get_model("kfet", "Operation")
|
||||
|
||||
for ope in Operation.objects.all():
|
||||
if (not ope.is_checkout and
|
||||
ope.type in ['deposit', 'withdraw']):
|
||||
ope.type = 'edit'
|
||||
ope.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('kfet', '0048_article_hidden'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='operation',
|
||||
name='type',
|
||||
field=models.CharField(choices=[('purchase', 'Achat'), ('deposit', 'Charge'), ('withdraw', 'Retrait'), ('initial', 'Initial'), ('edit', 'Édition')], max_length=8),
|
||||
),
|
||||
migrations.RunPython(adapt_operation_types),
|
||||
migrations.RemoveField(
|
||||
model_name='operation',
|
||||
name='is_checkout',
|
||||
),
|
||||
]
|
Loading…
Reference in a new issue