Create /boardingpass
This commit is contained in:
parent
9abea97625
commit
79085a798a
3 changed files with 28 additions and 1 deletions
|
@ -30,6 +30,7 @@ urlpatterns = [
|
|||
url(r'^pages/', include('django.contrib.flatpages.urls')),
|
||||
|
||||
url(r'^dashboard/', RedirectView.as_view(url='/')),
|
||||
url(r'^boardingpass', RedirectView.as_view(pattern_name="regidesk:boardingpass")),
|
||||
url(r'^$', symposion.views.dashboard, name="dashboard"),
|
||||
|
||||
]
|
||||
|
|
2
vendor/regidesk/regidesk/urls.py
vendored
2
vendor/regidesk/regidesk/urls.py
vendored
|
@ -4,9 +4,11 @@ from regidesk import views
|
|||
|
||||
app_name='regidesk'
|
||||
urlpatterns = [
|
||||
url(r"^boardingpass", views.boardingpass, name="boardingpass"),
|
||||
url(r"^([A-Z0-9]{6}$)", views.boarding_overview, name="checkin_detail"),
|
||||
url(r"^([A-Z0-9]{6}).png$", views.checkin_png, name="checkin_png"),
|
||||
url(r"^overview/([a-z]+)?$", views.boarding_overview, name="boarding_overview"),
|
||||
url(r"^prepare_passes/", views.boarding_prepare, name="boarding_prepare"),
|
||||
url(r"^send_passes/", views.boarding_send, name="boarding_send")
|
||||
]
|
||||
.
|
||||
|
|
26
vendor/regidesk/regidesk/views.py
vendored
26
vendor/regidesk/regidesk/views.py
vendored
|
@ -35,6 +35,30 @@ def _staff_only(user):
|
|||
''' Returns true if the user is staff. '''
|
||||
return user.is_staff
|
||||
|
||||
@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('/')
|
||||
|
||||
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"/>'
|
||||
|
||||
boardingpass = boardingpass.replace(not_qrcode_string, qrcode_string)
|
||||
ctx = { 'attendee': user.attendee,
|
||||
'boardingpass': checkin.boardingpass.html_body
|
||||
}
|
||||
|
||||
response = render(request, "regidesk/boardingpass.html", ctx)
|
||||
return response
|
||||
|
||||
|
||||
@permission_required("regidesk.view_boarding_pass")
|
||||
def boarding_overview(request, boarding_state="pending"):
|
||||
|
||||
|
@ -177,7 +201,7 @@ def boarding_send(request):
|
|||
"user": user,
|
||||
"checkin": user.checkin,
|
||||
"code": user.checkin.code,
|
||||
"qrcode": '<img src="cid:qrcode.png"/>',
|
||||
"qrcode": '<img src="cid:qrcode.png" alt="' + user.checkin.code + '"/>',
|
||||
"qrcode_url": request.build_absolute_uri(
|
||||
reverse("regidesk:checkin_png", args=[user.checkin.code])),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue