Skip to content

Commit

Permalink
:( #41, #40 ALMOST THERE! I know why amo recaptcha doesn't have the p…
Browse files Browse the repository at this point in the history
…roblem, because it uses a RecaptchaOptions! have a bug in include_tag, almost there though!!!
  • Loading branch information
haoqili committed Jul 11, 2011
1 parent ffc7e6e commit 843cc5f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
10 changes: 10 additions & 0 deletions apps/msw/helpers.py
Expand Up @@ -57,3 +57,13 @@ def media(context, url, key='MEDIA_URL'):
def static(context, url):
"""Get a STATIC_URL link with a cache buster querystring."""
return media(context, url, 'STATIC_URL')


@register.inclusion_tag('msw/demos/auth/login.html')
@jinja2.contextfunction
def recaptcha(context, form):
print "hiiiiiiiiiiii"
d = dict(context.items())
d.update(form=form)
print "rettttttttttttt"
return d
18 changes: 17 additions & 1 deletion apps/msw/templates/msw/demos/auth/login.html
@@ -1,13 +1,22 @@
{% extends "msw/base.html" %}
{#{% load url from future %}#}

{% block head_stuff %}
{{ js('moz_recaptcha') }} {#TODO: delete one #}
{% if request.user.is_anonymous() %}
{# TODO: change to js('') format #}
<script type="text/javascript" src="{{ settings.RECAPTCHA_URL }}"></script>
{% endif %}
{% endblock %}

{% block rightPanelText %}
{#
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
#}
<h1>Log in</h1>
{#
{% if error %}
<p><strong>Invalid credentials</strong></p>
{% endif %}
Expand All @@ -25,13 +34,20 @@ <h1>Log in</h1>
<p><input type="submit" value="Let's do this"></p>
</form>

#}
{% endblock %}

{% block body_end %}
test moz:
{% if form %}
{{ csrf() }}
{{ recaptcha(form) }}
{% endif %}
<hr />
testing:
{{ js('google_recState') }}
{{ js('google_recaptcha') }}
<hr />
{# {{ js('csp_alert') }} #}
{% include("msw/recaptcha_js.html") %}
{{ js('moz_recaptcha') }}
{% endblock %}
18 changes: 18 additions & 0 deletions media/js/msw/moz_recaptcha.js
@@ -0,0 +1,18 @@
// Recaptcha
var RecaptchaOptions = { theme : 'custom' };

$('#recaptcha_different').click(function(e) {
e.preventDefault();
Recaptcha.reload();
});

$('#recaptcha_audio').click(function(e) {
e.preventDefault();
Recaptcha.switch_type('audio');
});

$('#recaptcha_help').click(function(e) {
e.preventDefault();
Recaptcha.showhelp();
});

3 changes: 3 additions & 0 deletions settings.py
Expand Up @@ -231,6 +231,9 @@ def JINJA_CONFIG():
'google_recaptcha': (
'js/google/recaptcha.js',
),
'moz_recaptcha': (
'js/msw/moz_recaptcha.js',
)
}
}

Expand Down

0 comments on commit 843cc5f

Please sign in to comment.