Shows the attendee’s name in the attendee list.

This commit is contained in:
Christopher Neugebauer 2016-09-03 12:45:21 +10:00
parent 4dbe69574c
commit f3a08a82bb
2 changed files with 15 additions and 6 deletions

View file

@ -67,6 +67,13 @@ class AttendeeProfileBase(models.Model):
''' '''
return None 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): def invoice_recipient(self):
''' '''

View file

@ -332,28 +332,30 @@ def attendee_list(request):
attendees = people.Attendee.objects.all().select_related( attendees = people.Attendee.objects.all().select_related(
"attendeeprofilebase", "attendeeprofilebase",
"user",
) )
attendees = attendees.values("id", "user__email").annotate( attendees = attendees.annotate(
has_registered=Count( has_registered=Count(
Q(user__invoice__status=commerce.Invoice.STATUS_PAID) Q(user__invoice__status=commerce.Invoice.STATUS_PAID)
), ),
) )
headings = [ headings = [
"User ID", "Email", "Has registered", "User ID", "Name", "Email", "Has registered",
] ]
data = [] data = []
for attendee in attendees: for attendee in attendees:
data.append([ data.append([
attendee["id"], attendee.id,
attendee["user__email"], attendee.attendeeprofilebase.attendee_name(),
attendee["has_registered"], attendee.user.email,
attendee.has_registered > 0,
]) ])
# Sort by whether they've registered, then ID. # 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") return Report("Attendees", headings, data, link_view="attendee")