Fix the loaddevdata script

This commit is contained in:
Martin Pépin 2017-02-11 17:13:08 +01:00
parent f0c3def935
commit 6c3e1bd2db
2 changed files with 12 additions and 6 deletions

View file

@ -77,7 +77,7 @@ class Command(MyBaseCommand):
self.stdout.write("Inscription des utilisateurs aux tirages") self.stdout.write("Inscription des utilisateurs aux tirages")
ChoixSpectacle.objects.all().delete() ChoixSpectacle.objects.all().delete()
choices = [] 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: for tirage in tirages:
part, _ = Participant.objects.get_or_create( part, _ = Participant.objects.get_or_create(
user=user, user=user,

View file

@ -19,6 +19,8 @@ from cof.petits_cours_models import (
PetitCoursAttributionCounter PetitCoursAttributionCounter
) )
from cof.models import CofProfile
# Où sont stockés les fichiers json # Où sont stockés les fichiers json
DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)),
'data') 'data')
@ -47,8 +49,10 @@ class Command(MyBaseCommand):
# Gaulois # Gaulois
gaulois = self.from_json('gaulois.json', DATA_DIR, User) gaulois = self.from_json('gaulois.json', DATA_DIR, User)
for user in gaulois: for user in gaulois:
user.profile.is_cof = True CofProfile.objects.create(
user.profile.save() profile=user.profile,
is_cof=True
)
# Romains # Romains
self.from_json('romains.json', DATA_DIR, User) self.from_json('romains.json', DATA_DIR, User)
@ -65,10 +69,12 @@ class Command(MyBaseCommand):
root.set_password('root') root.set_password('root')
root.is_staff = True root.is_staff = True
root.is_superuser = True root.is_superuser = True
root.profile.is_cof = True
root.profile.is_buro = True
root.profile.save()
root.save() root.save()
CofProfile.objects.create(
profile=root.profile,
is_cof=True,
is_buro=True
)
# --- # ---
# Petits cours # Petits cours