diff --git a/Dockerfile b/Dockerfile index 7a90a647..0eb8619d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM python:3.9 ENV PYTHONUNBUFFERED 1 ENV PYTHONPATH /code:$PYTHONPATH +RUN apt-get update && apt-get -y install flite=2.2-5 RUN mkdir /code WORKDIR /code COPY dev_requirements.txt /code diff --git a/community/templates/account/custom_captcha.html b/community/templates/account/custom_captcha.html new file mode 100644 index 00000000..5411a950 --- /dev/null +++ b/community/templates/account/custom_captcha.html @@ -0,0 +1,23 @@ +{% load i18n %} +{% spaceless %} +
+ +
+
+
+ captcha + {% if audio %} +
+ {% include "django/forms/widgets/multiwidget.html" %} +
+
+
+{% endspaceless %} \ No newline at end of file diff --git a/pyarweb/forms.py b/pyarweb/forms.py index 4361c9f1..6491b392 100644 --- a/pyarweb/forms.py +++ b/pyarweb/forms.py @@ -1,6 +1,16 @@ from allauth.account.forms import SignupForm -from captcha.fields import CaptchaField +from captcha.fields import CaptchaField, CaptchaTextInput -class SingupFormWithCaptcha(SignupForm): - captcha = CaptchaField() +class CustomCaptchaTextInput(CaptchaTextInput): + # HACK - No entiendo por qué esto apunta a community/templates y no al /templates en el root + template_name = "account/custom_captcha.html" + + def image_url(self): + # Agrego el "@2" para enviar un captcha con más resolucioón + # https://django-simple-captcha.readthedocs.io/en/latest/advanced.html#captcha-2x-image + return super().image_url().removesuffix("/") + "@2" + + +class SignupFormWithCaptcha(SignupForm): + captcha = CaptchaField(widget=CustomCaptchaTextInput) diff --git a/pyarweb/settings/base.py b/pyarweb/settings/base.py index 88998cdd..fd2a350f 100644 --- a/pyarweb/settings/base.py +++ b/pyarweb/settings/base.py @@ -191,7 +191,6 @@ # CAPTCHA_LENGTH = 6 CAPTCHA_FLITE_PATH = "/usr/bin/flite" -CAPTCHA_IMAGE_TEMPLATE = "account/custom_captcha.html" ALLOWED_HTML_TAGS_INPUT = [ 'a', @@ -245,7 +244,7 @@ GOOGLE_TRACKING_ID = os.environ.get('GOOGLE_TRACKING_ID', '') -ACCOUNT_FORMS = {'signup': 'pyarweb.forms.SingupFormWithCaptcha'} +ACCOUNT_FORMS = {'signup': 'pyarweb.forms.SignupFormWithCaptcha'} DJANGO_EASY_AUDIT_WATCH_AUTH_EVENTS = False DJANGO_EASY_AUDIT_WATCH_REQUEST_EVENTS = False @@ -290,3 +289,5 @@ 'joboffers.publishers.telegram.TelegramPublisher', 'joboffers.publishers.twitter.TwitterPublisher' ] + +DEFAULT_AUTO_FIELD = "django.db.models.AutoField" diff --git a/requirements.txt b/requirements.txt index 6c5c9fc1..5d9231f0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ django-extensions==3.1.5 django-html-sanitizer==0.1.5 django-model-utils==4.2.0 django-sendfile==0.3.11 -django-simple-captcha==0.5.14 +django-simple-captcha==0.5.18 django-storages[azure]==1.11.1 django-summernote==0.8.20.0 django-tagging==0.5.0 diff --git a/templates/account/custom_captcha.html b/templates/account/custom_captcha.html deleted file mode 100644 index 60311caf..00000000 --- a/templates/account/custom_captcha.html +++ /dev/null @@ -1,14 +0,0 @@ -{% load i18n %} -{% spaceless %} - {% if audio %} - - {% endif %} - captcha image -{% endspaceless %} \ No newline at end of file