diff --git a/ynr/apps/people/admin.py b/ynr/apps/people/admin.py index 5cf6bfdcb..73cfe4c58 100644 --- a/ynr/apps/people/admin.py +++ b/ynr/apps/people/admin.py @@ -90,8 +90,11 @@ class PersonAdmin(admin.ModelAdmin): }, ), ( - "Edit limitations", - {"classes": ("collapse",), "fields": ("edit_limitations",)}, + "Restrictions", + { + "classes": ("collapse",), + "fields": ("edit_limitations", "delisted"), + }, ), ) diff --git a/ynr/apps/people/api/next/serializers.py b/ynr/apps/people/api/next/serializers.py index c627fd259..92dc708d8 100644 --- a/ynr/apps/people/api/next/serializers.py +++ b/ynr/apps/people/api/next/serializers.py @@ -100,6 +100,7 @@ class Meta: "thumbnail", "statement_to_voters", "favourite_biscuit", + "delisted", ) versions_url = serializers.HyperlinkedIdentityField( diff --git a/ynr/apps/people/merging.py b/ynr/apps/people/merging.py index 6d642bf0f..145a6c114 100644 --- a/ynr/apps/people/merging.py +++ b/ynr/apps/people/merging.py @@ -79,6 +79,7 @@ class PersonMerger: ("given_name", "merge_person_attrs"), ("patronymic_name", "merge_person_attrs"), ("summary", "merge_person_attrs"), + ("delisted", "merge_person_attrs"), ("name_search_vector", "discard_data"), # Relations ("versions", "merge_versions_json"), diff --git a/ynr/apps/people/migrations/0042_person_delisted.py b/ynr/apps/people/migrations/0042_person_delisted.py new file mode 100644 index 000000000..8e04e04f0 --- /dev/null +++ b/ynr/apps/people/migrations/0042_person_delisted.py @@ -0,0 +1,20 @@ +# Generated by Django 4.1.7 on 2023-09-11 15:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("people", "0041_add_person_name_edit_permissions"), + ] + + operations = [ + migrations.AddField( + model_name="person", + name="delisted", + field=models.BooleanField( + default=False, + help_text="Mark this person as de-listed in search engines. Might take some days to come in to effect", + ), + ), + ] diff --git a/ynr/apps/people/models.py b/ynr/apps/people/models.py index dd0ca2991..ddaaa64ea 100644 --- a/ynr/apps/people/models.py +++ b/ynr/apps/people/models.py @@ -307,6 +307,11 @@ class Person(TimeStampedModel, models.Model): ], ) + delisted = models.BooleanField( + default=False, + help_text="Mark this person as de-listed in search engines. Might take some days to come in to effect", + ) + name_search_vector = SearchVectorField(null=True) class Meta: diff --git a/ynr/apps/people/tests/test_api_views.py b/ynr/apps/people/tests/test_api_views.py index e496d9239..107c1ae52 100644 --- a/ynr/apps/people/tests/test_api_views.py +++ b/ynr/apps/people/tests/test_api_views.py @@ -104,3 +104,17 @@ def test_person_history_view(self): response.json(), {"count": 0, "next": None, "previous": None, "results": []}, ) + + def test_delisted_in_api(self): + person = self.people[0] + response = self.client.get(f"/api/next/people/{person.pk}/") + data = response.json() + self.assertTrue("delisted" in data) + self.assertFalse(data["delisted"]) + + person.delisted = True + person.save() + response = self.client.get(f"/api/next/people/{person.pk}/") + data = response.json() + self.assertTrue("delisted" in data) + self.assertTrue(data["delisted"]) diff --git a/ynr/apps/people/tests/test_person_update.py b/ynr/apps/people/tests/test_person_update.py index baafe7ba3..d495b7814 100644 --- a/ynr/apps/people/tests/test_person_update.py +++ b/ynr/apps/people/tests/test_person_update.py @@ -349,6 +349,7 @@ def test_person_update_election_future_not_current(self): "death_date", "biography", "favourite_biscuit", + "delisted", # "standing_parl.2015-05-07", # "constituency_parl.2015-05-07", # "party_GB_parl.2015-05-07",