use js to submit
This commit is contained in:
parent
e65bd99f31
commit
a7ce9c09ab
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -85,6 +85,8 @@
|
|||
});
|
||||
});
|
||||
</script>
|
||||
{% block end %}
|
||||
{% endblock %}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -6,13 +6,23 @@
|
|||
{% if sent %}
|
||||
<p>Thanks for getting in touch!</p>
|
||||
{% else %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<form id="contact" method="post">
|
||||
<input id="csrf" type='hidden' name='csrfmiddlewaretoken' value='' />
|
||||
{{form}}
|
||||
<br>
|
||||
<input type="submit" value="Send Message">
|
||||
<input id="captcha" type="button" value="Send Message">
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block end %}
|
||||
<script>
|
||||
$('#captcha').on({
|
||||
click: function() {
|
||||
$('#csrf').val(getCookie('csrftoken'))
|
||||
$('#contact').submit()
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user