Skip to content

Commit

Permalink
Add delisted flag to people
Browse files Browse the repository at this point in the history
  • Loading branch information
symroe committed Sep 12, 2023
1 parent 8b83d78 commit 0d2c17f
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ynr/apps/people/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ class PersonAdmin(admin.ModelAdmin):
},
),
(
"Edit limitations",
{"classes": ("collapse",), "fields": ("edit_limitations",)},
"Restrictions",
{
"classes": ("collapse",),
"fields": ("edit_limitations", "delisted"),
},
),
)

Expand Down
1 change: 1 addition & 0 deletions ynr/apps/people/api/next/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class Meta:
"thumbnail",
"statement_to_voters",
"favourite_biscuit",
"delisted",
)

versions_url = serializers.HyperlinkedIdentityField(
Expand Down
1 change: 1 addition & 0 deletions ynr/apps/people/merging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
20 changes: 20 additions & 0 deletions ynr/apps/people/migrations/0042_person_delisted.py
Original file line number Diff line number Diff line change
@@ -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",
),
),
]
5 changes: 5 additions & 0 deletions ynr/apps/people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions ynr/apps/people/tests/test_api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
1 change: 1 addition & 0 deletions ynr/apps/people/tests/test_person_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 0d2c17f

Please sign in to comment.