From a7ce9c09abc01a3039a74495f6e740dbe3f0c452 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 7 Mar 2018 16:25:55 +0000 Subject: [PATCH] use js to submit --- camp/static/js/app.js | 16 ++++++++++++++++ content/templates/base.html | 2 ++ content/templates/contact.html | 16 +++++++++++++--- content/views.py | 3 +++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/camp/static/js/app.js b/camp/static/js/app.js index 5b80fd1..670111a 100644 --- a/camp/static/js/app.js +++ b/camp/static/js/app.js @@ -1 +1,17 @@ $(document).foundation() + +function getCookie(name) { + var cookieValue = null; + if (document.cookie && document.cookie !== '') { + var cookies = document.cookie.split(';'); + for (var i = 0; i < cookies.length; i++) { + var cookie = jQuery.trim(cookies[i]); + // Does this cookie string begin with the name we want? + if (cookie.substring(0, name.length + 1) === (name + '=')) { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); + break; + } + } + } + return cookieValue; +} diff --git a/content/templates/base.html b/content/templates/base.html index d33830b..5407a0b 100644 --- a/content/templates/base.html +++ b/content/templates/base.html @@ -85,6 +85,8 @@ }); }); + {% block end %} + {% endblock %} diff --git a/content/templates/contact.html b/content/templates/contact.html index a431104..58727c5 100644 --- a/content/templates/contact.html +++ b/content/templates/contact.html @@ -6,13 +6,23 @@ {% if sent %}

Thanks for getting in touch!

{% else %} -
- {% csrf_token %} + + {{form}}
- +
{% endif %} {% endblock %} +{% block end %} + +{% endblock %} diff --git a/content/views.py b/content/views.py index 86e3105..f8a114d 100644 --- a/content/views.py +++ b/content/views.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals from datetime import datetime +import re from django.conf import settings from django.core.exceptions import ObjectDoesNotExist @@ -246,7 +247,9 @@ def redirect_event(request): content = get_object_or_404(Content, shortname=shortname) return redirect(content.get_absolute_url()) id = request.GET.get('id') + id = re.compile('\d+').findall(id) if id: + id = id[0] content = get_object_or_404(Content, id=id) return redirect(content.get_absolute_url())