def form_valid(self, form): name = form.cleaned_data['name'] attending = form.cleaned_data['attending'] == 1 song_requests = form.cleaned_data['song_requests'] dietary_reqs = form.cleaned_data['dietary_reqs'] message = form.cleaned_data['message'] postcode = form.cleaned_data['postcode'] lat = form.cleaned_data['lat'] lng = form.cleaned_data['lng'] self.success_url = reverse('rsvp-attending') if attending else reverse('rsvp-declined') model = RSVPModel(name=name, attending=attending, song_requests=song_requests, dietary_reqs=dietary_reqs, message=message, postcode=postcode, lat=lat, lng=lng) model.put() mail.send_mail(sender="*****@*****.**", to="*****@*****.**", subject="Wedding Registration - %s is %sattending" % (name, "not " if not attending else ""), body=message) return super(RSVPView, self).form_valid(form)
def get_rsvp_pins(request): lat_lngs = [{"lat": m.lat, "lng" : m.lng} for m in RSVPModel.all() if m.lat and m.lng] return HttpResponse(json.dumps(lat_lngs), content_type='application/json')