gestioCOF/kfet/migrations/0067_deleted_account.py

33 lines
1 KiB
Python
Raw Normal View History

# Generated by Django 2.2 on 2019-05-23 13:54
from django.db import migrations, models
from kfet import KFET_DELETED_TRIGRAMME, KFET_DELETED_USERNAME
def setup_kfet_deleted_user(apps, schema_editor):
"""
Setup models instances for the kfet deleted account.
Username and trigramme are retrieved from kfet.__init__ module.
Other data are registered here.
"""
User = apps.get_model("auth", "User")
CofProfile = apps.get_model("gestioncof", "CofProfile")
Account = apps.get_model("kfet", "Account")
user, _ = User.objects.update_or_create(
username=KFET_DELETED_USERNAME, defaults={"first_name": "Compte K-Fêt supprimé"}
)
profile, _ = CofProfile.objects.update_or_create(user=user)
account, _ = Account.objects.update_or_create(
cofprofile=profile, defaults={"trigramme": KFET_DELETED_TRIGRAMME}
)
class Migration(migrations.Migration):
dependencies = [("kfet", "0066_on_delete_actions")]
operations = [migrations.RunPython(setup_kfet_deleted_user)]