Skip to content

Commit

Permalink
gps: Don't update advisor with same data
Browse files Browse the repository at this point in the history
  • Loading branch information
tonial committed Oct 5, 2024
1 parent dfec9e9 commit 2761a34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions itou/gps/management/commands/import_advisor_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ def handle(self, import_excel_file, wet_run=False, **options):

for profile in implicated_profiles:
advisor, created = create_or_update_advisor(profile, nir_to_contact, commit=False)
if created:
contacts_to_create.append(advisor)
else:
contacts_to_update.append(advisor)
if advisor:
if created:
contacts_to_create.append(advisor)
else:
contacts_to_update.append(advisor)

if wet_run:
FranceTravailContact.objects.bulk_create(contacts_to_create)
Expand Down
4 changes: 4 additions & 0 deletions itou/gps/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def create_or_update_advisor(jobseeker_profile, nir_to_contact, commit=True):
# prepare to create or update FranceTravailContact
try:
advisor = jobseeker_profile.advisor_information

if (advisor.name, advisor.email) == (contact_name, contact_email):
return None, False

advisor.name = contact_name
advisor.email = contact_email
except FranceTravailContact.DoesNotExist:
Expand Down

0 comments on commit 2761a34

Please sign in to comment.