Changeset - 7d18387670ca
[Not reviewed]
0 2 0
James Polley - 6 years ago 2018-01-16 12:11:14
jp@jamezpolley.com
If no boardingpass, make one

- Use the first template in the system
- If there's no template, use /tickets/review as it at least gives
- people an overview of what they've paid for and warns them of
missing categories
2 files changed with 58 insertions and 38 deletions:
0 comments (0 inline, 0 general)
pinaxcon/templates/registrasion/review.html
Show inline comments
...
 
@@ -38,2 +38,4 @@
 

	
 
  {% endif %}
 
  <h3>Previously purchased</h3>
 
  {% items_purchased as purchased %}
...
 
@@ -72,2 +74,3 @@
 

	
 
  {% if pending %}
 
  <p>You can either check out an invoice and pay for your selections, or return to
...
 
@@ -79,2 +82,3 @@
 
    </a>
 

	
 
    <a class="btn btn-primary" href="{% url "dashboard" %}">Return to dashboard</a>
vendor/regidesk/regidesk/views.py
Show inline comments
...
 
@@ -43,4 +43,10 @@ def boardingpass(request):
 
    if not checkin.boardingpass:
 
        messages.add_message(request, messages.WARNING, 'Your boarding pass has not been prepared. Please try again later.')
 
        return redirect('/')
 
        templates = BoardingPassTemplate.objects.all()
 
        if not templates:
 
            messages.add_message(request, messages.WARNING,
 
                                 'Your boarding pass has not been prepared and I can\'t find a '
 
                                 'default template to use. This page has similar information to '
 
                                 'the boarding pass - please check back later.')
 
            return redirect('/tickets/review')
 
        prepare_boarding_pass(request, templates[0])
 

	
...
 
@@ -172,2 +178,45 @@ def boarding_prepare(request):
 

	
 
def prepare_boarding_pass(request, template, attendee=None):
 

	
 
    if attendee:
 
        user = attendee.user
 
    else:
 
        user = request.user
 
        attendee=user.attendee
 
    checkin = CheckIn.objects.get_or_create(user=user)
 
    ctx = {
 
        "user": user,
 
        "checkin": user.checkin,
 
        "code": user.checkin.code,
 
        "qrcode": user.checkin.qrcode,
 
        "qrcode_url": request.build_absolute_uri(
 
            reverse("regidesk:checkin_png", args=[user.checkin.code])),
 
    }
 
    ctx = Context(ctx)
 
    ctx["invoices"] = invoices(ctx)
 
    ctx["items_pending"] = items_pending(ctx)
 
    ctx["items_purchased"] = items_purchased(ctx)
 
    ctx["missing_categories"] = missing_categories(ctx)
 

	
 
    subject = Template(template.subject).render(ctx)
 
    body = Template(template.body).render(ctx)
 
    if template.html_body:
 
        html_body = Template(template.html_body).render(ctx)
 
    else:
 
        html_body = None
 

	
 
    bpass = BoardingPass(template=template, to_address=user.email,
 
                         from_address=template.from_address,
 
                         subject=subject, body=body,
 
                         html_body=html_body
 
    )
 
    bpass.save()
 

	
 
    if user.checkin.boardingpass:
 
        user.checkin.boardingpass.delete()
 
    user.checkin.boardingpass = bpass
 
    user.checkin.save()
 

	
 
    return body, html_body
 

	
 
@permission_required("regidesk.send_boarding_pass")
...
 
@@ -192,36 +241,3 @@ def boarding_send(request):
 

	
 
        user = attendee.user
 
        checkin = CheckIn.objects.get_or_create(user=user)
 
        ctx = {
 
            "user": user,
 
            "checkin": user.checkin,
 
            "code": user.checkin.code,
 
            "qrcode": user.checkin.qrcode,
 
            "qrcode_url": request.build_absolute_uri(
 
                reverse("regidesk:checkin_png", args=[user.checkin.code])),
 
        }
 
        ctx = Context(ctx)
 
        ctx["invoices"] = invoices(ctx)
 
        ctx["items_pending"] = items_pending(ctx)
 
        ctx["items_purchased"] = items_purchased(ctx)
 
        ctx["missing_categories"] = missing_categories(ctx)
 

	
 
        subject = Template(template.subject).render(ctx)
 
        body = Template(template.body).render(ctx)
 
        if template.html_body:
 
            html_body = Template(template.html_body).render(ctx)
 
        else:
 
            html_body = None
 

	
 
        bpass = BoardingPass(template=template, to_address=user.email,
 
                             from_address=template.from_address,
 
                             subject=subject, body=body,
 
                             html_body=html_body
 
        )
 
        bpass.save()
 

	
 
        if user.checkin.boardingpass:
 
            user.checkin.boardingpass.delete()
 
        user.checkin.boardingpass = bpass
 
        user.checkin.save()
 
        body, html_body = prepare_boarding_pass(attendee, template)
 

	
...
 
@@ -235,4 +251,4 @@ def boarding_send(request):
 
        msg.mixed_subtype="related"
 
        if bpass.html_body:
 
            msg.attach_alternative(bpass.html_body, "text/html")
 
        if html_body:
 
            msg.attach_alternative(html_body, "text/html")
 

	
0 comments (0 inline, 0 general)