# Path: hackday/common.py
# def common_env():
#     env = {
#         'nav_pages': get_nav_pages(),
#     }
#     return env
# 
# Path: hackday/messaging/models.py
# class RSVP(models.Model):
#     email = models.EmailField('email')
#     will_attend = models.BooleanField('will attend')
# 
#     create_date = models.DateTimeField('date created', auto_now_add=True)
#     mod_date = models.DateTimeField('date modified', auto_now=True)
# 
#     def __unicode__(self):
#         return self.email
# 
#     class Meta:
#         verbose_name_plural = "RSVPs"
#         ordering = ['email']
# 
# Path: hackday/messaging/forms.py
# class RSVPForm(forms.Form):
#     email = forms.EmailField(label='My Email Address',)
#     will_attend = forms.BooleanField(
#             label="Yes I do plan to attend the Hack Day presentations", required=False)


from django.shortcuts import render
from django.template import Context, loader
from hackday.common import common_env
from hackday.messaging.models import RSVP
from hackday.messaging.forms import RSVPForm


def rsvp(request):
    saved = False
    updated = False
    if request.method == 'POST':
        form = RSVPForm(request.POST)
        if form.is_valid():
            email = form.cleaned_data['email']
            will_attend = form.cleaned_data['will_attend']
            try:
                rsvp = RSVP.objects.get(email=email)
                updated = True
            except:

# Path: hackday/common.py
# def common_env():
#     env = {
#         'nav_pages': get_nav_pages(),
#     }
#     return env
# 
# Path: hackday/messaging/models.py
# class RSVP(models.Model):
#     email = models.EmailField('email')
#     will_attend = models.BooleanField('will attend')
# 
#     create_date = models.DateTimeField('date created', auto_now_add=True)
#     mod_date = models.DateTimeField('date modified', auto_now=True)
# 
#     def __unicode__(self):
#         return self.email
# 
#     class Meta:
#         verbose_name_plural = "RSVPs"
#         ordering = ['email']
# 
# Path: hackday/messaging/forms.py
# class RSVPForm(forms.Form):
#     email = forms.EmailField(label='My Email Address',)
#     will_attend = forms.BooleanField(
#             label="Yes I do plan to attend the Hack Day presentations", required=False)


# Path: hackday/messaging/views.py
from django.shortcuts import render
from django.template import Context, loader
from hackday.common import common_env
from hackday.messaging.models import RSVP
from hackday.messaging.forms import RSVPForm



def rsvp(request):
    saved = False
    updated = False
    if request.method == 'POST':
        form = RSVPForm(request.POST)
        if form.is_valid():
            email = form.cleaned_data['email']
            will_attend = form.cleaned_data['will_attend']
            try:
                rsvp = RSVP.objects.get(email=email)
                updated = True
            except:

                rsvp = RSVP()