membershipworks: Show non-member ticket count in event registrations view
All checks were successful
Ruff / ruff (push) Successful in 29s
Test / test (push) Successful in 4m6s

This commit is contained in:
Adam Goldsmith 2024-06-18 17:48:48 -04:00
parent a5cc2cce25
commit f33aa314b6

View File

@ -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"
)
}