summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2025-10-16 10:43:12 +0000
committerMagnus Hagander2025-10-16 10:43:12 +0000
commit9de19a416266a18b4eda94b5e8218a828c25c1ec (patch)
tree7e23656f6f2a4221b30fda836ecf774840a6f506
parentb58ad9ce1b8dfbea37ba471130b1afc8b7f3f261 (diff)
Add pronouns to attendee reports
Adds the ability to show and filter on pronouns. This was mistakenly omitted and only included in the json dumps. Spotted by Karen Jex
-rw-r--r--postgresqleu/confreg/reports.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/postgresqleu/confreg/reports.py b/postgresqleu/confreg/reports.py
index ad836ba7..3e3ad2dc 100644
--- a/postgresqleu/confreg/reports.py
+++ b/postgresqleu/confreg/reports.py
@@ -20,7 +20,7 @@ from postgresqleu.util.db import exec_to_dict, exec_to_single_list
from postgresqleu.util.db import ensure_conference_timezone
from postgresqleu.countries.models import Country
from .models import ConferenceRegistration, RegistrationType, ConferenceAdditionalOption, ShirtSize
-from .models import STATUS_CHOICES
+from .models import STATUS_CHOICES, PRONOUNS_TEXT
from .reportingforms import QueuePartitionForm
from functools import reduce
@@ -105,6 +105,15 @@ class ForeignReportField(ReportField):
)
+class DictReportField(ReportField):
+ def __init__(self, id, title, lookupdict, default=False):
+ super().__init__(id, title, default)
+ self.lookupdict = lookupdict
+
+ def get_value(self, val):
+ return self.lookupdict.get(val, None)
+
+
class DynamicReportField(ReportField):
virtualfield = True
@@ -261,6 +270,24 @@ class DynamicReportFilter(ReportFilter):
self.field = _fakefield()
+class ReportDictFilter(ReportFilter):
+ def __init__(self, id, name, lookupdict):
+ super().__init__(id, name)
+ self.type = 'select'
+ self.lookupdict = lookupdict
+
+ def options(self):
+ return self.lookupdict.items()
+
+ def build_SQL(self, flt, blockno):
+ val = flt['value']
+ idlist = [int(v) for v in val]
+ return (
+ '{}=ANY(%(b{}_{}_ids)s)'.format(self.db_colname, blockno, self.id),
+ {'b{}_{}_ids'.format(blockno, self.id): idlist},
+ )
+
+
class ReportQueuePartitionFilter(object):
id = 'queuepartition'
name = 'Queue partition'
@@ -414,6 +441,7 @@ class AttendeeReportManager:
ReportField('company', 'Company'),
ReportField('address', 'Address'),
ForeignReportField('country', 'Country', remotecol='printable_name'),
+ DictReportField('pronouns', 'Pronouns', PRONOUNS_TEXT),
ReportField('phone', 'Phone'),
ReportField('twittername', 'Twitter'),
ReportField('nick', 'Nickname'),
@@ -449,6 +477,7 @@ class AttendeeReportManager:
ReportQueuePartitionFilter(self.conference),
ReportFilter('country', 'Country', Country.objects.all()),
ReportFilter('company', 'Company'),
+ ReportDictFilter('pronouns', 'Pronouns', PRONOUNS_TEXT),
ReportFilter('phone', 'Phone'),
ReportFilter('twittername', 'Twitter'),
ReportFilter('nick', 'Nickname'),