Skip to content
Extraits de code Groupes Projets
Valider 224dfb9a rédigé par Olivier Le Thanh Duong's avatar Olivier Le Thanh Duong
Parcourir les fichiers

Merge pull request #1 from yohanboniface/fix_import

Fix import
parents 7339e5df 7ea13aa8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
2 requêtes de fusion!158Attempt at fixing tests in the restructure branch,!157WIP - Restructure the repository
......@@ -23,7 +23,13 @@ class Command(BaseCommand):
sys.stdout.write("%s/%s\r" % (a, end))
sys.stdout.flush()
remote_id = reps["id"]
representative = Representative.objects.get(remote_id=remote_id)
representative = Representative.objects.filter(remote_id=remote_id)
if representative:
representative = representative[0]
else:
representative = Representative()
representative.remote_id = remote_id
representative.first_name = reps["personal"]["first_name"]
representative.last_name = reps["personal"]["last_name"]
representative.full_name = reps["personal"]["full_name"]
......@@ -32,6 +38,8 @@ class Command(BaseCommand):
representative.cv = reps["personal"]["cv"]
representative.gender = reverted_gender_dict[reps["personal"]["gender"]]
representative.save()
representative.email_set.all().delete()
for email in reps["contact"]["emails"]:
representative.email_set.create(
......@@ -51,7 +59,7 @@ class Command(BaseCommand):
for address in reps["contact"]["address"]:
country = Country.objects.filter(code=address["country"]["code"])
if not country:
Country.objects.create(
country = Country.objects.create(
name=address["country"]["name"],
code=address["country"]["code"]
)
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter