Skip to content
Extraits de code Groupes Projets
Valider 7ea13aa8 rédigé par Bram's avatar Bram
Parcourir les fichiers

[enh] import_representatives_no_preserve works if representatives aren't in the db already

parent c44b538a
Branches
Étiquettes
1 requête de fusion!1Fix import
......@@ -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(
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter