Changeset - 7fac10241ec7
[Not reviewed]
0 3 0
Joel Addison - 4 years ago 2020-01-10 12:49:17
joel@addison.net.au
Improve attendee reports

Display attendee profile data in normal table without DataTables so
sorting is not applied, causing data to be confusing to read.
Include item quantity in attendee data report for accurate schwag packing.
3 files changed with 29 insertions and 22 deletions:
0 comments (0 inline, 0 general)
pinaxcon/registrasion/models.py
Show inline comments
...
 
@@ -60,48 +60,49 @@ class AttendeeProfile(rego.AttendeeProfileBase):
 
                ("state", "Australians must list their state"),
 
            )
 

	
 
        if self.address_line_2 and not self.address_line_1:
 
            errors.append((
 
                "address_line_1",
 
                "Please fill in line 1 before filling line 2",
 
            ))
 

	
 
        if errors:
 
            raise ValidationError(dict(errors))
 

	
 
    def save(self):
 
        if not self.name_per_invoice:
 
            self.name_per_invoice = self.name
 
        super(AttendeeProfile, self).save()
 

	
 
    # Things that appear on badge
 
    name = models.CharField(
 
        verbose_name="Your name (for your conference nametag)",
 
        max_length=64,
 
        help_text="Your name, as you'd like it to appear on your badge. ",
 
    )
 
    company = models.CharField(
 
        verbose_name="Company",
 
        max_length=64,
 
        help_text="The name of your company, as you'd like it on your badge",
 
        blank=True,
 
    )
 

	
 
    free_text_1 = models.CharField(
 
        max_length=64,
 
        verbose_name="Free text line 1",
 
        help_text="A line of free text that will appear on your badge. Use "
 
                  "this for your Twitter handle, IRC nick, your preferred "
 
                  "pronouns or anything else you'd like people to see on "
 
                  "your badge.",
 
        blank=True,
 
    )
 
    free_text_2 = models.CharField(
 
        max_length=64,
 
        verbose_name="Free text line 2",
 
        blank=True,
 
    )
 

	
 
    # Other important Information
 
    name_per_invoice = models.CharField(
 
        verbose_name="Your legal name (for invoicing purposes)",
 
        max_length=256,
...
 
@@ -112,80 +113,83 @@ class AttendeeProfile(rego.AttendeeProfileBase):
 
        )
 

	
 
    address_line_1 = models.CharField(
 
        verbose_name="Address line 1",
 
        help_text="This address, if provided, will appear on your invoices.",
 
        max_length=1024,
 
        blank=True,
 
    )
 
    address_line_2 = models.CharField(
 
        verbose_name="Address line 2",
 
        max_length=1024,
 
        blank=True,
 
    )
 
    address_suburb = models.CharField(
 
        verbose_name="City/Town/Suburb",
 
        max_length=1024,
 
        blank=True,
 
    )
 
    address_postcode = models.CharField(
 
        verbose_name="Postal/Zip code",
 
        max_length=1024,
 
        blank=True,
 
    )
 
    country = CountryField(
 
        verbose_name="Country",
 
        default="AU",
 
    )
 
    state = models.CharField(
 
        max_length=256,
 
        verbose_name="State/Territory/Province",
 
        help_text="If your Country is Australia, you must list a state.",
 
        blank=True,
 
    )
 

	
 
    of_legal_age = models.BooleanField(
 
        verbose_name="Are you over 18?",
 
        help_text="Being under 18 will not stop you from attending the "
 
                  "conference. We need to know whether you are over 18 to "
 
                  "allow us to cater for you at venues that serve alcohol.",
 
    )
 
    dietary_restrictions = models.CharField(
 
        verbose_name="Food allergies, intolerances, or dietary restrictions",
 
        max_length=256,
 
        blank=True,
 
    )
 
    accessibility_requirements = models.CharField(
 
        verbose_name="Accessibility-related requirements",
 
        max_length=256,
 
        blank=True,
 
    )
 
    gender = models.CharField(
 
        verbose_name="Gender",
 
        help_text="Gender data will only be used for demographic purposes.",
 
        max_length=64,
 
        blank=True,
 
    )
 

	
 
    children = models.CharField(
 
        verbose_name="Child Ages and Information",
 
        max_length=256,
 
        help_text="Linux.conf.au is a family friendly conference and provides "
 
            "free child-care for pre-school children from 6 months up to 5 years. We "
 
            "hope to also provide a programme for older children and will let you "
 
            "know closer to the conference. If you're wanting to bring your children "
 
            "to LCA, please let us know their age(s) so we can ensure we have "
 
            "enough spaces available.",
 
        blank=True
 
    )
 

	
 
    linux_australia = models.BooleanField(
 
        verbose_name="Linux Australia membership",
 
        help_text="Select this field to register for free "
 
                  "<a href='http://www.linux.org.au/'>Linux Australia</a> "
 
                  "membership.",
 
        blank=True,
 
    )
 

	
 
    lca_announce = models.BooleanField(
 
        verbose_name="Subscribe to lca-announce list",
 
        help_text="Select to be subscribed to the low-traffic lca-announce "
 
                  "mailing list",
 
        blank=True,
 
    )
...
 
@@ -196,25 +200,25 @@ class AttendeeProfile(rego.AttendeeProfileBase):
 
                  "attendees during the week of the conference for general "
 
                  "discussion.",
 
        blank=True,
 
    )
 

	
 
    future_conference = models.BooleanField(
 
        verbose_name = "Reuse my login for future Linux Australia conferences?",
 
        help_text="Select to have your login details made available to future "
 
                  "Linux Australia conferences who share the same Single Sign "
 
                  "On system.",
 
        blank=True,
 
    )
 

	
 
    past_lca = models.ManyToManyField(
 
        PastEvent,
 
        verbose_name="Which past linux.conf.au events have you attended?",
 
        blank=True,
 
    )
 

	
 
    def first_name(self):
 
        return wrap(self.name, 15, break_long_words=False)[0]
 

	
 
    def last_name(self):
 
        names = wrap(self.name, 15, break_long_words=False)
 
        return names[1] if len(names) > 1 else ''
...
 
\ No newline at end of file
 
        return names[1] if len(names) > 1 else ''
pinaxcon/templates/registrasion/report.html
Show inline comments
...
 
@@ -3,70 +3,68 @@
 
{% load registrasion_tags %}
 

	
 
{% block page_title %}Registration report{% endblock %}
 
{% block head_title %}Registration report - {{ title }}{% endblock %}
 

	
 
{% block content %}
 

	
 
  <h2>{{ title }}</h2>
 

	
 
  <p><a href="{% url 'reports_list' %}">Return to reports list</a></p>
 

	
 
  {% if form %}
 
    <form class="form-horizontal" method="GET">
 
      {{ form | bootstrap}}
 
      <br/>
 
      <input class="btn btn-primary" type="submit">
 
    </form>
 
  {% endif %}
 
<hr />
 

	
 
{% for report in reports %}
 
<h3>{{ report.title }}</h3>
 
{% if report.headings %}
 
<table class="table table-striped table-reportdata">
 
  <thead>
 
    <tr>
 
      {% for heading in report.headings %}
 
      <th>{{ heading }}</th>
 
      {% endfor %}
 
    </tr>
 
  </thead>
 
{% else %}
 
<table class="table table-striped">
 
{% endif %}
 
    <thead>
 
        <tr>
 
            {% for heading in report.headings %}
 
            <th>{{ heading }}</th>
 
            {% endfor %}
 
        </tr>
 
    </thead>
 
    <tbody>
 
        {% for line in report.rows %}
 
        <tr>
 
            {% for item in line %}
 
            <td>
 
                {{ item|safe }}
 
            </td>
 
            {% endfor %}
 
        </tr>
 
        {% endfor %}
 
    </tbody>
 
    </table>
 
  <tbody>
 
    {% for line in report.rows %}
 
    <tr>
 
      {% for item in line %}
 
      <td>{{ item|safe }}</td>
 
      {% endfor %}
 
    </tr>
 
    {% endfor %}
 
  </tbody>
 
</table>
 

	
 
<hr class="my-5" />
 
{% endfor %}
 

	
 
{% endblock %}
 

	
 
{% block extra_script %}
 
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.10.20/b-1.6.0/b-colvis-1.6.0/b-html5-1.6.0/b-print-1.6.0/cr-1.5.2/fc-3.3.0/fh-3.1.6/r-2.2.3/rg-1.1.1/datatables.min.css"/>
 

	
 
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
 
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
 
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.10.20/b-1.6.0/b-colvis-1.6.0/b-html5-1.6.0/b-print-1.6.0/cr-1.5.2/fc-3.3.0/fh-3.1.6/r-2.2.3/rg-1.1.1/datatables.min.js"></script>
 

	
 
<script type="text/javascript">
 
  $("table.table-reportdata").dataTable({
 
    "dom":
 
      "<'row'<'col-sm-12 col-md-3'l><'col-sm-12 col-md-5'B><'col-sm-12 col-md-4'f>>" +
 
      "<'row'<'col-sm-12'tr>>" +
 
      "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
 
    "stateSave": true,
 
    "lengthMenu": [[10, 50, 100, -1], [10, 50, 100, "All"]],
 
    "pageLength": 100,
 
    "buttons": [
 
      "csv",
vendor/registrasion/registrasion/reporting/views.py
Show inline comments
...
 
@@ -577,57 +577,61 @@ def attendee(request, form, user_id=None):
 
        fields = profile._meta.get_fields()
 
    except people.AttendeeProfileBase.DoesNotExist:
 
        name = attendee.user.username
 
        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())
 
        elif isinstance(field, CharField):
 
            try:
 
                value = bleach.clean(str(value))
 
            except TypeError:
 
                value = "Bad value for %s" % field.name
 

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

	
 
    profile_data.insert(1, ("Email", attendee.user.email))
 

	
 
    cart = CartController.for_user(attendee.user)
 
    try:
 
        reservation = cart.cart.reservation_duration + cart.cart.time_last_updated
 
    except AttributeError:  # No reservation_duration set -- default to 24h
 
        reservation = datetime.datetime.now() + datetime.timedelta(hours=24)
 

	
 
    profile_data.append(("Current cart reserved until", reservation))
 

	
 
    reports.append(ListReport("Profile", ["", ""], profile_data))
 
    # No column headings, as this has row headings instead and sorting makes
 
    # everything confusing.
 
    reports.append(ListReport("Profile", None, profile_data))
 

	
 
    links = []
 
    links.append((
 
        reverse(views.badge, args=[user_id]),
 
        "View badge",
 
    ))
 
    links.append((
 
        reverse(views.amend_registration, args=[user_id]),
 
        "Amend current cart",
 
    ))
 
    links.append((
 
        reverse(views.extend_reservation, args=[user_id]),
 
        "Extend reservation",
 
    ))
 

	
 
    reports.append(Links("Actions for " + name, links))
 

	
 
    # Paid and pending  products
 
    try:
 
        ic = ItemController(attendee.user)
 
        reports.append(ListReport(
 
            "Paid Products",
 
            ["Product", "Quantity"],
 
            [(pq.product, pq.quantity) for pq in ic.items_purchased()],
...
 
@@ -866,58 +870,59 @@ def attendee_data(request, form, user_id=None):
 
                    group["unpaid_count"] or 0,
 
                )
 
                for group in groups
 
            ],
 
        ))
 

	
 
    # DO the report for individual attendees
 

	
 
    field_names = [
 
        AttendeeProfile._meta.get_field(field).verbose_name for field in fields
 
    ]
 

	
 
    def display_field(profile, field):
 
        field_type = AttendeeProfile._meta.get_field(field)
 
        attr = getattr(profile, field)
 

	
 
        if isinstance(field_type, models.ManyToManyField):
 
            return [str(i) for i in attr.all()] or ""
 
        else:
 
            try:
 
                return bleach.clean(str(attr))
 
            except TypeError:
 
                return "Bad value found for %s" % attr
 

	
 
    headings = ["User ID", "Name", "Email", "Product", "Item Status"]
 
    headings = ["User ID", "Name", "Email", "Product", "Quantity", "Item Status"]
 
    headings.extend(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,
 
            item.quantity,
 
            status_display[item.cart.status],
 
        ] + [
 
            display_field(profile, field) for field in fields
 
        ]
 
        data.append(line)
 

	
 
    output.append(AttendeeListReport(
 
        "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__in=kinds,
0 comments (0 inline, 0 general)