Include pronouns in json report master github/master
authorMagnus Hagander <magnus@hagander.net>
Mon, 22 Sep 2025 21:45:57 +0000 (23:45 +0200)
committerMagnus Hagander <magnus@hagander.net>
Mon, 22 Sep 2025 21:46:55 +0000 (23:46 +0200)
This is needed so they can be shown on a badge when doing trial
printing.

Reported by Jimmy Angelakos

postgresqleu/confreg/migrations/0120_pronounstext.py [new file with mode: 0644]
postgresqleu/confreg/reports.py

diff --git a/postgresqleu/confreg/migrations/0120_pronounstext.py b/postgresqleu/confreg/migrations/0120_pronounstext.py
new file mode 100644 (file)
index 0000000..c0efcdc
--- /dev/null
@@ -0,0 +1,27 @@
+# Generated by Django 4.2.11 on 2025-09-22 21:36
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('confreg', '0119_conferenceadditionaloption_requires_attendee'),
+    ]
+
+    operations = [
+        migrations.RunSQL(
+            "CREATE TABLE IF NOT EXISTS pronouns_text(id int not null primary key, pronountext text not null)",
+            "DROP TABLE pronouns_text",
+        ),
+        migrations.RunSQL(
+            """WITH t(id, pronountext) AS (VALUES
+               (0, ''),
+               (1, 'she/her'),
+               (2, 'he/him'),
+               (3, 'they/them'),
+               (4, 'other')
+            ) MERGE INTO pronouns_text p USING t ON t.id=p.id WHEN MATCHED AND t.pronountext != p.pronountext THEN UPDATE SET pronountext=t.pronountext WHEN NOT MATCHED THEN INSERT (id, pronountext) VALUES (t.id, t.pronountext)""",
+            "DELETE FROM pronouns_text",
+        )
+    ]
index 15fd427d9d6b1c9b85ac40a326424868e5b9d692..ad836ba7531d1c0fd67c8dd22f30ca59fe3dda24 100644 (file)
@@ -584,11 +584,12 @@ class AttendeeReportManager:
                     'confreg_conferenceregistration_additionaloptions': 'crao',
                     'confreg_conferenceadditionaloption': 'ao',
                     'confreg_shirtsize': 's',
+                    'pronouns_text': 'pt',
                 }.get(table, table), _f)
 
             query = """SELECT r.id, firstname, lastname, email, company, address, phone, dietary, twittername, nick, badgescan, shareemail, vouchercode,
   country.name AS countryname, country.printable_name AS country,
-  s.shirtsize,
+  s.shirtsize, CASE WHEN conference.askpronouns THEN pt.pronountext ELSE '' END AS pronounstext,
   '{}/t/id/' || idtoken || '/' AS fullidtoken,
   '{}/t/at/' || publictoken || '/' AS fullpublictoken,
   regexp_replace(upper(substring(CASE WHEN conference.queuepartitioning=1 THEN lastname WHEN conference.queuepartitioning=2 THEN firstname END, 1, 1)), '[^A-Z]', 'Other') AS queuepartition,
@@ -608,8 +609,9 @@ LEFT JOIN confreg_conferenceregistration_additionaloptions crao ON crao.conferen
 LEFT JOIN confreg_conferenceadditionaloption ao ON crao.conferenceadditionaloption_id=ao.id
 LEFT JOIN country ON country.iso=r.country_id
 LEFT JOIN confreg_shirtsize s ON s.id=r.shirtsize_id
+LEFT JOIN pronouns_text pt ON pt.id=r.pronouns
 WHERE r.conference_id=%(conference_id)s {}
-GROUP BY r.id, conference.id, rt.id, rc.id, country.iso, s.id
+GROUP BY r.id, conference.id, rt.id, rc.id, country.iso, s.id, pt.id
 ORDER BY {}""".format(settings.SITEBASE, settings.SITEBASE, where, ", ".join([_get_table_aliased_field(o.get_orderby_field()) for o in ofields]))
 
         with ensure_conference_timezone(self.conference):