1
0
mirror of https://gitlab.crans.org/bde/nk20-scripts synced 2024-12-27 01:42:24 +00:00

Import boutons transaction, prep for adhésions

This commit is contained in:
Pierre-antoine Comby 2020-02-25 14:19:34 +01:00
parent 5a963eb281
commit e2c1d70eb4

View File

@ -16,16 +16,16 @@ from django.db import IntegrityError
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, TransactionType
from member.models import Profile, Club
from note.models import Transaction, TransactionTemplate,\
TemplateCategory, TemplateTransaction, MembershipTransaction
from member.models import Profile, Club, Membership
"""
Script d'import de la nk15:
TODO: import aliases
TODO: import transactions
TODO: import adhesion
TODO: import activite
TODO: import
TODO: import ...
"""
@transaction.atomic
@ -161,11 +161,33 @@ def import_boutons(cur,map_idbde):
@transaction.atomic
def import_transaction(cur, map_idbde):
cur.execute("SELECT * FROM transactions;")
cur.execute("SELECT * FROM transactions LEFT JOIN adhesions ON transactions.id = adhesions.idtransaction ORDER BY -id;")
for row in cur:
obj_dict = {
"pk":row["id"],
# "pk": row["id"],
"destination_id" : map_idbde[row["destinataire"]],
"source_id": map_idbde[row["emetteur"]],
"created_at":make_aware(row["date"]),
"amount":row["montant"],
"quantity":row["quantite"],
"reason":row["description"],
"valid":row["valide"],
}
if row["type"] == "bouton":
cat_name = row["categorie"]
if cat_name == None:
cat_name = 'None'
cat, created = TemplateCategory.objects.get_or_create(name=cat_name)
if created:
cat.save()
obj_dict["category"] = cat
transac = TemplateTransaction.objects.create(**obj_dict)
transac.save()
elif row["type"] == "adhésion":
else:
@transaction.atomic
def import_aliases(cur,map_idbde):