diff --git a/registrasion/reporting/forms.py b/registrasion/reporting/forms.py index 2e983491..010a8f24 100644 --- a/registrasion/reporting/forms.py +++ b/registrasion/reporting/forms.py @@ -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. ''' diff --git a/registrasion/reporting/views.py b/registrasion/reporting/views.py index 50901821..3e3f9308 100644 --- a/registrasion/reporting/views.py +++ b/registrasion/reporting/views.py @@ -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 @@ -600,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 [] diff --git a/registrasion/urls.py b/registrasion/urls.py index d7e440df..c7f008d0 100644 --- a/registrasion/urls.py +++ b/registrasion/urls.py @@ -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", + ), ]