diff --git a/src/fobi/reusable/invisible_recaptcha/__init__.py b/src/fobi/reusable/invisible_recaptcha/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/fobi/reusable/invisible_recaptcha/fields.py b/src/fobi/reusable/invisible_recaptcha/fields.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/fobi/reusable/invisible_recaptcha/valitators.py b/src/fobi/reusable/invisible_recaptcha/valitators.py deleted file mode 100644 index 92825cf0..00000000 --- a/src/fobi/reusable/invisible_recaptcha/valitators.py +++ /dev/null @@ -1,51 +0,0 @@ -import logging - -from django.conf import settings - -import requests - -__title__ = 'fobi.reusable.invisible_recaptcha.validators' -__author__ = 'Artur Barseghyan ' -__copyright__ = '2013-2018 Artur Barseghyan' -__license__ = 'GPL 2.0/LGPL 2.1' -__all__ = ('validate_invisible_recaptcha',) - - -LOGGER = logging.getLogger(__name__) - - -def validate_invisible_recaptcha(data): - RECAPTCHA_FIELD = 'g-recaptcha-response' - SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify' - site_secret = getattr(settings, 'FOBI_INVISIBLE_RECAPTCHA_SITE_SECRET', '') - recaptcha_response = data.get(RECAPTCHA_FIELD) - if not (site_secret and recaptcha_response): - return False, 'Captcha validation error' - - response = requests.post( - SITE_VERIFY_URL, - data={ - 'secret': site_secret, - 'response': recaptcha_response, - } - ) - - if response.status_code != requests.codes.ok: - LOGGER.error( - 'recaptcha: Error: %s: %s', - response.status_code, - response.reason - ) - return False, 'Captcha validation error' - else: - response = response.json() - - error_codes = response.get('error-codes') - if error_codes: - LOGGER.error('recaptcha verification error: %s', error_codes) - - result = response.get('success') - if result: - return True, '' - - return False, 'Incorrect captcha, please try again' diff --git a/src/fobi/reusable/invisible_recaptcha/widgets.py b/src/fobi/reusable/invisible_recaptcha/widgets.py deleted file mode 100644 index 97e908d4..00000000 --- a/src/fobi/reusable/invisible_recaptcha/widgets.py +++ /dev/null @@ -1,41 +0,0 @@ -from django.forms.widgets import CheckboxInput -from django.utils.safestring import mark_safe - -__title__ = 'fobi.reusable.invisible_recaptcha.widgets' -__author__ = 'Artur Barseghyan ' -__copyright__ = '2014-2018 Artur Barseghyan' -__license__ = 'GPL 2.0/LGPL 2.1' -__all__ = ('InvisibleRecaptchaWidget',) - - -class InvisibleRecaptchaWidget(CheckboxInput): - """Invisible recaptcha widget.""" - - class Media(object): - """Media.""" - css = { - 'all': ('pretty.css',) - } - js = ('animations.js', 'actions.js') - - def __init__(self, *args, **kwargs): - attrs = kwargs.get('attrs', {}) - attrs.update({'data-customforms': 'disabled'}) - kwargs.update({'attrs': attrs}) - super(InvisibleRecaptchaWidget, self).__init__(*args, **kwargs) - - def render(self, *args, **kwargs): - """ - Returns this Widget rendered as HTML, as a Unicode string. - """ - html = super(InvisibleRecaptchaWidget, self).render(*args, **kwargs) - invisible_recaptcha_html = """ - - - """ - return html + mark_safe(invisible_recaptcha_html)