mirror of https://gitlab.crans.org/bde/nk20
clean code, dont activate user
This commit is contained in:
parent
f5a80dd0a5
commit
e850c5755b
|
@ -12,10 +12,19 @@ from django.core.exceptions import ValidationError
|
|||
from django.db import IntegrityError
|
||||
from django.contrib.auth.models import User
|
||||
from note.models import Note, NoteSpecial, NoteUser, NoteClub
|
||||
from note.models import Transaction, TransactionTemplate, TransactionCategory, TransactionType
|
||||
from note.models import Alias
|
||||
from note.models import Transaction, TransactionTemplate, TemplateCategory, TransactionType
|
||||
from member.models import Profile, Club
|
||||
|
||||
"""
|
||||
Script d'import de la nk15:
|
||||
TODO: import aliases
|
||||
TODO: import transactions
|
||||
TODO: import adhesion
|
||||
TODO: import activite
|
||||
TODO: import
|
||||
|
||||
"""
|
||||
@transaction.atomic
|
||||
def import_special(cur):
|
||||
cur.execute("SELECT * FROM comptes WHERE idbde <0 ORDER BY idbde;")
|
||||
|
@ -71,6 +80,7 @@ def import_comptes(cur,map_idbde):
|
|||
"first_name": row["nom"],
|
||||
"last_name": row["prenom"],
|
||||
"email": row["mail"],
|
||||
"is_active" : False, # temporary
|
||||
}
|
||||
user = User.objects.create(**obj_dict)
|
||||
#sanitize duplicate aliases (nk12)
|
||||
|
@ -117,8 +127,7 @@ def import_comptes(cur,map_idbde):
|
|||
def import_boutons(cur,map_idbde):
|
||||
cur.execute("SELECT * FROM boutons;")
|
||||
for row in cur:
|
||||
cat, created = TransactionCategory.objects.get_or_create(name=row["categorie"])
|
||||
try:
|
||||
cat, created = TemplateCategory.objects.get_or_create(name=row["categorie"])
|
||||
obj_dict = {
|
||||
"pk": row["id"],
|
||||
"name": row["label"],
|
||||
|
@ -128,6 +137,7 @@ def import_boutons(cur,map_idbde):
|
|||
"display" : row["affiche"],
|
||||
"description": row["description"],
|
||||
}
|
||||
try:
|
||||
with transaction.atomic(): # required for error management
|
||||
button = TransactionTemplate.objects.create(**obj_dict)
|
||||
except IntegrityError as e:
|
||||
|
|
247
map_db.json
247
map_db.json
|
@ -1,247 +0,0 @@
|
|||
{
|
||||
"comptes":{
|
||||
"personne":{
|
||||
"idbde":{
|
||||
"app":"note",
|
||||
"model":"NoteUser",
|
||||
"field":"id"
|
||||
},
|
||||
"type": null,
|
||||
"pseudo":{
|
||||
"app":"member",
|
||||
"model":"User",
|
||||
"field":"username"
|
||||
},
|
||||
"passwd":{
|
||||
"app":"member",
|
||||
"model":"User",
|
||||
"field":"password"
|
||||
},
|
||||
"solde":{
|
||||
"app":"note",
|
||||
"model":"NoteUser",
|
||||
"field":"solde"
|
||||
},
|
||||
"nom":{
|
||||
"app":"member",
|
||||
"model":"User",
|
||||
"field":"first_name"
|
||||
},
|
||||
"prenom":{
|
||||
"app":"member",
|
||||
"model":"User",
|
||||
"field":"last_name"
|
||||
},
|
||||
"tel":{
|
||||
"app":"member",
|
||||
"model":"Profile",
|
||||
"field":"phone_number"
|
||||
},
|
||||
"mail":{
|
||||
"app":"member",
|
||||
"model":"User",
|
||||
"field":"email"
|
||||
},
|
||||
"adresse":{
|
||||
"app":"member",
|
||||
"model":"Profile",
|
||||
"field":"address"
|
||||
},
|
||||
"fonction": null,
|
||||
"normalien":{
|
||||
"app":"member",
|
||||
"model":"Profile",
|
||||
"field":"paid"
|
||||
},
|
||||
"pbsante": null,
|
||||
"droit": null,
|
||||
"surdroit": null,
|
||||
"supreme": null,
|
||||
"bloque": null,
|
||||
"last_adhesion": null,
|
||||
"commentaire":null,
|
||||
"last_negatif": null,
|
||||
"deleted":null
|
||||
},
|
||||
"club":{
|
||||
"idbde":{
|
||||
"app":"note",
|
||||
"model":"NoteClub",
|
||||
"field":"id"
|
||||
},
|
||||
"type": null,
|
||||
"pseudo":{
|
||||
"app":"member",
|
||||
"model":"Club",
|
||||
"field":"name"
|
||||
},
|
||||
"passwd":null,
|
||||
"solde":{
|
||||
"app":"note",
|
||||
"model":"NoteClub",
|
||||
"field":"solde"
|
||||
},
|
||||
"nom":null,
|
||||
"prenom":null,
|
||||
"tel":null,
|
||||
"mail":{
|
||||
"app":"member",
|
||||
"model":"Club",
|
||||
"field":"email"
|
||||
},
|
||||
"adresse":null,
|
||||
"fonction": null,
|
||||
"normalien": null,
|
||||
"pbsante": null,
|
||||
"droit": null,
|
||||
"surdroit": null,
|
||||
"supreme": null,
|
||||
"bloque": null,
|
||||
"last_adhesion": null,
|
||||
"commentaire":null,
|
||||
"last_negatif": null,
|
||||
"deleted":null
|
||||
},
|
||||
"special":{
|
||||
"idbde":{
|
||||
"app":"note",
|
||||
"model":"NoteSpecial",
|
||||
"field":"id"
|
||||
},
|
||||
"type": null,
|
||||
"pseudo":{
|
||||
"app":"member",
|
||||
"model":"NoteSpecial",
|
||||
"field":"special_type"
|
||||
},
|
||||
"passwd":null,
|
||||
"solde":{
|
||||
"app":"note",
|
||||
"model":"NoteClub",
|
||||
"field":"solde"
|
||||
},
|
||||
"nom":null,
|
||||
"prenom":null,
|
||||
"tel":null,
|
||||
"mail":null,
|
||||
"adresse":null,
|
||||
"fonction": null,
|
||||
"normalien": null,
|
||||
"pbsante": null,
|
||||
"droit": null,
|
||||
"surdroit": null,
|
||||
"supreme": null,
|
||||
"bloque": null,
|
||||
"last_adhesion": null,
|
||||
"commentaire":null,
|
||||
"last_negatif": null,
|
||||
"deleted":null
|
||||
},
|
||||
}
|
||||
|
||||
},
|
||||
"transactions":{
|
||||
"id":{
|
||||
"app":"note",
|
||||
"model":"Transaction",
|
||||
"field":""
|
||||
},"Transaction.id",
|
||||
"date":{
|
||||
"app":"note",
|
||||
"model":"Transaction",
|
||||
"field":""
|
||||
}"Transaction.created_at",
|
||||
"type":{
|
||||
"app":"note",
|
||||
"model":"Transaction",
|
||||
"field":""
|
||||
} null,
|
||||
"emetteur":{
|
||||
"app":"note",
|
||||
"model":"Transaction",
|
||||
"field":"id"
|
||||
},
|
||||
"destinataire":{
|
||||
"app":"note",
|
||||
"model":"Transaction",
|
||||
"field":"destination_id"
|
||||
},
|
||||
"quantite":{
|
||||
"app":"note",
|
||||
"model":"Transaction",
|
||||
"field":"quantity"
|
||||
},
|
||||
"montant":{
|
||||
"app":"note",
|
||||
"model":"Transaction",
|
||||
"field":"amount"
|
||||
},
|
||||
"description":{
|
||||
"app":"note",
|
||||
"model":"Transaction",
|
||||
"field":"reason"
|
||||
},
|
||||
"valide":{
|
||||
"app":"note",
|
||||
"model":"Transaction",
|
||||
"field":"valid"
|
||||
},
|
||||
"cantinvalidate": null,
|
||||
"categorie":{
|
||||
"app":"note",
|
||||
"model":"Transaction",
|
||||
"field":"transaction_type"
|
||||
}
|
||||
},
|
||||
"boutons":{
|
||||
"id":{
|
||||
"app":"note",
|
||||
"model":"TransactionTemplate",
|
||||
"field":"pk"
|
||||
}
|
||||
"label":{
|
||||
"app":"note",
|
||||
"model":"TransactionTemplate",
|
||||
"field":"name"
|
||||
},
|
||||
"montant":{
|
||||
"app":"note",
|
||||
"model":"TransactionTemplate",
|
||||
"field":"amount"
|
||||
},
|
||||
"destinataire":{
|
||||
"app":"note",
|
||||
"model":"TransactionTemplate",
|
||||
"field":"destination_id"
|
||||
},
|
||||
"categorie":null,
|
||||
"affiche":{
|
||||
"app":"note",
|
||||
"model":"TransactionTemplate",
|
||||
"field":"display"
|
||||
},
|
||||
"description":{
|
||||
"app":"note",
|
||||
"model":"TransactionTemplate",
|
||||
"field":"description"
|
||||
},
|
||||
"consigne":null
|
||||
},
|
||||
"aliases":{
|
||||
"id":{
|
||||
"app":"note",
|
||||
"model":"Alias",
|
||||
"field":"id"
|
||||
},
|
||||
"alias":{
|
||||
"app":"note",
|
||||
"model":"Alias",
|
||||
"field":"name"
|
||||
},
|
||||
"idbde":{
|
||||
"app":"note",
|
||||
"model":"Alias",
|
||||
"field":"note_id"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue