Skip to content

Commit

Permalink
[refs #114239] Fix PersonCompany integrity error on save on fetch_ecr
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaboiangiu committed Feb 13, 2020
1 parent e2e07db commit cd257a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions notifications/management/commands/fetch_ecr.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ def parse_person_data(self, person):

def set_current_user_true(self, company, persons):
for person in persons:
person_company, _ = PersonCompany.objects.really_all().get_or_create(company=company, person=person)
person_company.current = True
try:
person_company = PersonCompany.objects.really_all().get(company=company, person=person)
person_company.delete()
person_company = PersonCompany.objects.create(company=company, person=person, current=True)
except PersonCompany.DoesNotExist:
person_company = PersonCompany.objects.create(company=company, person=person, current=True)

def check_company_is_valid(self, company):
if company['check_passed']:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h2>Review contacts</h2>
</thead>
<tbody>
{% for company in companies %}
{% for person in company.users.all %}
{% for person in company.active_users %}
<tr>
<td>
{{ company.external_id }}
Expand Down

0 comments on commit cd257a0

Please sign in to comment.