|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +from __future__ import unicode_literals |
| 3 | + |
| 4 | +from django.db import migrations |
| 5 | + |
| 6 | +floors = [ |
| 7 | + (1, "Berlin Intercontinental Floor 1", 1, 'floor/floorplan-96-berlin-intercontinental-floor-1.jpg'), |
| 8 | + (2, "Berlin Intercontinental Floor 1", 2, 'floor/floorplan-96-berlin-intercontinental-floor-2.jpg'), |
| 9 | + (3, "Berlin Intercontinental Floor 1", 14, 'floor/floorplan-96-berlin-intercontinental-floor-14.jpg'), |
| 10 | +] |
| 11 | + |
| 12 | +rooms = [ |
| 13 | + ("Bellevue", 1, 176, 1348, 324, 1526), |
| 14 | + ("Kaminzimmer", 1, 696, 820, 812, 1038), |
| 15 | + ("Charlottenburg I", 1, 374, 320, 528, 400), |
| 16 | + ("Charlottenburg II/III", 1, 374, 172, 528, 316), |
| 17 | + ("Chess", 2, 238, 614, 336, 782), |
| 18 | + ("Glienicke", 1, 228, 1251, 324, 1310), |
| 19 | + ("Hugos 360", 3, 801, 1346, 976, 1509), |
| 20 | + ("King", 2, 802, 1389, 890, 1508), |
| 21 | + ("Koepenick I/II", 1, 370, 453, 458, 602), |
| 22 | + ("Lincke", 2, 40, 99, 532, 166), |
| 23 | + ("Potsdam I", 1, 1228, 790, 1550, 994), |
| 24 | + ("Potsdam I/III", 1, 1017, 792, 1550, 994), |
| 25 | + ("Potsdam II", 1, 1311, 1036, 1536, 1142), |
| 26 | + ("Potsdam III", 1, 1017, 792, 1228, 987), |
| 27 | + ("Rook", 2, 915, 1150, 1004, 1269), |
| 28 | + ("Schoeneberg", 1, 369, 42, 534, 126), |
| 29 | + ("Tegel", 1, 201, 1088, 326, 1184), |
| 30 | + ("Tiergarten", 1, 240, 612, 334, 780), |
| 31 | + ("Wintergarten/Pavillion", 1, 466, 1038, 711, 1504), |
| 32 | +] |
| 33 | + |
| 34 | +def forward(apps, schema_editor): |
| 35 | + FloorPlan = apps.get_model('meeting','FloorPlan') |
| 36 | + Room = apps.get_model('meeting','Room') |
| 37 | + Meeting = apps.get_model('meeting','Meeting') |
| 38 | + meeting = Meeting.objects.get(number='96') |
| 39 | + for item in floors: |
| 40 | + id, name, order, image = item |
| 41 | + f = FloorPlan(id=id, name=name, meeting=meeting, order=order, image=image) |
| 42 | + f.save() |
| 43 | + |
| 44 | + for item in rooms: |
| 45 | + name, floor_id, x1, y1, x2, y2 = item |
| 46 | + room = Room.objects.get(name=name, meeting=meeting) |
| 47 | + room.floorplan_id = floor_id |
| 48 | + room.x1 = x1 |
| 49 | + room.y1 = y1 |
| 50 | + room.x2 = x2 |
| 51 | + room.y2 = y2 |
| 52 | + room.save() |
| 53 | + |
| 54 | +def backward(apps, schema_editor): |
| 55 | + pass |
| 56 | + |
| 57 | +class Migration(migrations.Migration): |
| 58 | + |
| 59 | + dependencies = [ |
| 60 | + ('meeting', '0025_add_floorplan_and_room_coordinates'), |
| 61 | + ] |
| 62 | + |
| 63 | + operations = [ |
| 64 | + migrations.RunPython(forward,backward) |
| 65 | + ] |
0 commit comments