Browse Source

- Captcha app is correctly loaded
- reCaptcha works with new Forms
- Showstopper on register page fixed
- Delete Forum page was updated

Ralfp 12 years ago
parent
commit
510a02206c

+ 11 - 3
misago/captcha/fixtures.py

@@ -33,27 +33,35 @@ settings_fixtures = (
                 'description':  _("Enter private API key that you have received from reCaptcha."),
                 'description':  _("Enter private API key that you have received from reCaptcha."),
                 'position':     2,
                 'position':     2,
             }),
             }),
+            ('recaptcha_ssl', {
+                'value':        False,
+                'type':         "boolean",
+                'input':        "yesno",
+                'name':         _("Use SSL in reCaptcha"),
+                'description':  _("Do you want forum to use SSL when making requests to reCaptha servers?"),
+                'position':     3,
+            }),
             ('qa_test', {
             ('qa_test', {
                 'type':         "string",
                 'type':         "string",
                 'input':        "text",
                 'input':        "text",
                 'separator':    _("Question and Answer Test"),
                 'separator':    _("Question and Answer Test"),
                 'name':         _("Question"),
                 'name':         _("Question"),
                 'description':  _("Question visible to your users."),
                 'description':  _("Question visible to your users."),
-                'position':     3,
+                'position':     4,
             }),
             }),
             ('qa_test_help', {
             ('qa_test_help', {
                 'type':         "string",
                 'type':         "string",
                 'input':        "text",
                 'input':        "text",
                 'name':         _("Help Message"),
                 'name':         _("Help Message"),
                 'description':  _("Optional help message displayed on form."),
                 'description':  _("Optional help message displayed on form."),
-                'position':     4,
+                'position':     5,
             }),
             }),
             ('qa_test_answers', {
             ('qa_test_answers', {
                 'type':         "string",
                 'type':         "string",
                 'input':        "textarea",
                 'input':        "textarea",
                 'name':         _("Answers"),
                 'name':         _("Answers"),
                 'description':  _("Enter allowed answers to this question, each in new line. Test is case-insensitive."),
                 'description':  _("Enter allowed answers to this question, each in new line. Test is case-insensitive."),
-                'position':     5,
+                'position':     6,
             }),
             }),
         ),
         ),
     }),
     }),

+ 6 - 4
misago/forms/layouts.py

@@ -97,11 +97,13 @@ class FormFields(object):
                 
                 
             # ReCaptcha      
             # ReCaptcha      
             if widget_name == 'ReCaptchaWidget':
             if widget_name == 'ReCaptchaWidget':
+                from recaptcha.client.captcha import displayhtml
                 blueprint['widget'] = 'recaptcha'
                 blueprint['widget'] = 'recaptcha'
-                blueprint['attrs'] = get_captcha_dict(
-                                                      form.request.settings,
-                                                      bound_field.field.api_error
-                                                      )
+                blueprint['attrs'] = {'html': displayhtml(
+                                                          form.request.settings['recaptcha_public'],
+                                                          form.request.settings['recaptcha_ssl'],
+                                                          bound_field.field.api_error,
+                                                          )}
                 
                 
             # HiddenInput
             # HiddenInput
             if widget_name == 'HiddenInput':
             if widget_name == 'HiddenInput':

+ 1 - 0
misago/forums/views.py

@@ -253,6 +253,7 @@ class Delete(FormWidget):
     id = 'delete'
     id = 'delete'
     name = _("Delete Forum")
     name = _("Delete Forum")
     fallback = 'admin_forums'
     fallback = 'admin_forums'
+    template = 'delete'
     form = DeleteForm
     form = DeleteForm
     target_name = 'name'
     target_name = 'name'
     notfound_message = _('Requested Forum could not be found.')
     notfound_message = _('Requested Forum could not be found.')

+ 2 - 1
misago/register/views.py

@@ -5,6 +5,7 @@ from django.utils import timezone
 from django.utils.translation import ugettext as _
 from django.utils.translation import ugettext as _
 from misago.banning.decorators import block_banned
 from misago.banning.decorators import block_banned
 from misago.bruteforce.decorators import block_jammed
 from misago.bruteforce.decorators import block_jammed
+from misago.bruteforce.models import SignInAttempt
 from misago.forms.layouts import FormLayout
 from misago.forms.layouts import FormLayout
 from misago.messages import Message
 from misago.messages import Message
 from misago.authn.decorators import block_authenticated
 from misago.authn.decorators import block_authenticated
@@ -68,7 +69,7 @@ def form(request):
             if request.settings['registrations_jams']:
             if request.settings['registrations_jams']:
                 SignInAttempt.objects.register_attempt(request.session.get_ip(request))
                 SignInAttempt.objects.register_attempt(request.session.get_ip(request))
             # Have we jammed our account?
             # Have we jammed our account?
-            if SignInAttempt.objects.is_jammed(request.session.get_ip(request)):
+            if SignInAttempt.objects.is_jammed(request.settings, request.session.get_ip(request)):
                 request.jam.expires = timezone.now()
                 request.jam.expires = timezone.now()
                 return redirect(reverse('register'))
                 return redirect(reverse('register'))
     else:
     else:

+ 1 - 0
misago/settings_base.py

@@ -106,6 +106,7 @@ INSTALLED_APPS = (
     'misago.banning', # Banning and blacklisting users
     'misago.banning', # Banning and blacklisting users
     'misago.crawlers', # Web crawlers handling
     'misago.crawlers', # Web crawlers handling
     'misago.cookie_jar', # Cookies helper
     'misago.cookie_jar', # Cookies helper
+    'misago.captcha', # Web crawlers handling
     'misago.forums', # Forums, threads and posts
     'misago.forums', # Forums, threads and posts
     'misago.messages', # Messages and Flashes
     'misago.messages', # Messages and Flashes
     'misago.newsletters', # Send newsletters to members from Admin
     'misago.newsletters', # Send newsletters to members from Admin

+ 2 - 1
static/admin/css/admin.css

@@ -840,7 +840,8 @@ form fieldset{border-top:1px solid #e8e8e8;margin:0px;padding:0px;padding-top:16
 form fieldset .control-group{padding-bottom:4px;}
 form fieldset .control-group{padding-bottom:4px;}
 form fieldset .control-group:last-child{padding-bottom:0px;}
 form fieldset .control-group:last-child{padding-bottom:0px;}
 form fieldset:first-child{border-top:none;padding-top:0px;}
 form fieldset:first-child{border-top:none;padding-top:0px;}
-form fieldset:last-child{padding-bottom:0px;}
+form fieldset:last-child{padding-bottom:0px;margin-bottom:0px;}
+form .form-actions{margin-top:-4px;}
 textarea{resize:vertical;}
 textarea{resize:vertical;}
 .radio-group,.select-multiple,.yes-no-switch{margin-bottom:8px;}.radio-group label,.select-multiple label,.yes-no-switch label{color:#000000;font-weight:normal;}
 .radio-group,.select-multiple,.yes-no-switch{margin-bottom:8px;}.radio-group label,.select-multiple label,.yes-no-switch label{color:#000000;font-weight:normal;}
 .checkbox{color:#000000;font-weight:normal;}
 .checkbox{color:#000000;font-weight:normal;}

+ 5 - 0
static/admin/css/admin/forms.less

@@ -37,6 +37,11 @@ form {
   
   
   fieldset:last-child {
   fieldset:last-child {
     padding-bottom: 0px;
     padding-bottom: 0px;
+    margin-bottom: 0px;
+  }
+  
+  .form-actions {
+    margin-top: -4px;
   }
   }
 }
 }
 
 

+ 1 - 1
static/sora/css/sora.css

@@ -833,7 +833,7 @@ form fieldset{border-top:1px solid #e8e8e8;margin:0px;padding:0px;padding-top:16
 form fieldset .control-group{padding-bottom:4px;}
 form fieldset .control-group{padding-bottom:4px;}
 form fieldset .control-group:last-child{padding-bottom:0px;}
 form fieldset .control-group:last-child{padding-bottom:0px;}
 form fieldset:first-child{border-top:none;padding-top:0px;}
 form fieldset:first-child{border-top:none;padding-top:0px;}
-form fieldset:last-child{padding-bottom:0px;}
+form fieldset:last-child{padding-bottom:0px;margin-bottom:0px;}
 textarea{resize:vertical;}
 textarea{resize:vertical;}
 .radio-group,.select-multiple,.yes-no-switch{margin-bottom:8px;}.radio-group label,.select-multiple label,.yes-no-switch label{color:#000000;font-weight:normal;}
 .radio-group,.select-multiple,.yes-no-switch{margin-bottom:8px;}.radio-group label,.select-multiple label,.yes-no-switch label{color:#000000;font-weight:normal;}
 .checkbox{color:#000000;font-weight:normal;}
 .checkbox{color:#000000;font-weight:normal;}

+ 1 - 0
static/sora/css/sora/forms.less

@@ -37,6 +37,7 @@ form {
   
   
   fieldset:last-child {
   fieldset:last-child {
     padding-bottom: 0px;
     padding-bottom: 0px;
+    margin-bottom: 0px;
   }
   }
 }
 }
 
 

+ 1 - 1
templates/_forms.html

@@ -128,7 +128,7 @@
 
 
 {# Recaptcha input #}
 {# Recaptcha input #}
 {%- macro input_recaptcha(field, attrs={}, classes=[], horizontal=false, width=12, nested=false) -%}
 {%- macro input_recaptcha(field, attrs={}, classes=[], horizontal=false, width=12, nested=false) -%}
-RECAPTCHA!
+{{ field.attrs.html|safe }}
 {%- endmacro -%}
 {%- endmacro -%}
 
 
 
 

+ 4 - 0
templates/admin/admin/form.html

@@ -24,7 +24,10 @@
   {{ form_theme.form_widget(form) }}
   {{ form_theme.form_widget(form) }}
   {% endif %}
   {% endif %}
   <div class="form-actions">
   <div class="form-actions">
+  	{% block form_actions %}
+  	{% block form_submit %}
   	<button name="save" type="submit" class="btn btn-primary">{{ action.submit_button }}</button>
   	<button name="save" type="submit" class="btn btn-primary">{{ action.submit_button }}</button>
+  	{% endblock %}
   	{% if action.get_edit_url -%}
   	{% if action.get_edit_url -%}
   	<button name="save_edit" type="submit" class="btn btn-warning">{% trans %}Save and Edit{% endtrans %}</button>
   	<button name="save_edit" type="submit" class="btn btn-warning">{% trans %}Save and Edit{% endtrans %}</button>
   	{%- endif %}
   	{%- endif %}
@@ -32,6 +35,7 @@
   	<button name="save_new" type="submit" class="btn btn-success">{% trans %}Save and Add Another{% endtrans %}</button>
   	<button name="save_new" type="submit" class="btn btn-success">{% trans %}Save and Add Another{% endtrans %}</button>
   	{%- endif %}
   	{%- endif %}
   	{% if fallback %}<a href="{{ fallback }}" class="btn">{% trans %}Cancel{% endtrans %}</a>{% endif %}
   	{% if fallback %}<a href="{{ fallback }}" class="btn">{% trans %}Cancel{% endtrans %}</a>{% endif %}
+  	{% endblock %}
   </div>
   </div>
 </form>
 </form>
 {% endblock %}
 {% endblock %}

+ 6 - 0
templates/admin/forums/delete.html

@@ -0,0 +1,6 @@
+{% extends "admin/admin/form.html" %}
+{% load i18n %}
+
+{% block form_submit %}
+<button name="save" type="submit" class="btn btn-danger">{% trans %}Delete Forum{% endtrans %}</button>
+{% endblock %}