overhaul to django for rsvp codes

This commit is contained in:
Vicky Steeves 2019-08-06 19:51:28 -04:00 committed by Remi Rampin
parent a80757ee10
commit 4a8b7b12de
84 changed files with 422 additions and 157 deletions

6
.directory Normal file
View File

@ -0,0 +1,6 @@
[Dolphin]
Timestamp=2019,8,6,19,50,32
Version=4
[Settings]
HiddenFilesShown=true

View File

@ -1,11 +0,0 @@
pages:
stage: deploy
script:
- mkdir .public
- cp -r * .public
- mv .public public
artifacts:
paths:
- public
only:
- master

0
bigday/__init__.py Normal file
View File

5
bigday/admin.py Normal file
View File

@ -0,0 +1,5 @@
from django.contrib import admin
from .models import InvitedGuest
admin.site.register(InvitedGuest)

5
bigday/apps.py Normal file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class BigdayConfig(AppConfig):
name = 'bigday'

View File

@ -0,0 +1,23 @@
# Generated by Django 2.2.4 on 2019-08-06 22:42
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='InvitedGuests',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('rsvpCode', models.CharField(max_length=3)),
('name', models.CharField(max_length=500)),
('attending', models.BooleanField(default=False)),
],
),
]

View File

@ -0,0 +1,17 @@
# Generated by Django 2.2.4 on 2019-08-06 23:10
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('bigday', '0001_initial'),
]
operations = [
migrations.RenameModel(
old_name='InvitedGuests',
new_name='InvitedGuest',
),
]

View File

9
bigday/models.py Normal file
View File

@ -0,0 +1,9 @@
from django.db import models
class InvitedGuest(models.Model):
rsvpCode = models.CharField(max_length=3)
name = models.CharField(max_length=500)
attending = models.BooleanField(default=False)
def __str__(self):
return '%s (%s)' % (self.name, 'attending' if self.attending else 'not attending')

View File

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 137 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 323 KiB

After

Width:  |  Height:  |  Size: 323 KiB

View File

@ -27,7 +27,7 @@ jQuery(document).ready(function() {
/*
Background
*/
$('.home').backstretch("../img/splash.jpg");
$('.home').backstretch("/static/img/splash.jpg");
$('#top-navbar-1').on('shown.bs.collapse', function(){
$('.home').backstretch("resize");

View File

Before

Width:  |  Height:  |  Size: 676 KiB

After

Width:  |  Height:  |  Size: 676 KiB

View File

Before

Width:  |  Height:  |  Size: 141 KiB

After

Width:  |  Height:  |  Size: 141 KiB

View File

Before

Width:  |  Height:  |  Size: 820 KiB

After

Width:  |  Height:  |  Size: 820 KiB

View File

@ -0,0 +1,56 @@
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Anna & Dan's Big Day!</title>
<!-- CSS -->
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/all.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/animate.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/media-queries.css' %}">
</head>
<body>
{%block page-content%}
{%endblock%}
<!-- Footer -->
<footer>
<div class="container">
<div class="row">
<p>We are so excited to share our big day with all of you! If you have any problems using this website, please contact Vicky Steeves at <a href="mailto:victoriaisteeves@gmail.com">victoriaisteeves@gmail.com</a></p>
</div>
<div class="row">
<div class="col footer-bottom">
<a class="scroll-link" href="#home"><i class="fas fa-chevron-up"></i></a>
</div>
</div>
</div>
</footer>
<!-- Javascript -->
<script src="{% static 'js/jquery-3.2.1.min.js' %}"></script>
<script src="{% static 'js/jquery-migrate-3.0.0.min.js' %}"></script>
<script src="{% static 'js/popper.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
<script src="{% static 'js/jquery.backstretch.min.js' %}"></script>
<script src="{% static 'js/wow.min.js' %}"></script>
<script src="{% static 'js/retina-1.1.0.min.js' %}"></script>
<script src="{% static 'js/waypoints.min.js' %}"></script>
<script src="{% static 'js/scripts.js' %}"></script>
</body>
</html>

View File

@ -1,24 +1,6 @@
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Anna & Dan</title>
<!-- CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/all.css">
<link rel="stylesheet" href="css/animate.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/media-queries.css">
</head>
<body>
{% extends "base.html" %}
{% load staticfiles %}
{%block page-content%}
<!-- Top menu -->
<nav class="navbar navbar-dark fixed-top navbar-expand-md navbar-no-bg">
@ -60,7 +42,6 @@
</div>
</div>
</div>
</div>
</div>
@ -79,7 +60,7 @@
</div>
<div class="col-12 col-lg-5 our-story-box wow fadeInUp">
<div class="our-story-box-img">
<img src="img/about.jpg" alt="Anna and Dan sitting and looking into each other's eyes" data-at2x="img/about.jpg">
<img src="{% static 'img/about.jpg' %}" alt="Anna and Dan sitting and looking into each other's eyes" data-at2x="{% static 'img/about.jpg' %}">
</div>
</div>
</div>
@ -107,7 +88,7 @@
<h3>Where <i class="fas fa-angle-right"></i></h3>
<div class="details-box-date"><i class="fas fa-map-signs"></i> beautiful North Shore of Massachusetts</div>
<p>The wedding ceremony will take place at St. Ann's Church in Peabody, MA: <a href="https://goo.gl/maps/Rb2oaYKVbEb5qvtQA">140 Lynn St, Peabody, MA</a></p>
<p>The reception will follow, at the Hellenic Community Center in Ipswich: <a href="https://www.google.com/maps/place/Hellenic+Community+Center/@42.6696378,-70.8415109,17z/data=!3m1!4b1!4m5!3m4!1s0x89e318ec7b64f835:0xa1cc8d6807bfd7c6!8m2!3d42.6696339!4d-70.8393222">117 County Rd, Ipswich, MA</a> </p>
<p>The reception will follow, at the Hellenic Community Center in Ipswich: <a href="https://goo.gl/maps/6vtU3wm1ynPK5ajv8">117 County Rd, Ipswich, MA</a> </p>
</div>
<div class="col-md-4 details-box wow fadeInUp">
<h3>Registry <i class="fas fa-angle-right"></i></h3>
@ -126,70 +107,24 @@
<div class="col rsvp section-description wow fadeIn">
<h2>RSVP</h2>
<p>Kindly let us know if you will be able to attend our wedding!</p>
<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>
<form action="https://script.google.com/macros/s/AKfycbzAPmI049Uh-lBkJA-VWs_5BGgv3TxUlsdwI-z8eHMrW0Kwr2Y/exec" method="get">
<div class="form-group row">
<label for="name" class="col-4 col-form-label">Name</label>
<div class="col-8">
<input id="name" name="name" placeholder="Name" type="text" class="form-control" required="required">
<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">
<div class="input-group-prepend">
<div class="input-group-text">
<i class="far fa-envelope-open"></i>
</div>
</div>
<div class="form-group row">
<label for="email" class="col-4 col-form-label">Email</label>
<div class="col-8">
<input id="email" name="email" placeholder="Email" type="text" class="form-control" required="required">
</div>
</div>
<div class="form-group row">
<label class="col-4">Are you attending?</label>
<div class="col-8" id="attending-choice">
<div class="form-check form-check-inline">
<input name="attending" id="attending_0" type="radio" class="form-check-input" value="yes" required="required" checked>
<label for="attending_0" class="form-check-label">Yes</label>
</div>
<div class="form-check form-check-inline">
<input name="attending" id="attending_1" type="radio" class="form-check-input" value="no" required="required">
<label for="attending_1" class="form-check-label">No</label>
</div>
</div>
</div>
<div class="form-group row">
<div class="offset-4 col-8">
<button name="submit" type="submit" class="btn btn-primary">Submit</button>
</div>
<input id="rsvp-code" name="rsvp-code" placeholder="RSVP Code" type="text" class="form-control" required="required">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
</div>
<!-- Footer -->
<footer>
<div class="container">
<div class="row">
<p>We are so excited to share our big day with all of you! If you have any problems using this website, please contact Vicky Steeves at <a href="mailto:victoriaisteeves@gmail.com">victoriaisteeves@gmail.com</a></p>
</div>
<div class="row">
<div class="col footer-bottom">
<a class="scroll-link" href="#home"><i class="fas fa-chevron-up"></i></a>
</div>
</div>
</div>
</footer>
<!-- Javascript -->
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/jquery-migrate-3.0.0.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.backstretch.min.js"></script>
<script src="js/wow.min.js"></script>
<script src="js/retina-1.1.0.min.js"></script>
<script src="js/waypoints.min.js"></script>
<script src="js/scripts.js"></script>
</body>
</html>
{%endblock%}

View File

@ -0,0 +1,45 @@
{% extends "base.html" %}
{% load staticfiles %}
{%block page-content%}
<!-- Top menu -->
<nav class="navbar navbar-dark fixed-top navbar-expand-md navbar-no-bg">
<div class="container">
<a class="navbar-brand" href="index.html">Anna & Dan</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</nav>
<div>
<div class="container">
<form action="{% url 'rsvp' %}?rsvp-code={{ rsvpCode }}" method="post">
{% csrf_token %}
{% for guest in guests %}
<div class="form-group row">
<label class="col-2">{{ guest.name }} will be: </label>
<div class="col-10">
<div class="form-check form-check-inline">
<input name="attending_{{ guest.id }}" id="attending_{{ guest.id }}_yes" type="radio" class="form-check-input" value="attending" required="required">
<label for="attending_{{ guest.id }}_yes" class="form-check-label">attending</label>
</div>
<div class="form-check form-check-inline">
<input name="attending_{{ guest.id }}" id="attending_{{ guest.id }}_no" type="radio" class="form-check-input" value="not_attending" required="required">
<label for="attending_{{ guest.id }}_no" class="form-check-label">sending their regrets</label>
</div>
</div>
</div>
{% endfor %}
<div class="form-group row">
<div class="">
<button name="submit" type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
</div>
</div>
{%endblock%}

View File

@ -0,0 +1,39 @@
{% extends "base.html" %}
{% load staticfiles %}
{%block page-content%}
<!-- Top menu -->
<nav class="navbar navbar-dark fixed-top navbar-expand-md navbar-no-bg">
<div class="container">
<a class="navbar-brand" href="index.html">Anna & Dan</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</nav>
<!-- About us -->
<div class="our-story-container section-container section-container-gray-bg" id="our-story">
<div class="container">
<div class="row">
<div class="col-12 col-lg-7 our-story-box wow fadeInLeft">
<div class="our-story-box-text">
<h3>Thank you for RSVP-ing!</h3>
{% if attending %}
<p class="medium-paragraph">Thank you for RSVP-ing! We can't wait to see you at our wedding <i class="fas fa-heart"></i></p>
<p>The ceremony will take place on October 20, 2019. It begin at 2pm at St. Ann's Church in Peabody (<a href="https://goo.gl/maps/Rb2oaYKVbEb5qvtQA">140 Lynn St, Peabody, MA</a>) with the reception following at 4pm at the Hellenic Community Center in Ipswich: <a href="https://goo.gl/maps/6vtU3wm1ynPK5ajv8">117 County Rd, Ipswich, MA</a>.</p>
<p>Add the events to your calendar with <a href="files/Anna__Dans_Wedding_Schedule.ics">this ICS file</a>, which can be imported into any kind of calendar.</p>
{% else %}
<p>Sorry we'll miss you, but we hope to catch up with you soon!</p>
{% endif %}
</div>
</div>
<div class="col-12 col-lg-5 our-story-box wow fadeInUp">
<div class="our-story-box-img">
<img src="{% static 'img/about.jpg' %}" alt="Anna and Dan sitting and looking into each other's eyes" data-at2x="{% static 'img/about.jpg' %}">
</div>
</div>
</div>
</div>
</div>
{%endblock%}

3
bigday/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

24
bigday/views.py Normal file
View File

@ -0,0 +1,24 @@
from django.shortcuts import render, redirect
from django.urls import reverse
from .models import InvitedGuest
def index(request):
return render(request, 'index.html')
def rsvp(request):
rsvpCode = request.GET['rsvp-code']
guests = InvitedGuest.objects.filter(rsvpCode = rsvpCode)
if request.method == 'GET':
return render (request, 'rsvp.html', {'guests':guests, 'rsvpCode': rsvpCode})
elif request.method == 'POST':
any_attending = False
for guest in guests:
attending = request.POST['attending_%d' % guest.id] == 'attending'
guest.attending = attending
any_attending = any_attending or attending
guest.save()
return redirect(reverse('thank-you') + '?attending=' + ('yes' if any_attending else 'no'))
def thanks(request):
return render(request, 'thank-you.html', {'attending': request.GET.get('attending') == 'yes'})

View File

121
djangoWedding/settings.py Normal file
View File

@ -0,0 +1,121 @@
"""
Django settings for djangoWedding project.
Generated by 'django-admin startproject' using Django 2.2.4.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '(6t#m_6niir=*pr5pdl9x!1dj3r=0-fk)bs@9=)wzyjvwiq%v-'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bigday'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'djangoWedding.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'djangoWedding.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
STATIC_URL = '/static/'

10
djangoWedding/urls.py Normal file
View File

@ -0,0 +1,10 @@
from django.contrib import admin
from django.urls import path
import bigday.views
urlpatterns = [
path('admin/', admin.site.urls),
path('', bigday.views.index, name='index'),
path('rsvp',bigday.views.rsvp, name='rsvp'),
path('thanks', bigday.views.thanks, name='thank-you')
]

16
djangoWedding/wsgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
WSGI config for djangoWedding project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoWedding.settings')
application = get_wsgi_application()

21
manage.py Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoWedding.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

View File

@ -1,59 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Anna & Dan</title>
<!-- CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/all.css">
<link rel="stylesheet" href="css/animate.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/media-queries.css">
</head>
<body>
<!-- Top menu -->
<nav class="navbar navbar-dark fixed-top navbar-expand-md navbar-no-bg">
<div class="container">
<a class="navbar-brand" href="index.html">Anna & Dan</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
</div>
</div>
</nav>
<!-- Top content -->
<div class="home">
<div class="container">
<div class="row">
<div class="col-md-8 offset-md-2 text">
<h1 class="wow fadeInLeftBig">Thank you for RSVP-ing!</h1>
</div>
</div>
</div>
</div>
<!-- Javascript -->
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/jquery-migrate-3.0.0.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.backstretch.min.js"></script>
<script src="js/wow.min.js"></script>
<script src="js/retina-1.1.0.min.js"></script>
<script src="js/waypoints.min.js"></script>
<script src="js/scripts.js"></script>
</body>
</html>