Add pronouns to attendee reports master github/master
authorMagnus Hagander <magnus@hagander.net>
Thu, 16 Oct 2025 10:43:12 +0000 (12:43 +0200)
committerMagnus Hagander <magnus@hagander.net>
Thu, 16 Oct 2025 10:43:12 +0000 (12:43 +0200)
Adds the ability to show and filter on pronouns. This was mistakenly
omitted and only included in the json dumps.

Spotted by Karen Jex

postgresqleu/confreg/reports.py

index ad836ba7531d1c0fd67c8dd22f30ca59fe3dda24..3e3ad2dc5da3d4b2a2979a6f51b6a5a4880b4e60 100644 (file)
@@ -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'),