diff options
| -rw-r--r-- | ishtar_common/models.py | 5 | ||||
| -rw-r--r-- | ishtar_common/tests.py | 14 | 
2 files changed, 15 insertions, 4 deletions
| diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 9bcfd4930..a3e0302aa 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -3998,7 +3998,10 @@ def post_save_userprofile(sender, **kwargs):      if not kwargs.get('instance'):          return      instance = kwargs.get('instance') -    instance.person.ishtaruser.show_field_number(update=True) +    try: +        instance.person.ishtaruser.show_field_number(update=True) +    except IshtarUser.DoesNotExist: +        return  post_save.connect(post_save_userprofile, sender=UserProfile) diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 7166f9cb7..17cc874fe 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -898,6 +898,10 @@ class MergeTest(TestCase):              title=self.title, attached_to=self.company_2)          self.user.ishtaruser.person = self.person_2          self.user.ishtaruser.save() +        models.UserProfile.objects.create( +            profile_type=models.ProfileType.objects.all()[0], +            person=self.person_2 +        )          self.person_2.person_types.add(self.person_types[1])          self.author_2_pk = models.Author.objects.create( @@ -906,7 +910,7 @@ class MergeTest(TestCase):              name='George', history_modifier=self.user,              attached_to=self.company_1) -    def testPersonMerge(self): +    def test_person_merge(self):          self.person_1.merge(self.person_2)          # preserve existing fields          self.assertEqual(self.person_1.name, 'Boule') @@ -925,7 +929,7 @@ class MergeTest(TestCase):          # add new many to many          self.assertTrue(self.person_types[1]                          in self.person_1.person_types.all()) -        # update reverse foreign key association and dont break the existing +        # update reverse foreign key association and do not break the existing          self.assertEqual(models.Author.objects.get(pk=self.author_1_pk).person,                           self.person_1)          self.assertEqual(models.Author.objects.get(pk=self.author_2_pk).person, @@ -936,7 +940,11 @@ class MergeTest(TestCase):          self.assertTrue(self.person_types[1]                          in self.person_3.person_types.all()) -    def testPersonMergeCandidate(self): +    def test_person_with_use_account_merge(self): +        # bug: merge when the target is not the one having a Ishtar user account +        self.person_1.merge(self.person_2) + +    def test_person_merge_candidate(self):          init_mc = self.person_1.merge_candidate.count()          person = models.Person.objects.create(              name=self.person_1.name, | 
