Changeset - f3a08a82bb96
[Not reviewed]
0 2 0
Christopher Neugebauer - 8 years ago 2016-09-03 02:45:21
chrisjrn@gmail.com
Shows the attendee’s name in the attendee list.
2 files changed with 15 insertions and 6 deletions:
0 comments (0 inline, 0 general)
registrasion/models/people.py
Show inline comments
...
 
@@ -46,43 +46,50 @@ class Attendee(models.Model):
 
    guided_categories_complete = models.ManyToManyField("category")
 

	
 

	
 
class AttendeeProfileBase(models.Model):
 
    ''' Information for an attendee's badge and related preferences.
 
    Subclass this in your Django site to ask for attendee information in your
 
    registration progess.
 
     '''
 

	
 
    class Meta:
 
        app_label = "registrasion"
 

	
 
    objects = InheritanceManager()
 

	
 
    @classmethod
 
    def name_field(cls):
 
        '''
 
        Returns:
 
            The name of a field that stores the attendee's name. This is used
 
            to pre-fill the attendee's name from their Speaker profile, if they
 
            have one.
 
        '''
 
        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):
 
        '''
 

	
 
        Returns:
 
            A representation of this attendee profile for the purpose
 
            of rendering to an invoice. This should include any information
 
            that you'd usually include on an invoice. Override in subclasses.
 
        '''
 

	
 
        # Manual dispatch to subclass. Fleh.
 
        slf = AttendeeProfileBase.objects.get_subclass(id=self.id)
 
        # Actually compare the functions.
 
        if type(slf).invoice_recipient != type(self).invoice_recipient:
 
            return type(slf).invoice_recipient(slf)
 

	
 
        # Return a default
 
        return slf.attendee.user.username
 

	
 
    attendee = models.OneToOneField(Attendee, on_delete=models.CASCADE)
registrasion/reporting/views.py
Show inline comments
...
 
@@ -311,49 +311,51 @@ def attendee(request, form, attendee_id=None):
 
    headings = ["To Invoice", "Payment ID", "Reference", "Amount"]
 
    data = []
 

	
 
    payments = commerce.PaymentBase.objects.filter(
 
        invoice__user=attendee.user,
 
    )
 
    for payment in payments:
 
        data.append([
 
            payment.invoice.id, payment.id, payment.reference, payment.amount,
 
        ])
 

	
 
    reports.append(
 
        Report("Payments", headings, data, link_view="invoice")
 
    )
 

	
 

	
 
    return reports
 

	
 

	
 
def attendee_list(request):
 
    ''' Returns a list of all attendees. '''
 

	
 
    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")
0 comments (0 inline, 0 general)