diff --git a/mep/people/models.py b/mep/people/models.py index 8efafb07..a9ffb521 100644 --- a/mep/people/models.py +++ b/mep/people/models.py @@ -543,13 +543,18 @@ class Meta: def save(self, *args, **kwargs): """Adds birth and death dates if they aren't already set - and there's a viaf id for the record""" + and there's a viaf id for the record; keep a record of + past person slugs when a person slug has changed""" + # set birth and death date if VIAF id is set and birth year and death + # year are NOT set; UNLESS skip viaf lookup config or + # viaf date override are true if ( not getattr(settings, "SKIP_VIAF_LOOKUP", False) and self.viaf_id and not self.birth_year and not self.death_year + and not self.viaf_date_override ): self.set_birth_death_years() diff --git a/mep/people/tests/test_models.py b/mep/people/tests/test_models.py index a48607a3..4cb2fc16 100644 --- a/mep/people/tests/test_models.py +++ b/mep/people/tests/test_models.py @@ -191,6 +191,15 @@ def test_save(self): pers.save() mock_setbirthdeath.assert_called_with() + # viaf set, no dates, and date override set to true + # - should NOT call + pers.viaf_date_override = True + pers.birth_year = None + pers.death_year = None + mock_setbirthdeath.reset_mock() + pers.save() + mock_setbirthdeath.assert_not_called() + # should lookup normally, but configured to skip with override_settings(SKIP_VIAF_LOOKUP=True): mock_setbirthdeath.reset_mock()