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 43 insertions and 23 deletions:
0 comments (0 inline, 0 general)
pinaxcon/templates/registrasion/review.html
Show inline comments
...
 
@@ -33,12 +33,14 @@
 
  <h3>Current selection</h3>
 

	
 
  <p>You've selected the following items, which will be in your invoice when
 
    you check out:<p>
 
  {% include "registrasion/_items_list.html" with items=pending %}
 

	
 
  {% endif %}
 
  <h3>Previously purchased</h3>
 
  {% items_purchased as purchased %}
 
  {% if purchased %}
 
    <p>You've already paid for the following items:</p>
 
    {% include "registrasion/_items_list.html" with items=purchased suffix="<em>(PAID)</em>" %}
 
  {% endif %}
 

	
...
 
@@ -67,19 +69,21 @@
 

	
 
  {% available_categories as available %}
 
  {% include "registrasion/_category_list.html" with categories=available exclude=missing %}
 

	
 
  <h3>What next?</h3>
 

	
 
  {% if pending %}
 
  <p>You can either check out an invoice and pay for your selections, or return to
 
      the dashboard.</p>
 

	
 
  <div class="btn-group">
 
    <a class="btn btn-success" href="{% url "checkout" %}">
 
      <i class="fa fa-credit-card"></i> Check out and pay
 
    </a>
 

	
 
    <a class="btn btn-primary" href="{% url "dashboard" %}">Return to dashboard</a>
 
  </div>
 

	
 
  {% else %}
 

	
 
  <p>You have no items that need to be paid.</p>
vendor/regidesk/regidesk/views.py
Show inline comments
...
 
@@ -38,14 +38,20 @@ def _staff_only(user):
 
@login_required
 
def boardingpass(request):
 

	
 
    user=request.user
 
    checkin = CheckIn.objects.get_or_create(user=user)[0]
 
    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])
 

	
 
    boardingpass = checkin.boardingpass.html_body
 
    qrcode_url = request.build_absolute_uri(reverse("regidesk:checkin_png", args=[checkin.code]))
 
    qrcode = checkin.qrcode
 
    qrcode_string ='<img src="data:image/png;base64,' + qrcode + '"/>'
 
    not_qrcode_string = '<img src="cid:qrcode.png"/>'
...
 
@@ -167,33 +173,19 @@ def boarding_prepare(request):
 
    request.session['boarding_attendees'] = attendee_pks
 
    request.session['template'] = bp_template.pk
 
    response = render(request, "regidesk/boardingpass_prepare.html", ctx)
 

	
 
    return response
 

	
 
@permission_required("regidesk.send_boarding_pass")
 
def boarding_send(request):
 

	
 
    BOARDING_GROUP = getattr(settings, "REGIDESK_BOARDING_GROUP", None)
 
    if BOARDING_GROUP and Group.objects.filter(name=BOARDING_GROUP):
 
        boarding_users = User.objects.filter(groups__name=BOARDING_GROUP)
 
    else:
 
        boarding_users = User.objects.all()
 

	
 
    attendees = people.Attendee.objects.filter(pk__in=request.session['boarding_attendees'])
 
    attendees = attendees.select_related(
 
        "user", "attendeeprofilebase", "attendeeprofilebase__attendeeprofile")
 

	
 
    logging.debug(attendees)
 

	
 
    template_pk = request.session['template']
 
    template = BoardingPassTemplate.objects.get(pk=template_pk)
 

	
 
    for attendee in attendees:
 
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,
...
 
@@ -222,22 +214,46 @@ def boarding_send(request):
 

	
 
    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")
 
def boarding_send(request):
 

	
 
    BOARDING_GROUP = getattr(settings, "REGIDESK_BOARDING_GROUP", None)
 
    if BOARDING_GROUP and Group.objects.filter(name=BOARDING_GROUP):
 
        boarding_users = User.objects.filter(groups__name=BOARDING_GROUP)
 
    else:
 
        boarding_users = User.objects.all()
 

	
 
    attendees = people.Attendee.objects.filter(pk__in=request.session['boarding_attendees'])
 
    attendees = attendees.select_related(
 
        "user", "attendeeprofilebase", "attendeeprofilebase__attendeeprofile")
 

	
 
    logging.debug(attendees)
 

	
 
    template_pk = request.session['template']
 
    template = BoardingPassTemplate.objects.get(pk=template_pk)
 

	
 
    for attendee in attendees:
 

	
 
        body, html_body = prepare_boarding_pass(attendee, template)
 

	
 
        msg = EmailMultiAlternatives(
 
            bpass.subject,
 
            bpass.body,
 
            bpass.from_address,
 
            [bpass.to_address,],
 
        )
 
        msg.content_subtype="plain"
 
        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")
 

	
 
        msg.attach(filename="qrcode.png", content=user.checkin.qrcode, mimetype="image/png")
 

	
 
        if user in boarding_users:
 
            with transaction.atomic():
 
                msg.send()
0 comments (0 inline, 0 general)