1
0
mirror of https://gitlab.crans.org/bde/nk20-scripts synced 2025-06-29 09:50:54 +02:00

everything is imported, without server error

This commit is contained in:
Pierre-antoine Comby
2020-05-26 23:54:24 +02:00
parent 5af336fff3
commit 0ba656d5e0
2 changed files with 152 additions and 104 deletions

View File

@ -15,6 +15,15 @@ from ._import_utils import ImportCommand, BulkCreateManager, timed
MAP_ACTIVITY = dict()
CLUB_RELOU = [
0, # BDE
4771, # Kataclist
5162, # Assurance BDE ?!
5164, #S & L
625, #Aspique
5154, #Frekens
]
class Command(ImportCommand):
"""
Import command for Activities Base Data (Comptes, and Aliases)
@ -54,7 +63,7 @@ class Command(ImportCommand):
"date_start": make_aware(row["debut"]),
"date_end": make_aware(row["fin"]),
"valid": row["validepar"] is not None,
"open": row["ouvert"], # Should always be False
"open": False,
}
# WARNING: Fields lieu, liste, listeimprimee are missing
MAP_ACTIVITY[row["id"]] = pk_activity
@ -70,6 +79,8 @@ class Command(ImportCommand):
n = cur.rowcount
for idx, row in enumerate(cur):
self.update_line(idx, n, f"{row['nom']} {row['prenom']}")
if row["responsable"] in CLUB_RELOU:
row["responsable"] = 3508
obj_dict = {
"pk": row["id"],
"activity_id": MAP_ACTIVITY[row["activite"]],
@ -88,11 +99,13 @@ class Command(ImportCommand):
n = cur.rowcount
for idx, row in enumerate(cur):
self.update_line(idx, n, f"{row['idbde']} {row['responsable']}")
if row["idbde"] in CLUB_RELOU:
row["idbde"] = 3508
obj_dict = {
"activity_id": MAP_ACTIVITY[row["activite"]],
"time": make_aware(row["heure_entree"]),
"note_id": self.MAP_IDBDE[row["responsable"] if row['est_invite'] else row["idbde"]],
"guest_id": self.MAP_IDBDE[row["idbde"]] if row['est_invite'] else None,
"guest_id": row["idbde"] if row['est_invite'] else None,
}
bulk_mgr.add(Entry(**obj_dict))
bulk_mgr.done()