Merge branch 'chrisjrn/reports_20160919'

This commit is contained in:
Christopher Neugebauer 2016-09-20 19:41:47 +10:00
commit a445eed239
3 changed files with 56 additions and 1 deletions

View file

@ -1,6 +1,8 @@
from registrasion.models import conditions
from registrasion.models import inventory
from symposion.proposals import models as proposals_models
from django import forms
# Reporting forms.
@ -31,6 +33,14 @@ class UserIdForm(forms.Form):
)
class ProposalKindForm(forms.Form):
kind = forms.ModelMultipleChoiceField(
queryset=proposals_models.ProposalKind.objects.all(),
required=False,
)
def model_fields_form_factory(model):
''' Creates a form for specifying fields from a model to display. '''

View file

@ -5,6 +5,7 @@ import datetime
from django.conf import settings
from django.contrib.auth.decorators import user_passes_test
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models import F, Q
@ -18,6 +19,8 @@ from registrasion.models import people
from registrasion import util
from registrasion import views
from symposion.schedule import models as schedule_models
from reports import get_all_reports
from reports import Links
from reports import ListReport
@ -581,13 +584,14 @@ def attendee_data(request, form, user_id=None):
AttendeeProfile._meta.get_field(field).verbose_name for field in fields
]
headings = ["User ID", "Name", "Product", "Item Status"] + field_names
headings = ["User ID", "Name", "Email", "Product", "Item Status"] + field_names
data = []
for item in items:
profile = by_user[item.cart.user]
line = [
item.cart.user.id,
getattr(profile, name_field),
profile.attendee.user.email,
item.product,
status_display[item.cart.status],
] + [
@ -599,3 +603,39 @@ def attendee_data(request, form, user_id=None):
"Attendees by item with profile data", headings, data, link_view=attendee
))
return output
@report_view(
"Speaker Registration Status",
form_type=forms.ProposalKindForm,
)
def speaker_registrations(request, form):
''' Shows registration status for speakers with a given proposal kind. '''
kinds = form.cleaned_data["kind"]
presentations = schedule_models.Presentation.objects.filter(
proposal_base__kind=kinds,
).exclude(
cancelled=True,
)
users = User.objects.filter(
Q(speaker_profile__presentations__in=presentations) |
Q(speaker_profile__copresentations__in=presentations)
)
paid_carts = commerce.Cart.objects.filter(status=commerce.Cart.STATUS_PAID)
paid_carts = Case(When(cart__in=paid_carts, then=Value(1)), default=Value(0), output_field=models.IntegerField())
users = users.annotate(paid_carts=Sum(paid_carts))
users=users.order_by("paid_carts")
return QuerysetReport(
"Speaker Registration Status",
["id", "speaker_profile__name", "email", "paid_carts",],
users,
link_view=attendee,
)
return []

View file

@ -54,6 +54,11 @@ reports = [
),
url(r"^product_status/?$", rv.product_status, name="product_status"),
url(r"^reconciliation/?$", rv.reconciliation, name="reconciliation"),
url(
r"^speaker_registrations/?$",
rv.speaker_registrations,
name="speaker_registrations",
),
]