Changeset - ea07469634ee
[Not reviewed]
0 2 0
Christopher Neugebauer - 8 years ago 2016-12-06 23:18:48
chrisjrn@gmail.com
Fixes individual attendee view, which had disappeared.
2 files changed with 7 insertions and 2 deletions:
0 comments (0 inline, 0 general)
registrasion/reporting/reports.py
Show inline comments
...
 
@@ -264,49 +264,52 @@ class ReportView(object):
 

	
 
        return render(data.request, "registrasion/report.html", ctx)
 

	
 
    def _render_as_csv(self, data):
 
        report = data.reports[data.section]
 

	
 
        # Create the HttpResponse object with the appropriate CSV header.
 
        response = HttpResponse(content_type='text/csv')
 

	
 
        writer = csv.writer(response)
 
        encode = lambda i: i.encode("utf8") if isinstance(i, unicode) else i
 
        writer.writerow(list(encode(i) for i in report.headings()))
 
        for row in report.rows():
 
            writer.writerow(list(encode(i) for i in row))
 

	
 
        return response
 

	
 

	
 
class ReportViewRequestData(object):
 

	
 
    def __init__(self, report_view, request, *a, **k):
 
        self.report_view = report_view
 
        self.request = request
 

	
 
        # Calculate other data
 
        self.form = report_view.get_form(request)
 

	
 
        # Content type and section come from request.GET
 
        self.content_type = request.GET.get("content_type")
 
        self.section = request.GET.get("section")
 
        self.section = int(self.section) if self.section else None
 

	
 
        if self.content_type is None:
 
            self.content_type = "text/html"
 

	
 
        # Reports come from calling the inner view
 
        reports = report_view.inner_view(request, self.form, *a, **k)
 

	
 
        # Normalise to a list
 
        if isinstance(reports, Report):
 
            reports = [reports]
 

	
 
        # Wrap them in appropriate format
 
        reports = ReportView.wrap_reports(reports, self.content_type)
 

	
 
        self.reports = reports
 

	
 

	
 
def get_all_reports():
 
    ''' Returns all the views that have been registered with @report '''
 

	
 
    return list(_all_report_views)
registrasion/reporting/views.py
Show inline comments
...
 
@@ -379,69 +379,71 @@ def credit_notes(request, form):
 
        notes,
 
        headings=["id", "Owner", "Status", "Value"],
 
        link_view=views.credit_note,
 
    )
 

	
 

	
 
@report_view("Invoices")
 
def invoices(request,form):
 
    ''' Shows all of the invoices in the system. '''
 

	
 
    invoices = commerce.Invoice.objects.all().order_by("status")
 

	
 
    return QuerysetReport(
 
        "Invoices",
 
        ["id", "recipient", "value", "get_status_display"],
 
        invoices,
 
        headings=["id", "Recipient", "Value", "Status"],
 
        link_view=views.invoice,
 
    )
 

	
 

	
 
class AttendeeListReport(ListReport):
 

	
 
    def get_link(self, argument):
 
        return reverse(self._link_view) + "?user=%d" % int(argument)
 

	
 

	
 
@report_view("Attendee", form_type=forms.UserIdForm)
 
def attendee(request, form, user_id=None):
 
    ''' Returns a list of all manifested attendees if no attendee is specified,
 
    else displays the attendee manifest. '''
 

	
 
    if user_id is None and form.cleaned_data["user"] is not None:
 
        user_id = form.cleaned_data["user"]
 

	
 
    if user_id is None:
 
        return attendee_list(request)
 

	
 
    if form.cleaned_data["user"] is not None:
 
        user_id = form.cleaned_data["user"]
 
    print user_id
 

	
 
    attendee = people.Attendee.objects.get(user__id=user_id)
 
    name = attendee.attendeeprofilebase.attendee_name()
 

	
 
    reports = []
 

	
 
    profile_data = []
 
    try:
 
        profile = people.AttendeeProfileBase.objects.get_subclass(
 
            attendee=attendee
 
        )
 
        fields = profile._meta.get_fields()
 
    except people.AttendeeProfileBase.DoesNotExist:
 
        fields = []
 

	
 
    exclude = set(["attendeeprofilebase_ptr", "id"])
 
    for field in fields:
 
        if field.name in exclude:
 
            # Not actually important
 
            continue
 
        if not hasattr(field, "verbose_name"):
 
            continue  # Not a publicly visible field
 
        value = getattr(profile, field.name)
 

	
 
        if isinstance(field, models.ManyToManyField):
 
            value = ", ".join(str(i) for i in value.all())
 

	
 
        profile_data.append((field.verbose_name, value))
 

	
 
    cart = CartController.for_user(attendee.user)
 
    reservation = cart.cart.reservation_duration + cart.cart.time_last_updated
 
    profile_data.append(("Current cart reserved until", reservation))
0 comments (0 inline, 0 general)