mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-21 01:48:21 +02:00
Use migrations instead of fixtures to create BDE, Kfet and special notes
This commit is contained in:
57
apps/member/migrations/0003_create_bde_and_kfet.py
Normal file
57
apps/member/migrations/0003_create_bde_and_kfet.py
Normal file
@ -0,0 +1,57 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def create_bde_and_kfet(apps, schema_editor):
|
||||
"""
|
||||
The clubs BDE and Kfet are pre-injected.
|
||||
"""
|
||||
Club = apps.get_model("member", "club")
|
||||
NoteClub = apps.get_model("note", "noteclub")
|
||||
ContentType = apps.get_model('contenttypes', 'ContentType')
|
||||
polymorphic_ctype_id = ContentType.objects.get_for_model(NoteClub).id
|
||||
|
||||
Club.objects.get_or_create(
|
||||
id=1,
|
||||
name="BDE",
|
||||
email="tresorerie.bde@example.com",
|
||||
require_memberships=True,
|
||||
membership_fee_paid=500,
|
||||
membership_fee_unpaid=500,
|
||||
membership_duration=396,
|
||||
membership_start="2020-08-01",
|
||||
membership_end="2021-09-30",
|
||||
)
|
||||
Club.objects.get_or_create(
|
||||
id=2,
|
||||
name="Kfet",
|
||||
parent_club_id=1,
|
||||
email="tresorerie.bde@example.com",
|
||||
require_memberships=True,
|
||||
membership_fee_paid=500,
|
||||
membership_fee_unpaid=500,
|
||||
membership_duration=396,
|
||||
membership_start="2020-08-01",
|
||||
membership_end="2021-09-30",
|
||||
)
|
||||
|
||||
NoteClub.objects.get_or_create(
|
||||
id=5,
|
||||
club_id=1,
|
||||
polymorphic_ctype_id=polymorphic_ctype_id,
|
||||
)
|
||||
NoteClub.objects.get_or_create(
|
||||
id=6,
|
||||
club_id=2,
|
||||
polymorphic_ctype_id=polymorphic_ctype_id,
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('member', '0002_auto_20200904_2341'),
|
||||
('note', '0002_create_special_notes'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(create_bde_and_kfet),
|
||||
]
|
Reference in New Issue
Block a user