Skip to content

Commit

Permalink
Skip setting dates from viaf when override flag is set
Browse files Browse the repository at this point in the history
ref #824
  • Loading branch information
rlskoeser committed Aug 12, 2024
1 parent 0c308b5 commit e4c1124
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mep/people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
9 changes: 9 additions & 0 deletions mep/people/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit e4c1124

Please sign in to comment.