diff --git a/vendor/regidesk/regidesk/views.py b/vendor/regidesk/regidesk/views.py index c1a35316..79734090 100644 --- a/vendor/regidesk/regidesk/views.py +++ b/vendor/regidesk/regidesk/views.py @@ -154,8 +154,9 @@ def boarding_prepare(request): "boardingpass": sample_checkin.boardingpass, "code": sample_checkin.code, "qrcode": '', - "qrcode_url": request.build_absolute_uri( - reverse("regidesk:checkin_png", args=[sample_checkin.code])), + # "qrcode_url": request.build_absolute_uri( + # reverse("regidesk:checkin_png", args=[sample_checkin.code])), + "qrcode_url": "https://rego.linux.conf.au/checkin/" + sample_checkin.code + ".png" } ctx = Context(sample_ctx) ctx["invoices"] = invoices(ctx) @@ -184,7 +185,7 @@ def boarding_prepare(request): request.session['boarding_attendees'] = attendee_pks return render(request, "regidesk/boardingpass_prepare.html", ctx) -def prepare_boarding_pass(request, template, attendee=None): +def prepare_boarding_pass(user, template, attendee=None): if attendee: user = attendee.user @@ -197,8 +198,9 @@ def prepare_boarding_pass(request, template, attendee=None): "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])), + # "qrcode_url": request.build_absolute_uri( + # reverse("regidesk:checkin_png", args=[user.checkin.code])), + "qrcode_url": "https://rego.linux.conf.au/checkin/" + user.checkin.code + ".png" } ctx = Context(ctx) ctx["invoices"] = invoices(ctx) @@ -227,6 +229,23 @@ def prepare_boarding_pass(request, template, attendee=None): return bpass +def send_boarding_pass(bpass, user): + 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") + msg.attach(filename="qrcode.png", content=user.checkin.qrcode, mimetype="image/png") + + msg.send() + bpass.sent = datetime.now() + bpass.save() + @permission_required("regidesk.send_boarding_pass") def boarding_send(request): @@ -246,37 +265,17 @@ def boarding_send(request): template_pk = request.session['template'] template = BoardingPassTemplate.objects.get(pk=template_pk) - i = 0 for attendee in attendees: try: user = attendee.user - bpass = prepare_boarding_pass(request, template, attendee) - 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") - msg.attach(filename="qrcode.png", content=user.checkin.qrcode, mimetype="image/png") - + bpass = prepare_boarding_pass(user, template, attendee) if user in boarding_users: - with transaction.atomic(): - msg.send() - bpass.sent = datetime.now() - bpass.save() - messages.success(request, "Sent boarding pass to %s" % attendee) + send_boarding_pass(user, bpass) + 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) - i += 1 - if i == 10: - return redirect("regidesk:boarding_send") - return redirect("regidesk:boarding_overview")