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 11, 2023
1 parent 2ba77e7 commit 55828dc
Show file tree
Hide file tree
Showing 4 changed files with 25 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
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"])

0 comments on commit 55828dc

Please sign in to comment.