[Python-modules-commits] [django-simple-captcha] 02/10: Import django-simple-captcha_0.4.8.orig.tar.gz

Brian May bam at moszumanska.debian.org
Wed Dec 2 21:48:59 UTC 2015


This is an automated email from the git hooks/post-receive script.

bam pushed a commit to branch master
in repository django-simple-captcha.

commit d6b01a0fe8a347c2f693626bd7bed0d5dffb4951
Author: Brian May <bam at debian.org>
Date:   Thu Dec 3 07:56:08 2015 +1100

    Import django-simple-captcha_0.4.8.orig.tar.gz
---
 .gitignore                                         |  10 -
 .pep8                                              |   3 -
 .travis.yml                                        |  22 ---
 CHANGES                                            |  11 ++
 MANIFEST.in                                        |   2 +-
 PKG-INFO                                           |  22 +++
 README.rst                                         |  14 +-
 captcha/__init__.py                                |   2 +-
 captcha/conf/settings.py                           |  12 +-
 captcha/fields.py                                  |  57 ++++--
 captcha/locale/en/LC_MESSAGES/django.po            |  30 +++
 captcha/templates/captcha/field.html               |   1 +
 captcha/templates/captcha/hidden_field.html        |   1 +
 captcha/templates/captcha/image.html               |   4 +
 captcha/templates/captcha/text_field.html          |   1 +
 captcha/tests/tests.py                             |  54 +++---
 captcha/tests/urls.py                              |  25 ++-
 captcha/tests/views.py                             |  11 +-
 captcha/urls.py                                    |   6 +-
 django_simple_captcha.egg-info/PKG-INFO            |  22 +++
 django_simple_captcha.egg-info/SOURCES.txt         |  75 ++++++++
 .../dependency_links.txt                           |   1 +
 django_simple_captcha.egg-info/not-zip-safe        |   1 +
 django_simple_captcha.egg-info/requires.txt        |   3 +
 django_simple_captcha.egg-info/top_level.txt       |   2 +
 docs/Makefile                                      |  89 ---------
 docs/_static/captcha3.png                          | Bin 9633 -> 0 bytes
 docs/_static/dict.png                              | Bin 7859 -> 0 bytes
 docs/_static/math.png                              | Bin 7491 -> 0 bytes
 docs/_static/random_chars.png                      | Bin 8136 -> 0 bytes
 docs/advanced.rst                                  | 202 ---------------------
 docs/conf.py                                       | 198 --------------------
 docs/index.rst                                     |  41 -----
 docs/usage.rst                                     | 143 ---------------
 setup.cfg                                          |   6 +
 setup.py                                           |   4 +-
 testproject/.coveragerc                            |  10 -
 testproject/coverage.sh                            |   5 -
 testproject/settings.py                            |  29 ++-
 testproject/settings_17.py                         |  61 -------
 testproject/templates/home.html                    |  12 --
 tox.ini                                            |  66 -------
 42 files changed, 309 insertions(+), 949 deletions(-)

diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 4be0a97..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,10 +0,0 @@
-dist
-*.pyc
-*.egg-info
-docs/_build/
-.venv*
-testproject/django-simple-captcha.db
-testproject/.coverage
-testproject/coverage.xml
-testproject/htmlcov/
-.tox
diff --git a/.pep8 b/.pep8
deleted file mode 100644
index 4ad0546..0000000
--- a/.pep8
+++ /dev/null
@@ -1,3 +0,0 @@
-[flake8]
-ignore = E501
-exclude = south_migrations,migrations,.venv_*,docs
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index d891a4c..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-language: python
-services: memcached
-python: 2.7
-env:
-  - TOX_ENV=py26-django14
-  - TOX_ENV=py27-django14
-  - TOX_ENV=py26-django15
-  - TOX_ENV=py27-django15
-  - TOX_ENV=py34-django15
-  - TOX_ENV=py26-django16
-  - TOX_ENV=py27-django16
-  - TOX_ENV=py34-django16
-  - TOX_ENV=py27-django17
-  - TOX_ENV=py34-django17
-  - TOX_ENV=py27-django18
-  - TOX_ENV=py34-django18
-  - TOX_ENV=flake8
-  - TOX_ENV=gettext
-install:
-  - pip install tox
-script:
-  - tox -e $TOX_ENV
diff --git a/CHANGES b/CHANGES
index 7ecac93..3b90439 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,14 @@
+Version 0.4.8
+-------------
+* Adds templates folder missing in 0.4.7
+
+Version 0.4.7
+-------------
+* Supported Django versions are now 1.7, 1.8 and 1.9
+* Trying to fix the TravisCI build errors
+* Use Django templates to render the individual fields, as well as the assembled Captcha Field (Issue #31)
+
+
 Version 0.4.6
 -------------
 * Fixes an UnicodeDecodeError which was apparently only triggered during testing on TravisCI (I hope)
diff --git a/MANIFEST.in b/MANIFEST.in
index a971f94..491c9cc 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -4,4 +4,4 @@ include README.rst
 include CHANGES
 recursive-include captcha/fonts *
 recursive-include captcha/locale *
-prune testproject
+recursive-include captcha/templates *
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..e8664d4
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,22 @@
+Metadata-Version: 1.1
+Name: django-simple-captcha
+Version: 0.4.8
+Summary: A very simple, yet powerful, Django captcha application
+Home-page: https://github.com/mbi/django-simple-captcha
+Author: Marco Bonetti
+Author-email: mbonetti at gmail.com
+License: MIT
+Description: UNKNOWN
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Environment :: Web Environment
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Topic :: Security
+Classifier: Topic :: Internet :: WWW/HTTP
+Classifier: Framework :: Django
diff --git a/README.rst b/README.rst
index ec37e01..3691552 100644
--- a/README.rst
+++ b/README.rst
@@ -22,8 +22,8 @@ Features
 Requirements
 ++++++++++++
 
-* Django 1.4+
-* A recent version of the Python Imaging Library (PIL 1.1.7 or Pillow 2.2+) compiled with FreeType support
+* Django 1.7+
+* A recent version of the Pillow compiled with FreeType support
 * Flite is required for text-to-speech (audio) output, but not mandatory
 
 Python 3 compatibility
@@ -36,12 +36,4 @@ You will need to install `Pillow <https://github.com/python-imaging/Pillow>`_ be
 Documentation
 +++++++++++++
 
-Read the `documentation online <http://readthedocs.org/docs/django-simple-captcha>`_.
-
-Support
-+++++++
-
-.. image:: https://rawgithub.com/twolfson/gittip-badge/0.2.0/dist/gittip.png
-   :alt: Support via Gittip
-   :target: https://www.gittip.com/mbi/
-   :align: right
+Read the `documentation online <http://django-simple-captcha.readthedocs.org/en/latest/>`_.
diff --git a/captcha/__init__.py b/captcha/__init__.py
index 37a6f1b..d4e80f4 100644
--- a/captcha/__init__.py
+++ b/captcha/__init__.py
@@ -1,6 +1,6 @@
 import re
 
-VERSION = (0, 4, 6)
+VERSION = (0, 4, 8)
 
 
 def get_version(svn=False):
diff --git a/captcha/conf/settings.py b/captcha/conf/settings.py
index b102bcf..569372a 100644
--- a/captcha/conf/settings.py
+++ b/captcha/conf/settings.py
@@ -14,15 +14,15 @@ CAPTCHA_PUNCTUATION = getattr(settings, 'CAPTCHA_PUNCTUATION', '''_"',.;:-''')
 CAPTCHA_FLITE_PATH = getattr(settings, 'CAPTCHA_FLITE_PATH', None)
 CAPTCHA_TIMEOUT = getattr(settings, 'CAPTCHA_TIMEOUT', 5)  # Minutes
 CAPTCHA_LENGTH = int(getattr(settings, 'CAPTCHA_LENGTH', 4))  # Chars
-CAPTCHA_IMAGE_BEFORE_FIELD = getattr(settings, 'CAPTCHA_IMAGE_BEFORE_FIELD', True)
+# CAPTCHA_IMAGE_BEFORE_FIELD = getattr(settings, 'CAPTCHA_IMAGE_BEFORE_FIELD', True)
 CAPTCHA_DICTIONARY_MIN_LENGTH = getattr(settings, 'CAPTCHA_DICTIONARY_MIN_LENGTH', 0)
 CAPTCHA_DICTIONARY_MAX_LENGTH = getattr(settings, 'CAPTCHA_DICTIONARY_MAX_LENGTH', 99)
 CAPTCHA_IMAGE_SIZE = getattr(settings, 'CAPTCHA_IMAGE_SIZE', None)
-
-if CAPTCHA_IMAGE_BEFORE_FIELD:
-    CAPTCHA_OUTPUT_FORMAT = getattr(settings, 'CAPTCHA_OUTPUT_FORMAT', '%(image)s %(hidden_field)s %(text_field)s')
-else:
-    CAPTCHA_OUTPUT_FORMAT = getattr(settings, 'CAPTCHA_OUTPUT_FORMAT', '%(hidden_field)s %(text_field)s %(image)s')
+CAPTCHA_IMAGE_TEMPLATE = getattr(settings, 'CAPTCHA_IMAGE_TEMPLATE', 'captcha/image.html')
+CAPTCHA_HIDDEN_FIELD_TEMPLATE = getattr(settings, 'CAPTCHA_HIDDEN_FIELD_TEMPLATE', 'captcha/hidden_field.html')
+CAPTCHA_TEXT_FIELD_TEMPLATE = getattr(settings, 'CAPTCHA_TEXT_FIELD_TEMPLATE', 'captcha/text_field.html')
+CAPTCHA_FIELD_TEMPLATE = getattr(settings, 'CAPTCHA_FIELD_TEMPLATE', 'captcha/field.html')
+CAPTCHA_OUTPUT_FORMAT = getattr(settings, 'CAPTCHA_OUTPUT_FORMAT', None)
 
 CAPTCHA_TEST_MODE = getattr(settings, 'CAPTCHA_TEST_MODE', getattr(settings, 'CATPCHA_TEST_MODE', False))
 
diff --git a/captcha/fields.py b/captcha/fields.py
index 7fcc243..47f253d 100644
--- a/captcha/fields.py
+++ b/captcha/fields.py
@@ -5,7 +5,9 @@ from django.core.urlresolvers import reverse, NoReverseMatch
 from django.forms import ValidationError
 from django.forms.fields import CharField, MultiValueField
 from django.forms.widgets import TextInput, MultiWidget, HiddenInput
-from django.utils.translation import ugettext, ugettext_lazy
+from django.utils.translation import ugettext_lazy
+from django.template.loader import render_to_string
+from django.utils.safestring import mark_safe
 from six import u
 
 
@@ -61,14 +63,20 @@ class CaptchaTextInput(BaseCaptchaTextInput):
     def __init__(self, attrs=None, **kwargs):
         self._args = kwargs
         self._args['output_format'] = self._args.get('output_format') or settings.CAPTCHA_OUTPUT_FORMAT
+        self._args['field_template'] = self._args.get('field_template') or settings.CAPTCHA_FIELD_TEMPLATE
         self._args['id_prefix'] = self._args.get('id_prefix')
 
-        for key in ('image', 'hidden_field', 'text_field'):
-            if '%%(%s)s' % key not in self._args['output_format']:
-                raise ImproperlyConfigured('All of %s must be present in your CAPTCHA_OUTPUT_FORMAT setting. Could not find %s' % (
-                    ', '.join(['%%(%s)s' % k for k in ('image', 'hidden_field', 'text_field')]),
-                    '%%(%s)s' % key
-                ))
+        if self._args['output_format'] is None and self._args['field_template'] is None:
+            raise ImproperlyConfigured('You MUST define either CAPTCHA_FIELD_TEMPLATE or CAPTCHA_OUTPUT_FORMAT setting. Please refer to http://readthedocs.org/docs/django-simple-captcha/en/latest/usage.html#installation')
+
+        if self._args['output_format']:
+            for key in ('image', 'hidden_field', 'text_field'):
+                if '%%(%s)s' % key not in self._args['output_format']:
+                    raise ImproperlyConfigured('All of %s must be present in your CAPTCHA_OUTPUT_FORMAT setting. Could not find %s' % (
+                        ', '.join(['%%(%s)s' % k for k in ('image', 'hidden_field', 'text_field')]),
+                        '%%(%s)s' % key
+                    ))
+
         super(CaptchaTextInput, self).__init__(attrs)
 
     def build_attrs(self, extra_attrs=None, **kwargs):
@@ -85,19 +93,38 @@ class CaptchaTextInput(BaseCaptchaTextInput):
 
     def format_output(self, rendered_widgets):
         hidden_field, text_field = rendered_widgets
-        text_field = text_field.replace('<input', '<input autocomplete="off"')
-        return self._args['output_format'] % {
-            'image': self.image_and_audio,
-            'hidden_field': hidden_field,
-            'text_field': text_field
-        }
+
+        if self._args['output_format']:
+            return self._args['output_format'] % {
+                'image': self.image_and_audio,
+                'hidden_field': self.hidden_field,
+                'text_field': self.text_field
+            }
+
+        elif self._args['field_template']:
+            context = {
+                'image': mark_safe(self.image_and_audio),
+                'hidden_field': mark_safe(self.hidden_field),
+                'text_field': mark_safe(self.text_field)
+            }
+            return render_to_string(settings.CAPTCHA_FIELD_TEMPLATE, context)
 
     def render(self, name, value, attrs=None):
         self.fetch_captcha_store(name, value, attrs)
 
-        self.image_and_audio = '<img src="%s" alt="captcha" class="captcha" />' % self.image_url()
+        context = {
+            'image': self.image_url(),
+            'name': name,
+            'key': self._key,
+            'id': u'%s_%s' % (self._args.get('id_prefix'), attrs.get('id')) if self._args.get('id_prefix') else attrs.get('id')
+        }
         if settings.CAPTCHA_FLITE_PATH:
-            self.image_and_audio = '<a href="%s" title="%s">%s</a>' % (self.audio_url(), ugettext('Play CAPTCHA as audio file'), self.image_and_audio)
+            context.update({'audio': self.audio_url()})
+
+        self.image_and_audio = render_to_string(settings.CAPTCHA_IMAGE_TEMPLATE, context)
+        self.hidden_field = render_to_string(settings.CAPTCHA_HIDDEN_FIELD_TEMPLATE, context)
+        self.text_field = render_to_string(settings.CAPTCHA_TEXT_FIELD_TEMPLATE, context)
+
         return super(CaptchaTextInput, self).render(name, self._value, attrs=attrs)
 
 
diff --git a/captcha/locale/en/LC_MESSAGES/django.po b/captcha/locale/en/LC_MESSAGES/django.po
new file mode 100644
index 0000000..603d181
--- /dev/null
+++ b/captcha/locale/en/LC_MESSAGES/django.po
@@ -0,0 +1,30 @@
+# django-simple-captcha French translation.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Patrick Samson <maxcom at laposte.net>, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: django-simple-captcha 0.2.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-07-25 11:44+0300\n"
+"PO-Revision-Date: 2010-09-16 12:16+0200\n"
+"Last-Translator: Marco Bonetti <mbonetti at gmail.com>\n"
+"Language-Team: en <mbonetti at gmail.com>\n"
+"Language: en\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=n>1;\n"
+
+#: fields.py:49
+msgid "Play CAPTCHA as audio file"
+msgstr "Play CAPTCHA as audio file"
+
+#: fields.py:66 fields.py:89 tests/__init__.py:62
+msgid "Invalid CAPTCHA"
+msgstr ""
+
+#: tests/__init__.py:88
+msgid "This field is required."
+msgstr ""
diff --git a/captcha/templates/captcha/field.html b/captcha/templates/captcha/field.html
new file mode 100644
index 0000000..8c5d5d6
--- /dev/null
+++ b/captcha/templates/captcha/field.html
@@ -0,0 +1 @@
+{{image}}{{hidden_field}}{{text_field}}
diff --git a/captcha/templates/captcha/hidden_field.html b/captcha/templates/captcha/hidden_field.html
new file mode 100644
index 0000000..36d7490
--- /dev/null
+++ b/captcha/templates/captcha/hidden_field.html
@@ -0,0 +1 @@
+<input id="{{id}}_0" name="{{name}}_0" type="hidden" value="{{key}}" />
diff --git a/captcha/templates/captcha/image.html b/captcha/templates/captcha/image.html
new file mode 100644
index 0000000..b4a4155
--- /dev/null
+++ b/captcha/templates/captcha/image.html
@@ -0,0 +1,4 @@
+{% load i18n %}
+{% spaceless %}
+    {% if audio %}<a title="{% trans "Play CAPTCHA as audio file" %}" href="{{audio}}">{% endif %}<img src="{{image}}" alt="captcha" class="captcha" />{% if audio %}</a>{% endif %}
+{% endspaceless %}
\ No newline at end of file
diff --git a/captcha/templates/captcha/text_field.html b/captcha/templates/captcha/text_field.html
new file mode 100644
index 0000000..783e93d
--- /dev/null
+++ b/captcha/templates/captcha/text_field.html
@@ -0,0 +1 @@
+<input autocomplete="off" id="{{id}}_1" name="{{name}}_1" type="text" />
\ No newline at end of file
diff --git a/captcha/tests/tests.py b/captcha/tests/tests.py
index c240b62..d7292eb 100644
--- a/captcha/tests/tests.py
+++ b/captcha/tests/tests.py
@@ -2,10 +2,9 @@
 from captcha.conf import settings
 from captcha.fields import CaptchaField, CaptchaTextInput
 from captcha.models import CaptchaStore, get_safe_now
-from django.conf import settings as django_settings
 from django.core.exceptions import ImproperlyConfigured
 from django.core.urlresolvers import reverse
-from django.test import TestCase
+from django.test import TestCase, override_settings
 from django.utils.translation import ugettext_lazy
 import datetime
 import json
@@ -25,8 +24,8 @@ except ImportError:
     import Image  # NOQA
 
 
+ at override_settings(ROOT_URLCONF='captcha.tests.urls')
 class CaptchaCase(TestCase):
-    urls = 'captcha.tests.urls'
 
     def setUp(self):
 
@@ -58,14 +57,14 @@ class CaptchaCase(TestCase):
         response = CaptchaStore.objects.get(hashkey=hash_).response
         return hash_, response
 
-    def testImages(self):
+    def test_image(self):
         for key in [store.hashkey for store in six.itervalues(self.stores)]:
             response = self.client.get(reverse('captcha-image', kwargs=dict(key=key)))
             self.assertEqual(response.status_code, 200)
             self.assertTrue(response.has_header('content-type'))
             self.assertEqual(response._headers.get('content-type'), ('Content-Type', 'image/png'))
 
-    def testAudio(self):
+    def test_audio(self):
         if not settings.CAPTCHA_FLITE_PATH:
             return
         for key in (self.stores.get('math_store').hashkey, self.stores.get('math_store').hashkey, self.default_store.hashkey):
@@ -75,7 +74,7 @@ class CaptchaCase(TestCase):
             self.assertTrue(response.has_header('content-type'))
             self.assertEqual(response._headers.get('content-type'), ('Content-Type', 'audio/x-wav'))
 
-    def testFormSubmit(self):
+    def test_form_submit(self):
         r = self.client.get(reverse('captcha-test'))
         self.assertEqual(r.status_code, 200)
         hash_, response = self.__extract_hash_and_response(r)
@@ -88,7 +87,7 @@ class CaptchaCase(TestCase):
         self.assertEqual(r.status_code, 200)
         self.assertFalse(str(r.content).find('Form validated') > 0)
 
-    def testFormModelForm(self):
+    def test_modelform(self):
         r = self.client.get(reverse('captcha-test-model-form'))
         self.assertEqual(r.status_code, 200)
         hash_, response = self.__extract_hash_and_response(r)
@@ -101,14 +100,14 @@ class CaptchaCase(TestCase):
         self.assertEqual(r.status_code, 200)
         self.assertFalse(str(r.content).find('Form validated') > 0)
 
-    def testWrongSubmit(self):
+    def test_wrong_submit(self):
         for urlname in ('captcha-test', 'captcha-test-model-form'):
             r = self.client.get(reverse(urlname))
             self.assertEqual(r.status_code, 200)
             r = self.client.post(reverse(urlname), dict(captcha_0='abc', captcha_1='wrong response', subject='xxx', sender='asasd at asdasd.com'))
             self.assertFormError(r, 'form', 'captcha', ugettext_lazy('Invalid CAPTCHA'))
 
-    def testDeleteExpired(self):
+    def test_deleted_expired(self):
         self.default_store.expiration = get_safe_now() - datetime.timedelta(minutes=5)
         self.default_store.save()
         hash_ = self.default_store.hashkey
@@ -124,7 +123,7 @@ class CaptchaCase(TestCase):
         except:
             pass
 
-    def testCustomErrorMessage(self):
+    def test_custom_error_message(self):
         r = self.client.get(reverse('captcha-test-custom-error-message'))
         self.assertEqual(r.status_code, 200)
         # Wrong answer
@@ -134,14 +133,14 @@ class CaptchaCase(TestCase):
         r = self.client.post(reverse('captcha-test-custom-error-message'), dict(captcha_0='abc', captcha_1=''))
         self.assertFormError(r, 'form', 'captcha', ugettext_lazy('This field is required.'))
 
-    def testRepeatedChallenge(self):
+    def test_repeated_challenge(self):
         CaptchaStore.objects.create(challenge='xxx', response='xxx')
         try:
             CaptchaStore.objects.create(challenge='xxx', response='xxx')
         except Exception:
             self.fail()
 
-    def testRepeatedChallengeFormSubmit(self):
+    def test_repeated_challenge_form_submit(self):
         __current_challange_function = settings.CAPTCHA_CHALLENGE_FUNCT
         for urlname in ('captcha-test', 'captcha-test-model-form'):
             settings.CAPTCHA_CHALLENGE_FUNCT = 'captcha.tests.trivial_challenge'
@@ -183,40 +182,35 @@ class CaptchaCase(TestCase):
             self.assertTrue(str(r2.content).find('Form validated') > 0)
         settings.CAPTCHA_CHALLENGE_FUNCT = __current_challange_function
 
-    def testOutputFormat(self):
+    def test_output_format(self):
         for urlname in ('captcha-test', 'captcha-test-model-form'):
             settings.CAPTCHA_OUTPUT_FORMAT = u('%(image)s<p>Hello, captcha world</p>%(hidden_field)s%(text_field)s')
             r = self.client.get(reverse(urlname))
             self.assertEqual(r.status_code, 200)
             self.assertTrue('<p>Hello, captcha world</p>' in str(r.content))
 
-    def testInvalidOutputFormat(self):
-        __current_settings_debug = django_settings.DEBUG
+    def test_invalid_output_format(self):
         for urlname in ('captcha-test', 'captcha-test-model-form'):
-            # we turn on DEBUG because CAPTCHA_OUTPUT_FORMAT is only checked debug
-
-            django_settings.DEBUG = True
             settings.CAPTCHA_OUTPUT_FORMAT = u('%(image)s')
             try:
                 self.client.get(reverse(urlname))
                 self.fail()
             except ImproperlyConfigured as e:
                 self.assertTrue('CAPTCHA_OUTPUT_FORMAT' in str(e))
-        django_settings.DEBUG = __current_settings_debug
 
-    def testPerFormFormat(self):
+    def test_per_form_format(self):
         settings.CAPTCHA_OUTPUT_FORMAT = u('%(image)s testCustomFormatString %(hidden_field)s %(text_field)s')
         r = self.client.get(reverse('captcha-test'))
         self.assertTrue('testCustomFormatString' in str(r.content))
         r = self.client.get(reverse('test_per_form_format'))
         self.assertTrue('testPerFieldCustomFormatString' in str(r.content))
 
-    def testIssue31ProperLabel(self):
+    def test_issue31_proper_abel(self):
         settings.CAPTCHA_OUTPUT_FORMAT = u('%(image)s %(hidden_field)s %(text_field)s')
         r = self.client.get(reverse('captcha-test'))
         self.assertTrue('<label for="id_captcha_1"' in str(r.content))
 
-    def testRefreshView(self):
+    def test_refresh_view(self):
         r = self.client.get(reverse('captcha-refresh'), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
         try:
             new_data = json.loads(six.text_type(r.content, encoding='ascii'))
@@ -224,14 +218,14 @@ class CaptchaCase(TestCase):
         except:
             self.fail()
 
-    def testContentLength(self):
+    def test_content_length(self):
         for key in [store.hashkey for store in six.itervalues(self.stores)]:
             response = self.client.get(reverse('captcha-image', kwargs=dict(key=key)))
             self.assertTrue(response.has_header('content-length'))
             self.assertTrue(response['content-length'].isdigit())
             self.assertTrue(int(response['content-length']))
 
-    def testIssue12ProperInstantiation(self):
+    def test_issue12_proper_instantiation(self):
         """
         This test covers a default django field and widget behavior
         It not assert anything. If something is wrong it will raise a error!
@@ -240,7 +234,7 @@ class CaptchaCase(TestCase):
         widget = CaptchaTextInput(attrs={'class': 'required'})
         CaptchaField(widget=widget)
 
-    def testTestMode_Issue15(self):
+    def test_test_mode_issue15(self):
         __current_test_mode_setting = settings.CAPTCHA_TEST_MODE
         settings.CAPTCHA_TEST_MODE = False
         r = self.client.get(reverse('captcha-test'))
@@ -357,6 +351,16 @@ class CaptchaCase(TestCase):
 
         settings.CAPTCHA_FONT_PATH = __current_test_mode_setting
 
+    def test_template_overrides(self):
+        __current_test_mode_setting = settings.CAPTCHA_IMAGE_TEMPLATE
+        settings.CAPTCHA_IMAGE_TEMPLATE = 'captcha_test/image.html'
+
+        for urlname in ('captcha-test', 'captcha-test-model-form'):
+            settings.CAPTCHA_CHALLENGE_FUNCT = 'captcha.tests.trivial_challenge'
+            r = self.client.get(reverse(urlname))
+            self.assertTrue('captcha-template-test' in six.text_type(r.content))
+        settings.CAPTCHA_IMAGE_TEMPLATE = __current_test_mode_setting
+
 
 def trivial_challenge():
     return 'trivial', 'trivial'
diff --git a/captcha/tests/urls.py b/captcha/tests/urls.py
index 02276dc..5f8eb34 100644
--- a/captcha/tests/urls.py
+++ b/captcha/tests/urls.py
@@ -1,15 +1,14 @@
-try:
-    from django.conf.urls import url, patterns, include
-except ImportError:
-    from django.conf.urls.defaults import url, patterns, include
+from django.conf.urls import url, include
+from .views import (
+    test, test_model_form, test_custom_error_message, test_per_form_format, test_non_required, test_id_prefix
+)
 
-urlpatterns = patterns(
-    '',
-    url(r'test/$', 'captcha.tests.views.test', name='captcha-test'),
-    url(r'test-modelform/$', 'captcha.tests.views.test_model_form', name='captcha-test-model-form'),
-    url(r'test2/$', 'captcha.tests.views.test_custom_error_message', name='captcha-test-custom-error-message'),
-    url(r'test3/$', 'captcha.tests.views.test_per_form_format', name='test_per_form_format'),
-    url(r'test-non-required/$', 'captcha.tests.views.test_non_required', name='captcha-test-non-required'),
-    url(r'test-id-prefix/$', 'captcha.tests.views.test_id_prefix', name='captcha-test-id-prefix'),
+urlpatterns = [
+    url(r'test/$', test, name='captcha-test'),
+    url(r'test-modelform/$', test_model_form, name='captcha-test-model-form'),
+    url(r'test2/$', test_custom_error_message, name='captcha-test-custom-error-message'),
+    url(r'test3/$', test_per_form_format, name='test_per_form_format'),
+    url(r'test-non-required/$', test_non_required, name='captcha-test-non-required'),
+    url(r'test-id-prefix/$', test_id_prefix, name='captcha-test-id-prefix'),
     url(r'', include('captcha.urls')),
-)
+]
diff --git a/captcha/tests/views.py b/captcha/tests/views.py
index 9f4f604..230d478 100644
--- a/captcha/tests/views.py
+++ b/captcha/tests/views.py
@@ -3,6 +3,7 @@ from captcha.fields import CaptchaField
 from django.http import HttpResponse
 from django.contrib.auth.models import User
 from six import u
+import django
 
 try:
     from django.template import engines, RequestContext
@@ -13,7 +14,6 @@ except ImportError:
 
 
 TEST_TEMPLATE = r'''
-{% load url from future %}
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html>
@@ -55,8 +55,13 @@ def _test(request, form_class):
         form = form_class()
 
     t = _get_template(TEST_TEMPLATE)
-    return HttpResponse(
-        t.render(RequestContext(request, dict(passed=passed, form=form))))
+
+    if django.VERSION >= (1, 9):
+        return HttpResponse(
+            t.render(context=dict(passed=passed, form=form), request=request))
+    else:
+        return HttpResponse(
+            t.render(RequestContext(request, dict(passed=passed, form=form))))
 
 
 def test(request):
diff --git a/captcha/urls.py b/captcha/urls.py
index ab08ae6..ba09c02 100644
--- a/captcha/urls.py
+++ b/captcha/urls.py
@@ -1,8 +1,4 @@
-try:
-    from django.conf.urls import url
-except ImportError:
-    from django.conf.urls.defaults import url
-
+from django.conf.urls import url
 from captcha import views
 
 urlpatterns = [
diff --git a/django_simple_captcha.egg-info/PKG-INFO b/django_simple_captcha.egg-info/PKG-INFO
new file mode 100644
index 0000000..e8664d4
--- /dev/null
+++ b/django_simple_captcha.egg-info/PKG-INFO
@@ -0,0 +1,22 @@
+Metadata-Version: 1.1
+Name: django-simple-captcha
+Version: 0.4.8
+Summary: A very simple, yet powerful, Django captcha application
+Home-page: https://github.com/mbi/django-simple-captcha
+Author: Marco Bonetti
+Author-email: mbonetti at gmail.com
+License: MIT
+Description: UNKNOWN
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Environment :: Web Environment
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Topic :: Security
+Classifier: Topic :: Internet :: WWW/HTTP
+Classifier: Framework :: Django
diff --git a/django_simple_captcha.egg-info/SOURCES.txt b/django_simple_captcha.egg-info/SOURCES.txt
new file mode 100644
index 0000000..2abc12f
--- /dev/null
+++ b/django_simple_captcha.egg-info/SOURCES.txt
@@ -0,0 +1,75 @@
+CHANGES
+LICENSE
+MANIFEST.in
+README.rst
+setup.cfg
+setup.py
+captcha/__init__.py
+captcha/fields.py
+captcha/helpers.py
+captcha/models.py
+captcha/urls.py
+captcha/views.py
+captcha/conf/__init__.py
+captcha/conf/settings.py
+captcha/fonts/COPYRIGHT.TXT
+captcha/fonts/README.TXT
+captcha/fonts/Vera.ttf
+captcha/locale/bg/LC_MESSAGES/django.mo
+captcha/locale/bg/LC_MESSAGES/django.po
+captcha/locale/cs/LC_MESSAGES/django.mo
+captcha/locale/cs/LC_MESSAGES/django.po
+captcha/locale/de/LC_MESSAGES/django.mo
+captcha/locale/de/LC_MESSAGES/django.po
+captcha/locale/en/LC_MESSAGES/django.po
+captcha/locale/es/LC_MESSAGES/django.mo
+captcha/locale/es/LC_MESSAGES/django.po
+captcha/locale/fr/LC_MESSAGES/django.mo
+captcha/locale/fr/LC_MESSAGES/django.po
+captcha/locale/it/LC_MESSAGES/django.mo
+captcha/locale/it/LC_MESSAGES/django.po
+captcha/locale/ja/LC_MESSAGES/django.mo
+captcha/locale/ja/LC_MESSAGES/django.po
+captcha/locale/nl/LC_MESSAGES/django.mo
+captcha/locale/nl/LC_MESSAGES/django.po
+captcha/locale/pl/LC_MESSAGES/django.mo
+captcha/locale/pl/LC_MESSAGES/django.po
+captcha/locale/pt_BR/LC_MESSAGES/django.mo
+captcha/locale/pt_BR/LC_MESSAGES/django.po
+captcha/locale/ru/LC_MESSAGES/django.mo
+captcha/locale/ru/LC_MESSAGES/django.po
+captcha/locale/sk/LC_MESSAGES/django.mo
+captcha/locale/sk/LC_MESSAGES/django.po
+captcha/locale/tr/LC_MESSAGES/django.mo
+captcha/locale/tr/LC_MESSAGES/django.po
+captcha/locale/uk/LC_MESSAGES/django.mo
+captcha/locale/uk/LC_MESSAGES/django.po
+captcha/locale/zh_CN/LC_MESSAGES/django.mo
+captcha/locale/zh_CN/LC_MESSAGES/django.po
+captcha/management/__init__.py
+captcha/management/commands/__init__.py
+captcha/management/commands/captcha_clean.py
+captcha/migrations/0001_initial.py
+captcha/migrations/__init__.py
+captcha/south_migrations/0001_initial.py
+captcha/south_migrations/__init__.py
+captcha/templates/captcha/field.html
+captcha/templates/captcha/hidden_field.html
+captcha/templates/captcha/image.html
+captcha/templates/captcha/text_field.html
+captcha/tests/__init__.py
+captcha/tests/tests.py
+captcha/tests/urls.py
+captcha/tests/views.py
+django_simple_captcha.egg-info/PKG-INFO
+django_simple_captcha.egg-info/SOURCES.txt
+django_simple_captcha.egg-info/dependency_links.txt
+django_simple_captcha.egg-info/not-zip-safe
+django_simple_captcha.egg-info/requires.txt
+django_simple_captcha.egg-info/top_level.txt
+testproject/__init__.py
+testproject/forms.py
+testproject/manage.py
+testproject/settings.py
+testproject/urls.py
+testproject/views.py
\ No newline at end of file
diff --git a/django_simple_captcha.egg-info/dependency_links.txt b/django_simple_captcha.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/django_simple_captcha.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/django_simple_captcha.egg-info/not-zip-safe b/django_simple_captcha.egg-info/not-zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/django_simple_captcha.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
diff --git a/django_simple_captcha.egg-info/requires.txt b/django_simple_captcha.egg-info/requires.txt
new file mode 100644
index 0000000..b86c64b
--- /dev/null
+++ b/django_simple_captcha.egg-info/requires.txt
@@ -0,0 +1,3 @@
+setuptools
+six >=1.2.0
+Django >= 1.7
diff --git a/django_simple_captcha.egg-info/top_level.txt b/django_simple_captcha.egg-info/top_level.txt
new file mode 100644
index 0000000..d941b23
--- /dev/null
+++ b/django_simple_captcha.egg-info/top_level.txt
@@ -0,0 +1,2 @@
+captcha
+testproject
diff --git a/docs/Makefile b/docs/Makefile
deleted file mode 100644
index 338297f..0000000
--- a/docs/Makefile
+++ /dev/null
@@ -1,89 +0,0 @@
-# Makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line.
-SPHINXOPTS    =
-SPHINXBUILD   = sphinx-build
-PAPER         =
-BUILDDIR      = _build
-
-# Internal variables.
-PAPEROPT_a4     = -D latex_paper_size=a4
-PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-
-.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
-
-help:
-	@echo "Please use \`make <target>' where <target> is one of"
-	@echo "  html      to make standalone HTML files"
-	@echo "  dirhtml   to make HTML files named index.html in directories"
-	@echo "  pickle    to make pickle files"
-	@echo "  json      to make JSON files"
-	@echo "  htmlhelp  to make HTML files and a HTML help project"
-	@echo "  qthelp    to make HTML files and a qthelp project"
-	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
-	@echo "  changes   to make an overview of all changed/added/deprecated items"
-	@echo "  linkcheck to check all external links for integrity"
-	@echo "  doctest   to run all doctests embedded in the documentation (if enabled)"
-
-clean:
-	-rm -rf $(BUILDDIR)/*
-
-html:
-	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
-	@echo
-	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
-
-dirhtml:
-	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
-	@echo
-	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
-
-pickle:
-	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
-	@echo
-	@echo "Build finished; now you can process the pickle files."
-
-json:
-	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
-	@echo
-	@echo "Build finished; now you can process the JSON files."
-
-htmlhelp:
-	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
-	@echo
-	@echo "Build finished; now you can run HTML Help Workshop with the" \
-	      ".hhp project file in $(BUILDDIR)/htmlhelp."
-
-qthelp:
-	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
-	@echo
-	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
-	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
-	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/DjangoSimpleCaptcha.qhcp"
-	@echo "To view the help file:"
-	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/DjangoSimpleCaptcha.qhc"
-
-latex:
-	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-	@echo
-	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
-	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
-	      "run these through (pdf)latex."
-
-changes:
-	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
-	@echo
-	@echo "The overview file is in $(BUILDDIR)/changes."
-
-linkcheck:
-	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
-	@echo
-	@echo "Link check complete; look for any errors in the above output " \
-	      "or in $(BUILDDIR)/linkcheck/output.txt."
-
-doctest:
-	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
-	@echo "Testing of doctests in the sources finished, look at the " \
-	      "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/docs/_static/captcha3.png b/docs/_static/captcha3.png
deleted file mode 100644
index 7d2b9f9..0000000
Binary files a/docs/_static/captcha3.png and /dev/null differ
diff --git a/docs/_static/dict.png b/docs/_static/dict.png
deleted file mode 100644
index 9458460..0000000
Binary files a/docs/_static/dict.png and /dev/null differ
diff --git a/docs/_static/math.png b/docs/_static/math.png
deleted file mode 100644
index ed123d9..0000000
Binary files a/docs/_static/math.png and /dev/null differ
diff --git a/docs/_static/random_chars.png b/docs/_static/random_chars.png
deleted file mode 100644
index b431427..0000000
Binary files a/docs/_static/random_chars.png and /dev/null differ
diff --git a/docs/advanced.rst b/docs/advanced.rst
deleted file mode 100644
index 799200b..0000000
--- a/docs/advanced.rst
+++ /dev/null
@@ -1,202 +0,0 @@
-Advanced topics
-===============
-
-Configuration toggles
-+++++++++++++++++++++
-
-The following configuration elements can be defined (in your ``settings.py``)
-
-CAPTCHA_FONT_PATH
------------------
-
-Full path and filename of a TrueType (TTF), OpenType, or pilfont font file used to render text.
-
-Defaults to: ``fonts/Vera.ttf`` (included in the application, GPL font).
-
-Note that your PIL installation must support TTF and/or OpenFont if you want to use these kind of glyphs (most modern distributions of PIL do.)
-
-Note: as of version 0.4.6, ``CAPTCHA_FONT_PATH`` may be an iterable of font paths, in which case a font will be picked randomly from the list for each CAPTCHA.
-
-CAPTCHA_FONT_SIZE
------------------
-
-Font-size in pixels of the rendered text.
-
-Defaults to '22'.
-
-CAPTCHA_IMAGE_SIZE
-------------------
-
-Image size in pixels of generated captcha, specified by 2-tuple (width, height)
-
-Defaults to `None` (automatically calculated)
-
-CAPTCHA_LETTER_ROTATION
------------------------
-
-A random rotation in this interval is applied to each letter in the challenge text.
-
-Defaults to ``(-35,35)``.
-
-New in version 0.1.6: set this to None to disable letter roation.
-
-CAPTCHA_BACKGROUND_COLOR
-------------------------
-
-Background-color of the captcha. Can be expressed as html-style #rrggbb, rgb(red, green, blue), or common html names (e.g. "red").
-
-Defaults to: ``'#ffffff'``
-
-CAPTCHA_FOREGROUND_COLOR
-------------------------
-
-Foreground-color of the captcha.
-
-Defaults to ``'#001100'``
-
-CAPTCHA_CHALLENGE_FUNCT
-------------------------
-
-String representing a python callable (i.e. a function) to use as challenge generator.
-
-See Generators below for a list of available generators and a guide on how to write your own.
-
-Defaults to: ``'captcha.helpers.random_char_challenge'``
-
-CAPTCHA_NOISE_FUNCTIONS
-------------------------
-
-List of strings of python callables that take a PIL ``DrawImage`` object and an ``Image`` image as input, modify the ``DrawImage``, then return it.
-
-Defaults to: ``('captcha.helpers.noise_arcs','captcha.helpers.noise_dots',)``
-
-A null noise helper function useful when debugging issues is available at ``'captcha.helpers.noise_null'``.
-
-
-CAPTCHA_FILTER_FUNCTIONS
-------------------------
-
-List of strings of python callables that take a PIL ``Image`` object as input, modify it and return it.
-
-These are called right before the rendering, i.e. after the noise functions.
-
... 803 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-simple-captcha.git



More information about the Python-modules-commits mailing list