From 6c3e1bd2db888ac0ba6afc595766a29c1af19865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sat, 11 Feb 2017 17:13:08 +0100 Subject: [PATCH] Fix the loaddevdata script --- bda/management/commands/loadbdadevdata.py | 2 +- cof/management/commands/loaddevdata.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bda/management/commands/loadbdadevdata.py b/bda/management/commands/loadbdadevdata.py index a8851e3d..f348b310 100644 --- a/bda/management/commands/loadbdadevdata.py +++ b/bda/management/commands/loadbdadevdata.py @@ -77,7 +77,7 @@ class Command(MyBaseCommand): self.stdout.write("Inscription des utilisateurs aux tirages") ChoixSpectacle.objects.all().delete() choices = [] - for user in User.objects.filter(profile__is_cof=True): + for user in User.objects.filter(profile__cof__is_cof=True): for tirage in tirages: part, _ = Participant.objects.get_or_create( user=user, diff --git a/cof/management/commands/loaddevdata.py b/cof/management/commands/loaddevdata.py index 4627c2d0..1525152c 100644 --- a/cof/management/commands/loaddevdata.py +++ b/cof/management/commands/loaddevdata.py @@ -19,6 +19,8 @@ from cof.petits_cours_models import ( PetitCoursAttributionCounter ) +from cof.models import CofProfile + # Où sont stockés les fichiers json DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'data') @@ -47,8 +49,10 @@ class Command(MyBaseCommand): # Gaulois gaulois = self.from_json('gaulois.json', DATA_DIR, User) for user in gaulois: - user.profile.is_cof = True - user.profile.save() + CofProfile.objects.create( + profile=user.profile, + is_cof=True + ) # Romains self.from_json('romains.json', DATA_DIR, User) @@ -65,10 +69,12 @@ class Command(MyBaseCommand): root.set_password('root') root.is_staff = True root.is_superuser = True - root.profile.is_cof = True - root.profile.is_buro = True - root.profile.save() root.save() + CofProfile.objects.create( + profile=root.profile, + is_cof=True, + is_buro=True + ) # --- # Petits cours