|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# Generated by Django 1.10.7 on 2017-06-12 02:45 |
| 3 | +from __future__ import unicode_literals |
| 4 | + |
| 5 | +from django.db import migrations, models |
| 6 | + |
| 7 | + |
| 8 | +def forwards(apps, schema_editor): |
| 9 | + floors = { |
| 10 | + # id, meeting, name, short |
| 11 | + 1: ("Berlin Intercontinental Floor 1", "1"), |
| 12 | + 2: ("Berlin Intercontinental Floor 2", "2"), |
| 13 | + 3: ("Berlin Intercontinental Floor 14", "14"), |
| 14 | + 4: ("Seoul Conrad Floor 3", "3"), |
| 15 | + 5: ("Seoul Conrad Floor 5", "5"), |
| 16 | + 6: ("Seoul Conrad Floor 6", "6"), |
| 17 | + 7: ("Chicago Swissotel Ballroom Level", "BL"), |
| 18 | + 8: ("Chicago Swissotel Concourse Level", "CC"), |
| 19 | + 9: ("Chicago Swissotel Floor 2", "2"), |
| 20 | + 10:("Chicago Swissotel Floor 3", "3"), |
| 21 | + } |
| 22 | + FloorPlan = apps.get_model('meeting', "FloorPlan") |
| 23 | + for f in FloorPlan.objects.all(): |
| 24 | + name, short = floors[f.pk] |
| 25 | + assert f.name == name, ("Unexpected floorplan name. Expected '%s' for FlooPlan#%s, found '%s' in the database"%(name, f.id, f.name)) |
| 26 | + f.short = short |
| 27 | + f.save() |
| 28 | + |
| 29 | +def backwards(apps, schema_editor): |
| 30 | + pass |
| 31 | + |
| 32 | +class Migration(migrations.Migration): |
| 33 | + |
| 34 | + dependencies = [ |
| 35 | + ('meeting', '0051_auto_20170511_0449'), |
| 36 | + ] |
| 37 | + |
| 38 | + operations = [ |
| 39 | + migrations.AddField( |
| 40 | + model_name='floorplan', |
| 41 | + name='short', |
| 42 | + field=models.CharField(default=b'', max_length=2), |
| 43 | + ), |
| 44 | + migrations.RunPython(forwards, backwards), |
| 45 | + ] |
0 commit comments