From a304f6a97db2e575b93747432add690b157eac05 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Thu, 20 Feb 2020 22:10:10 +0100 Subject: [PATCH] Some initial data --- apps/member/fixtures/initial.json | 26 ++++ apps/note/fixtures/initial.json | 220 ++++++++++++++++++++++++++++++ apps/note/signals.py | 12 +- 3 files changed, 256 insertions(+), 2 deletions(-) create mode 100644 apps/member/fixtures/initial.json create mode 100644 apps/note/fixtures/initial.json diff --git a/apps/member/fixtures/initial.json b/apps/member/fixtures/initial.json new file mode 100644 index 00000000..7ff10c91 --- /dev/null +++ b/apps/member/fixtures/initial.json @@ -0,0 +1,26 @@ +[ + { + "model": "member.club", + "pk": 1, + "fields": { + "name": "BDE", + "email": "tresorerie.bde@example.com", + "membership_fee": 5, + "membership_duration": "365 00:00:00", + "membership_start": "00:00:00", + "membership_end": "365 00:00:00" + } + }, + { + "model": "member.club", + "pk": 2, + "fields": { + "name": "Kfet", + "email": "tresorerie.bde@example.com", + "membership_fee": 35, + "membership_duration": "365 00:00:00", + "membership_start": "00:00:00", + "membership_end": "365 00:00:00" + } + } +] \ No newline at end of file diff --git a/apps/note/fixtures/initial.json b/apps/note/fixtures/initial.json new file mode 100644 index 00000000..f853d3cb --- /dev/null +++ b/apps/note/fixtures/initial.json @@ -0,0 +1,220 @@ +[ + { + "model": "note.note", + "pk": 1, + "fields": { + "polymorphic_ctype": 22, + "balance": 0, + "is_active": true, + "display_image": "", + "created_at": "2020-02-20T20:02:48.778Z" + } + }, + { + "model": "note.note", + "pk": 2, + "fields": { + "polymorphic_ctype": 22, + "balance": 0, + "is_active": true, + "display_image": "", + "created_at": "2020-02-20T20:06:39.546Z" + } + }, + { + "model": "note.note", + "pk": 3, + "fields": { + "polymorphic_ctype": 22, + "balance": 0, + "is_active": true, + "display_image": "", + "created_at": "2020-02-20T20:06:43.049Z" + } + }, + { + "model": "note.note", + "pk": 4, + "fields": { + "polymorphic_ctype": 22, + "balance": 0, + "is_active": true, + "display_image": "", + "created_at": "2020-02-20T20:06:50.996Z" + } + }, + { + "model": "note.note", + "pk": 5, + "fields": { + "polymorphic_ctype": 21, + "balance": 0, + "is_active": true, + "display_image": "", + "created_at": "2020-02-20T20:09:38.615Z" + } + }, + { + "model": "note.note", + "pk": 6, + "fields": { + "polymorphic_ctype": 21, + "balance": 0, + "is_active": true, + "display_image": "", + "created_at": "2020-02-20T20:16:14.753Z" + } + }, + { + "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.noteclub", + "pk": 5, + "fields": { + "club": 1 + } + }, + { + "model": "note.noteclub", + "pk": 6, + "fields": { + "club": 2 + } + }, + { + "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 + } + }, + { + "model": "note.transactioncategory", + "pk": 1, + "fields": { + "name": "Soft" + } + }, + { + "model": "note.transactioncategory", + "pk": 2, + "fields": { + "name": "Pulls" + } + }, + { + "model": "note.transactioncategory", + "pk": 3, + "fields": { + "name": "Gala" + } + }, + { + "model": "note.transactioncategory", + "pk": 4, + "fields": { + "name": "Clubs" + } + }, + { + "model": "note.transactioncategory", + "pk": 5, + "fields": { + "name": "Bouffe" + } + }, + { + "model": "note.transactioncategory", + "pk": 6, + "fields": { + "name": "BDA" + } + }, + { + "model": "note.transactioncategory", + "pk": 7, + "fields": { + "name": "Autre" + } + }, + { + "model": "note.transactioncategory", + "pk": 8, + "fields": { + "name": "Alcool" + } + } +] \ No newline at end of file diff --git a/apps/note/signals.py b/apps/note/signals.py index ad376ee0..e62115b3 100644 --- a/apps/note/signals.py +++ b/apps/note/signals.py @@ -2,20 +2,28 @@ # SPDX-License-Identifier: GPL-3.0-or-later -def save_user_note(instance, created, **_kwargs): +def save_user_note(instance, created, raw, **_kwargs): """ Hook to create and save a note when an user is updated """ + if raw: + # When provisionning data, do not try to autocreate + return + if created: from .models import NoteUser NoteUser.objects.create(user=instance) instance.note.save() -def save_club_note(instance, created, **_kwargs): +def save_club_note(instance, created, raw, **_kwargs): """ Hook to create and save a note when a club is updated """ + if raw: + # When provisionning data, do not try to autocreate + return + if created: from .models import NoteClub NoteClub.objects.create(club=instance)