diff --git a/apps/member/fixtures/initial.json b/apps/member/fixtures/initial.json deleted file mode 100644 index e27eb72d..00000000 --- a/apps/member/fixtures/initial.json +++ /dev/null @@ -1,31 +0,0 @@ -[ - { - "model": "member.club", - "pk": 1, - "fields": { - "name": "BDE", - "email": "tresorerie.bde@example.com", - "require_memberships": true, - "membership_fee_paid": 500, - "membership_fee_unpaid": 500, - "membership_duration": 396, - "membership_start": "2019-08-31", - "membership_end": "2020-09-30" - } - }, - { - "model": "member.club", - "pk": 2, - "fields": { - "name": "Kfet", - "email": "tresorerie.bde@example.com", - "parent_club": 1, - "require_memberships": true, - "membership_fee_paid": 3500, - "membership_fee_unpaid": 3500, - "membership_duration": 396, - "membership_start": "2019-08-31", - "membership_end": "2020-09-30" - } - } -] diff --git a/apps/member/migrations/0003_create_bde_and_kfet.py b/apps/member/migrations/0003_create_bde_and_kfet.py new file mode 100644 index 00000000..0464569f --- /dev/null +++ b/apps/member/migrations/0003_create_bde_and_kfet.py @@ -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), + ] diff --git a/apps/note/fixtures/initial.json b/apps/note/fixtures/initial.json deleted file mode 100644 index 72853eb7..00000000 --- a/apps/note/fixtures/initial.json +++ /dev/null @@ -1,188 +0,0 @@ -[ - { - "model": "note.note", - "pk": 1, - "fields": { - "polymorphic_ctype": [ - "note", - "notespecial" - ], - "balance": 0, - "last_negative": null, - "is_active": true, - "display_image": "", - "created_at": "2020-02-20T20:02:48.778Z" - } - }, - { - "model": "note.note", - "pk": 2, - "fields": { - "polymorphic_ctype": [ - "note", - "notespecial" - ], - "balance": 0, - "last_negative": null, - "is_active": true, - "display_image": "", - "created_at": "2020-02-20T20:06:39.546Z" - } - }, - { - "model": "note.note", - "pk": 3, - "fields": { - "polymorphic_ctype": [ - "note", - "notespecial" - ], - "balance": 0, - "last_negative": null, - "is_active": true, - "display_image": "", - "created_at": "2020-02-20T20:06:43.049Z" - } - }, - { - "model": "note.note", - "pk": 4, - "fields": { - "polymorphic_ctype": [ - "note", - "notespecial" - ], - "balance": 0, - "last_negative": null, - "is_active": true, - "display_image": "", - "created_at": "2020-02-20T20:06:50.996Z" - } - }, - { - "model": "note.note", - "pk": 5, - "fields": { - "polymorphic_ctype": [ - "note", - "noteclub" - ], - "balance": 0, - "last_negative": null, - "is_active": true, - "display_image": "pic/default.png", - "created_at": "2020-02-20T20:09:38.615Z" - } - }, - { - "model": "note.note", - "pk": 6, - "fields": { - "polymorphic_ctype": [ - "note", - "noteclub" - ], - "balance": 0, - "last_negative": null, - "is_active": true, - "display_image": "pic/default.png", - "created_at": "2020-02-20T20:16:14.753Z" - } - }, - { - "model": "note.noteclub", - "pk": 5, - "fields": { - "club": 1 - } - }, - { - "model": "note.noteclub", - "pk": 6, - "fields": { - "club": 2 - } - }, - { - "model": "note.notespecial", - "pk": 1, - "fields": { - "special_type": "Esp\u00e8ces" - } - }, - { - "model": "note.notespecial", - "pk": 2, - "fields": { - "special_type": "Carte bancaire" - } - }, - { - "model": "note.notespecial", - "pk": 3, - "fields": { - "special_type": "Ch\u00e8que" - } - }, - { - "model": "note.notespecial", - "pk": 4, - "fields": { - "special_type": "Virement bancaire" - } - }, - { - "model": "note.alias", - "pk": 1, - "fields": { - "name": "Esp\u00e8ces", - "normalized_name": "especes", - "note": 1 - } - }, - { - "model": "note.alias", - "pk": 2, - "fields": { - "name": "Carte bancaire", - "normalized_name": "cartebancaire", - "note": 2 - } - }, - { - "model": "note.alias", - "pk": 3, - "fields": { - "name": "Ch\u00e8que", - "normalized_name": "cheque", - "note": 3 - } - }, - { - "model": "note.alias", - "pk": 4, - "fields": { - "name": "Virement bancaire", - "normalized_name": "virementbancaire", - "note": 4 - } - }, - { - "model": "note.alias", - "pk": 5, - "fields": { - "name": "BDE", - "normalized_name": "bde", - "note": 5 - } - }, - { - "model": "note.alias", - "pk": 6, - "fields": { - "name": "Kfet", - "normalized_name": "kfet", - "note": 6 - } - } -] \ No newline at end of file diff --git a/apps/note/migrations/0002_create_special_notes.py b/apps/note/migrations/0002_create_special_notes.py new file mode 100644 index 00000000..12fa8583 --- /dev/null +++ b/apps/note/migrations/0002_create_special_notes.py @@ -0,0 +1,25 @@ +from django.db import migrations + + +def create_special_notes(apps, schema_editor): + """ + We create the four special note to make transfers. + """ + NoteSpecial = apps.get_model("note", "notespecial") + ContentType = apps.get_model('contenttypes', 'ContentType') + polymorphic_ctype_id = ContentType.objects.get_for_model(NoteSpecial).id + + NoteSpecial.objects.get_or_create(id=1, special_type="Espèces", polymorphic_ctype_id=polymorphic_ctype_id) + NoteSpecial.objects.get_or_create(id=2, special_type="Carte bancaire", polymorphic_ctype_id=polymorphic_ctype_id) + NoteSpecial.objects.get_or_create(id=3, special_type="Chèque", polymorphic_ctype_id=polymorphic_ctype_id) + NoteSpecial.objects.get_or_create(id=4, special_type="Virement bancaire", polymorphic_ctype_id=polymorphic_ctype_id) + + +class Migration(migrations.Migration): + dependencies = [ + ('note', '0001_initial'), + ] + + operations = [ + migrations.RunPython(create_special_notes), + ]