From f33aa314b6cca13695798a88d4b7fc66ce3ac158 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Tue, 18 Jun 2024 17:48:48 -0400 Subject: [PATCH] membershipworks: Show non-member ticket count in event registrations view --- membershipworks/tables.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/membershipworks/tables.py b/membershipworks/tables.py index 1d8120d..7d1d806 100644 --- a/membershipworks/tables.py +++ b/membershipworks/tables.py @@ -66,7 +66,8 @@ class EventTable(tables.Table): class EventRegistrationsTable(tables.Table): - ticket_count = tables.Column(empty_values=()) + total_ticket_count = tables.Column(empty_values=()) + non_member_ticket_count = tables.Column("Non-Member ticket count", empty_values=()) name = tables.Column(accessor="Full name") email = tables.EmailColumn(accessor="Email") phone = tables.Column(accessor="Phone") @@ -76,14 +77,18 @@ class EventRegistrationsTable(tables.Table): ) emergency_contact_relation = tables.Column(accessor="Emergency Contact Relation:") - def render_ticket_count(self, record): + def render_total_ticket_count(self, record): return sum(int(v) for k, v in record.items() if k.startswith("Ticket: ")) + def render_non_member_ticket_count(self, record): + # TODO: this is somewhat brittle + return sum(int(v) for k, v in record.items() if k == "Ticket: CMS Non-Members") + class Meta: row_attrs = { "class": lambda table, record: ( "" - if table.render_ticket_count(record) > 0 + if table.render_total_ticket_count(record) > 0 else "text-decoration-line-through table-danger" ) }