2019-02-18 20:11:51 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Generated by Django 1.10.7 on 2019-02-18 16:43
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.db import migrations, models
|
|
|
|
import django.db.models.deletion
|
|
|
|
import re2o.mixins
|
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
2019-11-04 16:55:03 +00:00
|
|
|
dependencies = [("topologie", "0069_auto_20190108_1439")]
|
2019-02-18 20:11:51 +00:00
|
|
|
|
|
|
|
def create_dormitory(apps, schema_editor):
|
|
|
|
db_alias = schema_editor.connection.alias
|
|
|
|
dormitory = apps.get_model("topologie", "Dormitory")
|
|
|
|
building = apps.get_model("topologie", "Building")
|
|
|
|
dorm = dormitory.objects.using(db_alias).create(name="Residence")
|
|
|
|
building.objects.using(db_alias).update(dormitory=dorm)
|
|
|
|
|
|
|
|
def delete_dormitory(apps, schema_editor):
|
|
|
|
pass
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.CreateModel(
|
2019-11-04 16:55:03 +00:00
|
|
|
name="Dormitory",
|
2019-02-18 20:11:51 +00:00
|
|
|
fields=[
|
2019-11-04 16:55:03 +00:00
|
|
|
(
|
|
|
|
"id",
|
|
|
|
models.AutoField(
|
|
|
|
auto_created=True,
|
|
|
|
primary_key=True,
|
|
|
|
serialize=False,
|
|
|
|
verbose_name="ID",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
("name", models.CharField(max_length=255)),
|
2019-02-18 20:11:51 +00:00
|
|
|
],
|
|
|
|
options={
|
2019-11-04 16:55:03 +00:00
|
|
|
"verbose_name": "dormitory",
|
|
|
|
"permissions": (("view_dormitory", "Can view a dormitory object"),),
|
|
|
|
"verbose_name_plural": "dormitories",
|
2019-02-18 20:11:51 +00:00
|
|
|
},
|
|
|
|
bases=(re2o.mixins.AclMixin, re2o.mixins.RevMixin, models.Model),
|
|
|
|
),
|
|
|
|
migrations.AddField(
|
2019-11-04 16:55:03 +00:00
|
|
|
model_name="building",
|
|
|
|
name="dormitory",
|
|
|
|
field=models.ForeignKey(
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
on_delete=django.db.models.deletion.PROTECT,
|
|
|
|
to="topologie.Dormitory",
|
|
|
|
),
|
2019-02-18 20:11:51 +00:00
|
|
|
preserve_default=False,
|
|
|
|
),
|
2019-11-04 16:55:03 +00:00
|
|
|
migrations.RunPython(create_dormitory, delete_dormitory),
|
2019-02-18 20:11:51 +00:00
|
|
|
]
|