Shows the attendee’s name in the attendee list.
This commit is contained in:
parent
4dbe69574c
commit
f3a08a82bb
2 changed files with 15 additions and 6 deletions
|
@ -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):
|
||||
'''
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue