Add support for a "ready for boarding" group

This allows for the boarding functionality to be safely tested with
just a subset of users first. Once you're ready to go live Fur Reals,
just delete the group and all users will become eligible.
This commit is contained in:
James Polley 2018-01-07 22:24:07 +11:00
parent c478fb8454
commit 0831a4aa76
2 changed files with 16 additions and 4 deletions

View file

@ -335,6 +335,9 @@ INVOICE_CURRENCY = "AUD"
TICKET_PRODUCT_CATEGORY = 1
ATTENDEE_PROFILE_FORM = "pinaxcon.registrasion.forms.ProfileForm"
#REGIDESK
REGIDESK_BOARDING_GROUP = "Ready For Boarding"
# CSRF custom error screen
CSRF_FAILURE_VIEW = "pinaxcon.csrf_view.csrf_failure"

View file

@ -7,6 +7,7 @@ from django.core.mail import EmailMultiAlternatives
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import permission_required, user_passes_test, login_required
from django.contrib.auth.models import User, Group
from django.db import transaction
from django.db.models import F, Q
from django.db.models import Count, Max, Sum
@ -145,6 +146,12 @@ def boarding_prepare(request):
@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")
@ -197,11 +204,13 @@ def boarding_send(request):
if bpass.html_body:
msg.attach_alternative(bpass.html_body, "text/html")
msg.send()
if user in boarding_users:
msg.send()
bpass.sent = datetime.now()
bpass.save()
messages.success(request, "Sent boarding pass to %s" % attendee)
bpass.sent = datetime.now()
bpass.save()
messages.success(request, "Sent boarding pass to %s" % attendee)
request.session['boarding_attendees'].remove(attendee.pk)
return redirect("regidesk:boarding_overview")