From f3a08a82bb967f500de955269a8bd696adf32fd5 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Sat, 3 Sep 2016 12:45:21 +1000 Subject: [PATCH] =?UTF-8?q?Shows=20the=20attendee=E2=80=99s=20name=20in=20?= =?UTF-8?q?the=20attendee=20list.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- registrasion/models/people.py | 7 +++++++ registrasion/reporting/views.py | 14 ++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/registrasion/models/people.py b/registrasion/models/people.py index e36bd728..64d0ac40 100644 --- a/registrasion/models/people.py +++ b/registrasion/models/people.py @@ -67,6 +67,13 @@ class AttendeeProfileBase(models.Model): ''' return None + def attendee_name(self): + if type(self) == AttendeeProfileBase: + real = AttendeeProfileBase.objects.get_subclass(id=self.id) + else: + real = self + return getattr(real, real.name_field()) + def invoice_recipient(self): ''' diff --git a/registrasion/reporting/views.py b/registrasion/reporting/views.py index 02557945..eb512454 100644 --- a/registrasion/reporting/views.py +++ b/registrasion/reporting/views.py @@ -332,28 +332,30 @@ def attendee_list(request): attendees = people.Attendee.objects.all().select_related( "attendeeprofilebase", + "user", ) - attendees = attendees.values("id", "user__email").annotate( + attendees = attendees.annotate( has_registered=Count( Q(user__invoice__status=commerce.Invoice.STATUS_PAID) ), ) headings = [ - "User ID", "Email", "Has registered", + "User ID", "Name", "Email", "Has registered", ] data = [] for attendee in attendees: data.append([ - attendee["id"], - attendee["user__email"], - attendee["has_registered"], + attendee.id, + attendee.attendeeprofilebase.attendee_name(), + attendee.user.email, + attendee.has_registered > 0, ]) # Sort by whether they've registered, then ID. - data.sort(key=lambda attendee: (-attendee[2], attendee[0])) + data.sort(key=lambda attendee: (-attendee[3], attendee[0])) return Report("Attendees", headings, data, link_view="attendee")