Enhance boarding poass processes
* Add a note about the creation date of boarding pass * Add a link to ticket review page * Try to handle some of the expected errors in the boarding pass sending process * don't just 502, try to handle the error and move on.
This commit is contained in:
parent
28d10ff9fc
commit
dc6b7f43ef
2 changed files with 51 additions and 36 deletions
|
@ -12,9 +12,13 @@
|
|||
{% ticket_type as ticket_type %}
|
||||
|
||||
{% block header_title %}
|
||||
<h1>Boarding Pass for {{ attendee.user.email }}</h1>
|
||||
<h1>Boarding Pass for {{ attendee.user.email }}</h1>
|
||||
<div class="panel panel-info">
|
||||
<p>This boarding pass was prepared at {{ boardingpass.created }} and was correct at that time.</p>
|
||||
<p>For an up-to-date list of paid/unpaid items please see <a href="/tickets/review">this review page.</a></p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div>{{ boardingpass|safe }}</div>
|
||||
<div>{{ boardingpass_body|safe }}</div>
|
||||
{% endblock %}
|
||||
|
|
43
vendor/regidesk/regidesk/views.py
vendored
43
vendor/regidesk/regidesk/views.py
vendored
|
@ -50,14 +50,15 @@ def boardingpass(request):
|
|||
return redirect('/tickets/review')
|
||||
prepare_boarding_pass(request, templates[0])
|
||||
|
||||
boardingpass = checkin.boardingpass.html_body
|
||||
boardingpass = checkin.boardingpass
|
||||
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"/>'
|
||||
|
||||
boardingpass = boardingpass.replace(not_qrcode_string, qrcode_string)
|
||||
boardingpass_body = boardingpass.html_body.replace(not_qrcode_string, qrcode_string)
|
||||
ctx = { 'attendee': user.attendee,
|
||||
'boardingpass_body': boardingpass_body,
|
||||
'boardingpass': boardingpass
|
||||
}
|
||||
|
||||
|
@ -126,19 +127,28 @@ def boarding_prepare(request):
|
|||
for pk in request.POST.getlist("_selected_action"):
|
||||
attendee_pks.append(int(pk))
|
||||
except ValueError:
|
||||
return HttpResponseBadRequest()
|
||||
messages.warning(request, ValueError)
|
||||
return redirect("/checkin/overview")
|
||||
attendees = people.Attendee.objects.filter(pk__in=attendee_pks)
|
||||
attendees = attendees.select_related(
|
||||
"user", "attendeeprofilebase", "attendeeprofilebase__attendeeprofile")
|
||||
|
||||
try:
|
||||
sample_checkin = CheckIn.objects.get_or_create(user=attendees[0].user)[0]
|
||||
except:
|
||||
messages.warning(request, "Couldn't find a sample checking - did you add a user?")
|
||||
return redirect("/checkin/overview")
|
||||
|
||||
rendered_template = {}
|
||||
sample_ctx = {}
|
||||
|
||||
bp_template_pk = request.POST.get("template", "")
|
||||
if bp_template_pk:
|
||||
bp_template = BoardingPassTemplate.objects.get(pk=bp_template_pk)
|
||||
if not bp_template_pk:
|
||||
messages.warning(request, "Need to choose a template")
|
||||
return redirect("/checkin/overview")
|
||||
|
||||
bp_template = BoardingPassTemplate.objects.get(pk=bp_template_pk)
|
||||
if bp_template:
|
||||
sample_ctx = {
|
||||
"user": sample_checkin.user,
|
||||
"boardingpass": sample_checkin.boardingpass,
|
||||
|
@ -156,9 +166,10 @@ def boarding_prepare(request):
|
|||
subject = Template(bp_template.subject).render(ctx)
|
||||
rendered_template['plain'] = Template(bp_template.body).render(ctx)
|
||||
rendered_template['html'] = Template(bp_template.html_body).render(ctx)
|
||||
request.session['template'] = bp_template.pk
|
||||
else:
|
||||
bp_template = None
|
||||
subject = None
|
||||
request.session['template'] = None
|
||||
|
||||
ctx = {
|
||||
"attendees": attendees,
|
||||
|
@ -171,10 +182,7 @@ def boarding_prepare(request):
|
|||
|
||||
request.session.set_expiry=(300)
|
||||
request.session['boarding_attendees'] = attendee_pks
|
||||
request.session['template'] = bp_template.pk
|
||||
response = render(request, "regidesk/boardingpass_prepare.html", ctx)
|
||||
|
||||
return response
|
||||
return render(request, "regidesk/boardingpass_prepare.html", ctx)
|
||||
|
||||
def prepare_boarding_pass(request, template, attendee=None):
|
||||
|
||||
|
@ -217,7 +225,7 @@ def prepare_boarding_pass(request, template, attendee=None):
|
|||
user.checkin.boardingpass = bpass
|
||||
user.checkin.save()
|
||||
|
||||
return body, html_body
|
||||
return bpass
|
||||
|
||||
@permission_required("regidesk.send_boarding_pass")
|
||||
def boarding_send(request):
|
||||
|
@ -232,6 +240,7 @@ def boarding_send(request):
|
|||
attendees = attendees.select_related(
|
||||
"user", "attendeeprofilebase", "attendeeprofilebase__attendeeprofile")
|
||||
|
||||
logging.debug(len(attendees))
|
||||
logging.debug(attendees)
|
||||
|
||||
template_pk = request.session['template']
|
||||
|
@ -239,8 +248,9 @@ def boarding_send(request):
|
|||
|
||||
for attendee in attendees:
|
||||
|
||||
body, html_body = prepare_boarding_pass(attendee, template)
|
||||
|
||||
try:
|
||||
user = attendee.user
|
||||
bpass = prepare_boarding_pass(request, template, attendee)
|
||||
msg = EmailMultiAlternatives(
|
||||
bpass.subject,
|
||||
bpass.body,
|
||||
|
@ -249,9 +259,8 @@ def boarding_send(request):
|
|||
)
|
||||
msg.content_subtype="plain"
|
||||
msg.mixed_subtype="related"
|
||||
if html_body:
|
||||
msg.attach_alternative(html_body, "text/html")
|
||||
|
||||
if bpass.html_body:
|
||||
msg.attach_alternative(bpass.html_body, "text/html")
|
||||
msg.attach(filename="qrcode.png", content=user.checkin.qrcode, mimetype="image/png")
|
||||
|
||||
if user in boarding_users:
|
||||
|
@ -260,6 +269,8 @@ def boarding_send(request):
|
|||
bpass.sent = datetime.now()
|
||||
bpass.save()
|
||||
messages.success(request, "Sent boarding pass to %s" % attendee)
|
||||
except:
|
||||
messages.warning(request, "Could not send boarding pass to %s" % attendee)
|
||||
|
||||
request.session['boarding_attendees'].remove(attendee.pk)
|
||||
|
||||
|
|
Loading…
Reference in a new issue