Import boutons transaction, prep for adhésions
This commit is contained in:
parent
5a963eb281
commit
e2c1d70eb4
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue