George Notaras avatar George Notaras committed d943a6f

Fixed the project-wide settings overrides

Comments (0)

Files changed (2)

src/recaptchaworks/fields.py

 
 
 class RecaptchaField(forms.Field):
-    widget = RecaptchaWidget
+    
     default_error_messages = {
         'required': u'Please enter the CAPTCHA solution.',
         'invalid': u'An incorrect CAPTCHA solution was entered.',
             '%(code)s.',
     }
 
-    def __init__(self, private_key=None, use_ssl=False, *args, **kwargs):
-        """
+    def __init__(self, private_key=None, public_key=None, use_ssl=False,
+                recaptcha_options=None, *args, **kwargs):
+        """Field constructor
+        
+        The optional ``public_key`` argument can be used to override the
+        default use of the project-wide ``RECAPTCHA_PUBLIC_KEY`` setting.
+        
         The optional ``private_key`` argument can be used to override the
         default use of the project-wide ``RECAPTCHA_PRIVATE_KEY`` setting.
+        
+        The optional ``use_ssl`` argument can be used to override the default
+        use of the project-wide ``RECAPTCHA_USE_SSL`` setting.
+        
+        The optional ``recaptcha_options`` argument can be used to override
+        the default project wide ``RECAPTCHA_OPTIONS`` setting.
+        
         """
         self.private_key = private_key or settings.RECAPTCHA_PRIVATE_KEY
         self.use_ssl = use_ssl or settings.RECAPTCHA_USE_SSL
+        kwargs['widget'] = RecaptchaWidget(public_key, use_ssl, recaptcha_options)
         super(RecaptchaField, self).__init__(*args, **kwargs)
 
     def clean(self, value):

src/recaptchaworks/widgets.py

 </script>
 '''
     
-    def __init__(self, recaptcha_options=None, public_key=None, use_ssl=False):
+    def __init__(self, public_key=None, use_ssl=False, recaptcha_options=None):
         '''RecaptchaWidget constructor
         
         For customization information visit:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.