Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ynr/apps/data_exports/csv_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ def link_formatter(value, url):
value_group="candidacy",
label="Party description",
)
csv_fields["sopn_last_name"] = CSVField(
value=F("membership__sopn_last_name"),
type="expr",
value_group="candidacy",
label="SOPN Last Name",
)
csv_fields["sopn_first_names"] = CSVField(
value=F("membership__sopn_first_names"),
type="expr",
value_group="candidacy",
label="SOPN First Names",
)
csv_fields["legacy_party_id"] = CSVField(
value=F("party__legacy_slug"),
type="expr",
Expand Down
10 changes: 9 additions & 1 deletion ynr/apps/popolo/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ class MembershipAdmin(admin.ModelAdmin):
form = MembershipAdminForm
model = models.Membership
list_display = ("person", "party", "get_ballot", "deselected")
fields = ("person", "party", "ballot", "deselected", "deselected_source")
fields = (
"person",
"party",
"ballot",
"deselected",
"deselected_source",
"sopn_last_name",
"sopn_first_names",
)
readonly_fields = ("person", "party", "ballot")
list_filter = ("deselected",)

Expand Down
4 changes: 4 additions & 0 deletions ynr/apps/popolo/api/next/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class Meta:
"party_description_text",
"deselected",
"deselected_source",
"sopn_last_name",
"sopn_first_names",
"created",
"modified",
]
Expand Down Expand Up @@ -96,6 +98,8 @@ class Meta:
)
deselected = serializers.ReadOnlyField()
deselected_source = serializers.ReadOnlyField()
sopn_last_name = serializers.ReadOnlyField()
sopn_first_names = serializers.ReadOnlyField()

@swagger_serializer_method(serializer_or_field=BallotOnCandidacySerializer)
def get_ballot(self, obj):
Expand Down
32 changes: 32 additions & 0 deletions ynr/apps/popolo/migrations/0054_membership_sopn_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 5.2.8 on 2026-01-12 15:23

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("popolo", "0053_alter_post_territory_code"),
]

operations = [
migrations.AddField(
model_name="membership",
name="sopn_first_names",
field=models.CharField(
blank=True,
default="",
help_text="The person's first names, exactly as they are printed on the SOPN",
max_length=255,
),
),
migrations.AddField(
model_name="membership",
name="sopn_last_name",
field=models.CharField(
blank=True,
default="",
help_text="The person's last name, exactly as it is printed on the SOPN",
max_length=255,
),
),
]
12 changes: 12 additions & 0 deletions ynr/apps/popolo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,18 @@ class Membership(Dateframeable, TimeStampedModel, models.Model):
previous_party_affiliations = models.ManyToManyField(
to="parties.Party", related_name="alliated_memberships", blank=True
)
sopn_last_name = models.CharField(
max_length=255,
help_text="The person's last name, exactly as it is printed on the SOPN",
blank=True,
default="",
)
sopn_first_names = models.CharField(
max_length=255,
help_text="The person's first names, exactly as they are printed on the SOPN",
blank=True,
default="",
)

deselected = models.BooleanField(
null=True,
Expand Down