1
0
mirror of https://gitlab.crans.org/bde/nk20-scripts synced 2025-06-29 17:51:08 +02:00

Fix activities import

This commit is contained in:
Yohann D'ANELLO
2020-07-22 01:28:28 +02:00
parent ee54fca89e
commit 4839b2deb8
5 changed files with 62 additions and 20 deletions

View File

@ -10,18 +10,22 @@ from django.db import transaction
from activity.models import ActivityType, Activity, Guest, Entry
from member.models import Club
from note.models import Note
from note.models import Note, NoteUser
from ._import_utils import ImportCommand, BulkCreateManager, timed
MAP_ACTIVITY = dict()
CLUB_RELOU = [
0, # BDE
0, # BDE
4771, # Kataclist
5162, # Assurance BDE ?!
5164, #S & L
625, #Aspique
5154, #Frekens
5164, # S & L
625, # Aspique
5154, # Frekens
3944, # DiskJok[ENS]
5153, # Monopo[list]
2351, # JdRM
2365, # Pot Vieux
]
class Command(ImportCommand):
@ -40,11 +44,13 @@ class Command(ImportCommand):
pk_activity = 1
for idx, row in enumerate(cur):
self.update_line(idx, n, row["titre"])
if row["responsable"] in CLUB_RELOU:
row["responsable"] = 3508
note = self.MAP_IDBDE[row["responsable"]]
if note == 6244:
# Licorne magique ne doit pas utiliser son compte club pour proposer des activités
note = Note.objects.get(pk=self.MAP_IDBDE[6524])
note = note.user_id
note = note.id
organizer = Club.objects.filter(name=row["signature"])
if organizer.exists():
# Try to find the club that organizes the activity.
@ -57,7 +63,7 @@ class Command(ImportCommand):
"name": row["titre"],
"description": row["description"],
"activity_type_id": activity_type_id, # By default Pot
"creater_id": note,
"creater_id": NoteUser.objects.get(pk=note).user.id,
"organizer_id": organizer.pk,
"attendees_club_id": kfet.pk, # Maybe fix manually
"date_start": make_aware(row["debut"]),