1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-26 18:37:12 +00:00

fix json file format

test struct of json

json file finish
This commit is contained in:
Pierre-antoine Comby 2020-02-09 15:40:46 +01:00
parent 71a88e84f7
commit 4fe61fdc5f
2 changed files with 168 additions and 49 deletions

View File

@ -3,6 +3,7 @@
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.utils import timezone from django.utils import timezone
import psycopg2 as pg import psycopg2 as pg
import psycopg2.extras as pge
import json import json
@ -19,12 +20,19 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
map_file= options.get("map",None) map_file= options.get("map",None)
with open(map_file,'rb') as f: with open(map_file,'r') as f:
map_dict = json.load(f); map_dict = json.load(f);
#conn = pg.connect(database="nk15",user="nk_15") conn = pg.connect(database="nk15",user="nk15_user")
#cur = conn.cursor() cur = conn.cursor(cursor_factory = pge.DictCursor)
for old_table in map_dict: # Start with comptes table.
print(old_table) cur.execute("SELECT * FROM comptes ORDER BY -idbde LIMIT 5")
old_fields = [d[0] for d in cur.description]
print(type(old_fields))
for row in cur:
for old_field in old_fields:
print(old_field,row[old_field])

View File

@ -1,50 +1,161 @@
[ {
"comptes": { "comptes":{
"idbde":"Note.id", "idbde":{
"type": null, "app":"note",
"pseudo":"User.username", "model":"Note",
"passwd":"User.password", "field":"id"
"solde":"Note.solde", },
"nom":"User.first_name", "type": null,
"prenom":"User.last_name", "pseudo":{
"tel":"Profile.phone_number", "app":"member",
"mail":"User.email", "model":"User",
"adresse":"Profile.address", "field":"username"
"fonction": null, },
"normalien": "Profile.paid", "passwd":{
"pbsante": null, "app":"member",
"droit": null, "model":"User",
"surdroit": null, "field":"password"
"supreme": null, },
"bloque": null, "solde":{
"last_adhesion": null "app":"note",
"model":"Note",
"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
}, },
"transaction":{ "transactions":{
"id":"Transaction.id", "id":{
"date":"Transaction.created_at", "app":"note",
"type": null, "model":"Transaction",
"emetteur":"Transaction.source_id", "field":""
"destinataire":"Transaction.destination_id", },"Transaction.id",
"quantite":"Transaction.quantity", "date":{
"montant":"Transaction.amount", "app":"note",
"description":"Transaction.reason", "model":"Transaction",
"valide":"Transaction.valid", "field":""
"cantinvalidate": null, }"Transaction.created_at",
"categorie":"Transaction.transaction_type" "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":{ "boutons":{
"id":"TransactionTemplate.id", "id":{
"label":"TransactionTemplate.name", "app":"note",
"montant":"TransactionTemplate.amount", "model":"Transaction",
"destinataire":"TransactionTemplate.destination_id", "field":"transaction_type"
"categorie":null, }"TransactionTemplate.id",
"affiche":null, "label":{
"description":null, "app":"note",
"consigne":null "model":"TransactionTemplate",
"field":"name"
},
"montant":{
"app":"note",
"model":"TransactionTemplate",
"field":"amount"
},
"destinataire":{
"app":"note",
"model":"TransactionTemplate",
"field":"destination_id"
},
"categorie":null,
"affiche":null,
"description":null,
"consigne":null
}, },
"aliases":{ "aliases":{
"id":"Alias.id", "id":{
"alias":"Alias.name", "app":"note",
"idbde":"Alias.note_id" "model":"Alias",
"field":"id"
},
"alias":{
"app":"note",
"model":"Alias",
"field":"name"
},
"idbde":{
"app":"note",
"model":"Alias",
"field":"note_id"
}
} }
] }