Show a message if the invitation code is wrong

This commit is contained in:
Remi Rampin 2019-08-06 21:53:16 -04:00
parent 2e73ef2464
commit aec8ea57af
2 changed files with 9 additions and 0 deletions

View File

@ -109,6 +109,12 @@
<p>Kindly let us know if you will be able to attend our wedding! On the back of your invitation should be a two-digit code. Please enter that in the box below, which will take you to a personalized RSVP form.</p>
{% if invalid_code %}
<div class="alert alert-danger" role="alert">
Sorry, this invitation code doesn't seem quite right...
</div>
{% endif %}
<form action="{% url 'rsvp' %}" method="get" class="form-inline justify-content-center">
<label class="sr-only" for="rsvp-code">RSVP Code</label>
<div class="input-group mr-2">

View File

@ -9,6 +9,9 @@ def rsvp(request):
rsvpCode = request.GET['rsvp-code']
guests = InvitedGuest.objects.filter(rsvpCode = rsvpCode)
if request.method == 'GET':
if not guests:
# No guests with that code
return render(request, 'index.html', {'invalid_code': True})
return render (request, 'rsvp.html', {'guests':guests, 'rsvpCode': rsvpCode})
elif request.method == 'POST':
any_attending = False