This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.conf.urls import include, url, patterns | |
| from django.contrib import admin | |
| from django.conf import settings | |
| urlpatterns = [ | |
| url(r'^admin/', include(admin.site.urls)), | |
| url(r'^rsvp/', include('rsvp.urls', namespace='rsvp')), | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.conf.urls import include, url | |
| from .views import IndexView, ThanksView, ConfirmView | |
| urlpatterns = [ | |
| url(r'^$', IndexView.as_view(), name='index'), | |
| url(r'^confirm/$', ConfirmView.as_view(), name='confirm'), | |
| url(r'^thanks/$', ThanksView.as_view(), name='thanks'), | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.shortcuts import render | |
| from django.core.urlresolvers import reverse, reverse_lazy | |
| from django.http import HttpResponseRedirect | |
| from django.views.generic import View, TemplateView, FormView, UpdateView | |
| from django.forms.formsets import formset_factory | |
| from django.forms.models import modelformset_factory | |
| from .models import Invitee, Extra | |
| from .forms import RSVPForm, ExtraForm, InviteeForm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django import forms | |
| from django.core.exceptions import ObjectDoesNotExist | |
| from django.forms.models import modelformset_factory | |
| from .models import Invitee, Extra | |
| class RSVPForm(forms.Form): | |
| code = forms.CharField(max_length=56) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def clean(self): | |
| """ Validate site and people resource ids with Doorman """ | |
| if settings.FEATURE_DOORMAN_VALIDATION_ON: | |
| doorman = DoormanClient() | |
| if hasattr(self, 'site'): | |
| if not doorman.resource_exists(resource='sites', resource_id=self.site): | |
| raise ValidationError('Invalid site id: {0}'.format(self.site)) | |
| if hasattr(self, 'editor'): | |
| if not doorman.resource_exists(resource='people', resource_id=self.editor): | |
| raise ValidationError('Invalid editor id: {0}'.format(self.editor)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def test_colection_uniqueness(self): | |
| collection = CollectionFactory() | |
| collection2 = CollectionFactory() | |
| collection.site = 'foo' | |
| collection.slug = 'foo' | |
| collection2.site = 'foo' | |
| collection2.site = 'foo' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ConfirmView(UpdateView): | |
| template_name = 'rsvp/confirm.html' | |
| success_url = reverse_lazy('rsvp:thanks') | |
| form_class = InviteeForm | |
| model = Invitee | |
| def get_context_data(self, **kwargs): | |
| context = super().get_context_data(**kwargs) | |
| obj = self.get_object() | |
| num_current_extras = Extra.objects.filter(invitee=obj).count() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var mongoose = require('mongoose'); | |
| var ExtraSchema = new mongoose.Schema({ | |
| name: String, | |
| }); | |
| var RsvpSchema = new mongoose.Schema({ | |
| code: {type: String, unique: true, dropDups: true}, | |
| email: String, | |
| allowed_extras: Number, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var app = angular.module('myApp', []); | |
| app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { | |
| $routeProvider. | |
| when('/', { | |
| templateUrl: '../views/codeform.html', | |
| controller: 'MainController' | |
| }). | |
| when('/confirm', { | |
| templateUrl: '../views/confirm.html', | |
| controller: 'ConfirmController' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="jumbotron text-center"> | |
| <h1>RSVP Here<span class="label label-info"></span></h1> | |
| </div> | |
| <div id="rsvp-form" class="row"> | |
| <div class="col-sm-8 col-sm-offset-2 text-center"> | |
| <form> | |
| <div class="form-group"> | |
| <!-- BIND THIS VALUE TO formData.text IN ANGULAR --> |