|
15 | 15 | import re |
16 | 16 |
|
17 | 17 | from postgresqleu.mailqueue.util import send_simple_mail, send_template_mail |
| 18 | +from postgresqleu.util.db import exec_to_keyed_dict |
18 | 19 | from postgresqleu.util.middleware import RedirectException |
19 | 20 | from postgresqleu.util.time import today_conference |
20 | 21 | from postgresqleu.util.messaging.util import send_org_notification |
@@ -489,6 +490,34 @@ def get_conference_or_404(urlname): |
489 | 490 | return conference |
490 | 491 |
|
491 | 492 |
|
| 493 | +def get_conference_scanner_permissions(user): |
| 494 | + permissions = exec_to_keyed_dict("""SELECT conferencename AS name, startdate::text, true AS checkin, |
| 495 | +CASE WHEN scannerfields != '' THEN regexp_split_to_array(scannerfields, ',') ELSE '{}' END AS scannerfields, |
| 496 | +regtoken AS token |
| 497 | +FROM confreg_conference c |
| 498 | +INNER JOIN confreg_conferenceregistration r ON r.conference_id=c.id |
| 499 | +WHERE r.attendee_id=%(userid)s |
| 500 | +AND c.enddate > CURRENT_TIMESTAMP - '2 weeks'::interval |
| 501 | +AND EXISTS (SELECT 1 FROM confreg_conference_checkinprocessors cp WHERE cp.conference_id=c.id AND cp.conferenceregistration_id=r.id) |
| 502 | +""", {'userid': user.id}) |
| 503 | + |
| 504 | + for conf, data in exec_to_keyed_dict("""SELECT conferencename AS name, startdate::text, false as checkin, |
| 505 | +jsonb_agg(jsonb_build_object('sponsor', s.name, 'token', ss.token)) AS sponsors |
| 506 | +FROM confreg_conference c |
| 507 | +INNER JOIN confreg_conferenceregistration r ON r.conference_id=c.id |
| 508 | +INNER JOIN confsponsor_sponsorscanner ss ON ss.scanner_id=r.id |
| 509 | +INNER JOIN confsponsor_sponsor s ON s.id=ss.sponsor_id |
| 510 | +WHERE r.attendee_id=%(userid)s |
| 511 | +AND c.enddate > CURRENT_TIMESTAMP - '2 weeks'::interval |
| 512 | +GROUP BY 1, 2, 3 |
| 513 | +""", {'userid': user.id}).items(): |
| 514 | + if conf in permissions: |
| 515 | + permissions[conf]['sponsors'] = data['sponsors'] |
| 516 | + else: |
| 517 | + permissions[conf] = data |
| 518 | + return permissions |
| 519 | + |
| 520 | + |
492 | 521 | def activate_conference_timezone(conference): |
493 | 522 | timezone.activate(conference.tzname) |
494 | 523 |
|
|
0 commit comments