47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Generated by Django 1.10.1 on 2016-10-06 18:53
|
|
from __future__ import unicode_literals
|
|
|
|
from django.db import migrations, models
|
|
|
|
|
|
def migrate_accommodations(apps, schema_editor):
|
|
db_alias = schema_editor.connection.alias
|
|
Participation = apps.get_model('accounts', 'Participation')
|
|
for participation in Participation.objects.using(db_alias).all():
|
|
if participation.need_hosting:
|
|
if participation.homestay:
|
|
participation.accommodation = 2
|
|
else:
|
|
participation.accommodation = 1
|
|
participation.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('accounts', '0011_auto_20161005_1841'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RenameField(
|
|
model_name='participation',
|
|
old_name='hosting_booked',
|
|
new_name='accommodation_booked',
|
|
),
|
|
migrations.AddField(
|
|
model_name='participation',
|
|
name='accommodation',
|
|
field=models.IntegerField(null=True, blank=True, choices=[(0, 'No'), (1, 'Hotel'), (2, 'Homestay')], verbose_name='Need accommodation?'),
|
|
),
|
|
migrations.RunPython(migrate_accommodations),
|
|
migrations.RemoveField(
|
|
model_name='participation',
|
|
name='need_hosting',
|
|
),
|
|
migrations.RemoveField(
|
|
model_name='participation',
|
|
name='homestay',
|
|
),
|
|
]
|