Skip to content

Commit

Permalink
Small fixes and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
mbi committed Sep 11, 2022
1 parent de053d7 commit e3073a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Version 0.5.18 (unreleased)
* Fix some typos in documentation (#210, thanks @stweil)
* Test against Django 4.1a
* Stopped testing Django < 3.2
* BaseCaptchaTextInput should set autocomplete=off on the hashkey HiddenInput (#201, thanks @eerotal)


Version 0.5.17
Expand Down
6 changes: 4 additions & 2 deletions captcha/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@
else: # NOQA
from django.urls import reverse, NoReverseMatch # NOQA


class CaptchaHiddenInput(HiddenInput):
"""Hidden input for the captcha key."""

# Use *args and **kwargs because signature changed in Django 1.11
def build_attrs(self, *args, **kwargs):
"""Disable autocomplete to prevent problems on page reload."""

attrs = super(CaptchaHiddenInput, self).build_attrs(*args, **kwargs)
attrs = super().build_attrs(*args, **kwargs)
attrs["autocomplete"] = "off"
return attrs


class CaptchaAnswerInput(TextInput):
"""Text input for captcha answer."""

# Use *args and **kwargs because signature changed in Django 1.11
def build_attrs(self, *args, **kwargs):
"""Disable automatic corrections and completions."""
attrs = super(CaptchaAnswerInput, self).build_attrs(*args, **kwargs)
attrs = super().build_attrs(*args, **kwargs)
attrs["autocapitalize"] = "off"
attrs["autocomplete"] = "off"
attrs["autocorrect"] = "off"
Expand Down
10 changes: 3 additions & 7 deletions captcha/tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
# -*- coding: utf-8 -*-
import datetime
import json
import os
import re
import unittest
import warnings
import re

import django
from captcha.conf import settings
from captcha.fields import CaptchaField, CaptchaTextInput
from captcha.models import CaptchaStore
from django.core import management
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase, override_settings
from django.utils import timezone
from PIL import Image
from testfixtures import LogCapture

from captcha.conf import settings
from captcha.fields import CaptchaField, CaptchaTextInput
from captcha.models import CaptchaStore

if django.VERSION < (1, 10): # NOQA
from django.core.urlresolvers import reverse # NOQA
else: # NOQA
Expand Down

0 comments on commit e3073a9

Please sign in to comment.