From aec8ea57afda48e7bbf56c45146b43afb6ba6f41 Mon Sep 17 00:00:00 2001 From: Remi Rampin Date: Tue, 6 Aug 2019 21:53:16 -0400 Subject: [PATCH] Show a message if the invitation code is wrong --- bigday/templates/index.html | 6 ++++++ bigday/views.py | 3 +++ 2 files changed, 9 insertions(+) diff --git a/bigday/templates/index.html b/bigday/templates/index.html index e9c28a8..ec9e6db 100644 --- a/bigday/templates/index.html +++ b/bigday/templates/index.html @@ -108,6 +108,12 @@

RSVP

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.

+ + {% if invalid_code %} + + {% endif %}
diff --git a/bigday/views.py b/bigday/views.py index 7d3a94d..4f84631 100644 --- a/bigday/views.py +++ b/bigday/views.py @@ -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