From 2571477bb4383aa1bf2beda1777fbcccd0636367 Mon Sep 17 00:00:00 2001 From: Maxime Bombar Date: Sun, 22 Mar 2020 13:24:54 -0400 Subject: [PATCH 1/2] Rename TemplateTransaction into RecurrentTransaction --- management/commands/import_nk15.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/management/commands/import_nk15.py b/management/commands/import_nk15.py index 7b8e7de..b036667 100644 --- a/management/commands/import_nk15.py +++ b/management/commands/import_nk15.py @@ -18,7 +18,7 @@ from django.contrib.auth.models import User from note.models import Note, NoteSpecial, NoteUser, NoteClub from note.models import Alias from note.models import Transaction, TransactionTemplate,\ - TemplateCategory, TemplateTransaction, MembershipTransaction + TemplateCategory, RecurrentTransaction, MembershipTransaction from member.models import Profile, Club, Membership """ @@ -185,7 +185,7 @@ def import_transaction(cur, map_idbde): if created: cat.save() obj_dict["category"] = cat - transac = TemplateTransaction.objects.create(**obj_dict) + transac = RecurrentTransaction.objects.create(**obj_dict) transac.save() elif row["type"] == "adhésion": print("adhesion not supported yet") From 146260b35878baa94f3298e5940777336f566668 Mon Sep 17 00:00:00 2001 From: Maxime Bombar Date: Sun, 22 Mar 2020 13:25:01 -0400 Subject: [PATCH 2/2] Do not hardcode database name and owner --- management/commands/import_nk15.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/management/commands/import_nk15.py b/management/commands/import_nk15.py index b036667..c1d210f 100644 --- a/management/commands/import_nk15.py +++ b/management/commands/import_nk15.py @@ -231,13 +231,16 @@ class Command(BaseCommand): parser.add_argument('-b', '--boutons', action = 'store_true', help="import boutons") parser.add_argument('-t', '--transactions', action = 'store_true',help="import transaction") parser.add_argument('-a', '--aliases', action = 'store_true',help="import aliases") + parser.add_argument('-d', '--nk15db', action='store', default='nk15', help='NK15 database name') + parser.add_argument('-u', '--nk15user', action='store', default='nk15_user', help='NK15 database owner') def handle(self, *args, **kwargs): + nk15db, nk15user = kwargs['nk15db'], kwargs['nk15user'] #reset database. call_command("flush") self.print_success("flush nk20 database") # connecting to nk15 database - conn = pg.connect(database="nk15",user="nk15_user") + conn = pg.connect(database=nk15db,user=nk15user) cur = conn.cursor(cursor_factory = pge.DictCursor) if kwargs["special"]: