diff --git a/wcivf/apps/elections/templates/elections/post_view.html b/wcivf/apps/elections/templates/elections/post_view.html
index 57feb1ba2..67995a3f0 100644
--- a/wcivf/apps/elections/templates/elections/post_view.html
+++ b/wcivf/apps/elections/templates/elections/post_view.html
@@ -8,7 +8,11 @@
{% block og_description_content %}{% include "elections/includes/_post_meta_description.html" %}{% endblock og_description_content %}
{% block twitter_title_content %}{% include "elections/includes/_post_meta_title.html" %}{% endblock twitter_title_content %}>
{% block twitter_description_content %}{% include "elections/includes/_post_meta_description.html" %}{% endblock twitter_description_content %}/>
-
+{% block page_meta %}
+ {% if postelection.people.contains_delisted_person %}
+
+ {% endif %}
+{% endblock %}
{% block content %}
{% include "elections/includes/_post_breadcrumbs.html" %}
diff --git a/wcivf/apps/people/managers.py b/wcivf/apps/people/managers.py
index 38f9f11ae..6a2076f23 100644
--- a/wcivf/apps/people/managers.py
+++ b/wcivf/apps/people/managers.py
@@ -67,6 +67,9 @@ def current(self):
"""
return self.filter(election__current=True)
+ def contains_delisted_person(self):
+ return self.filter(person__delisted=True).exists()
+
class PersonPostManager(models.Manager):
def get_queryset(self):
@@ -107,6 +110,7 @@ def update_or_create_from_ynr(self, person):
"birth_date": person["birth_date"] or None,
"death_date": person["death_date"] or None,
"last_updated": last_updated,
+ "delisted": person.get("delisted", False),
}
for value_type in VALUE_TYPES_TO_IMPORT:
diff --git a/wcivf/apps/people/migrations/0045_person_delisted.py b/wcivf/apps/people/migrations/0045_person_delisted.py
new file mode 100644
index 000000000..48cf221e6
--- /dev/null
+++ b/wcivf/apps/people/migrations/0045_person_delisted.py
@@ -0,0 +1,17 @@
+# Generated by Django 4.1.6 on 2023-09-11 16:26
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("people", "0044_person_mastodon_username"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="person",
+ name="delisted",
+ field=models.BooleanField(default=False),
+ ),
+ ]
diff --git a/wcivf/apps/people/models.py b/wcivf/apps/people/models.py
index e6c8044dc..193547791 100644
--- a/wcivf/apps/people/models.py
+++ b/wcivf/apps/people/models.py
@@ -193,6 +193,9 @@ class Person(models.Model):
last_or_current_job = models.CharField(null=True, max_length=800)
previously_in_parliament = models.CharField(null=True, max_length=800)
+ # Meta
+ delisted = models.BooleanField(default=False)
+
objects = PersonManager()
class Meta:
diff --git a/wcivf/apps/people/templates/people/person_detail.html b/wcivf/apps/people/templates/people/person_detail.html
index 254cc787d..03e9aedde 100644
--- a/wcivf/apps/people/templates/people/person_detail.html
+++ b/wcivf/apps/people/templates/people/person_detail.html
@@ -14,6 +14,11 @@
{% block twitter_image %}{% if object.photo_url %}{{ object.photo_url }}{% else %}{{ CANONICAL_URL }}{% static 'images/blank-avatar.png' %}{% endif %}{% endblock twitter_image %}
{% block twitter_description_content %}{% include "people/includes/_person_meta_description.html" %}{% endblock twitter_description_content %}
{% block twitter_image_alt %}Photo of {{ object.name }}{% endblock twitter_image_alt %}
+{% block page_meta %}
+ {% if object.delisted %}
+
+ {% endif %}
+{% endblock %}
{% block content %}
{% if referer_postcode %}
diff --git a/wcivf/apps/people/tests/test_person_manager.py b/wcivf/apps/people/tests/test_person_manager.py
index 8a7453024..38ee1f5da 100644
--- a/wcivf/apps/people/tests/test_person_manager.py
+++ b/wcivf/apps/people/tests/test_person_manager.py
@@ -29,6 +29,14 @@ def test_counts_by_post(self):
assert Person.objects.all().count() == 5
assert PersonPost.objects.all().counts_by_post().count() == 1
+ def test_delisted_value(self):
+ assert PersonPost.objects.all().contains_delisted_person() is False
+
+ person = Person.objects.first()
+ person.delisted = True
+ person.save()
+ assert PersonPost.objects.all().contains_delisted_person() is True
+
@pytest.mark.freeze_time("2021-01-13")
class PersonPostManagerTests(TestCase):
diff --git a/wcivf/apps/people/tests/test_person_views.py b/wcivf/apps/people/tests/test_person_views.py
index c42dd1b89..b89a45312 100644
--- a/wcivf/apps/people/tests/test_person_views.py
+++ b/wcivf/apps/people/tests/test_person_views.py
@@ -553,6 +553,18 @@ def test_person_detail_404_with_string_pk(self):
req = self.client.get("/person/partywebsite.org/")
self.assertEqual(req.status_code, 404)
+ def test_noindex_tag_added(self):
+ noindex_string = """"""
+ PersonPostWithPartyFactory(
+ person=self.person, election=ElectionFactory()
+ )
+ response = self.client.get(self.person_url, follow=True)
+ self.assertNotContains(response, noindex_string)
+ self.person.delisted = True
+ self.person.save()
+ response = self.client.get(self.person_url, follow=True)
+ self.assertInHTML(noindex_string, response.content.decode("utf8"))
+
class TestPersonViewUnitTests:
@pytest.fixture