[Python-modules-commits] [python-django-contact-form] 01/08: Import upstream snapshot 8413069af2bd9282be6fafe5185f54dcdbe88b38

Andrew Starr-Bochicchio asb at moszumanska.debian.org
Fri Dec 25 19:20:35 UTC 2015


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

asb pushed a commit to branch master
in repository python-django-contact-form.

commit 023166ec30eaebe43c08eaa60870d9d9a56bde63
Author: Andrew Starr-Bochicchio <a.starr.b at gmail.com>
Date:   Fri Dec 25 13:33:55 2015 -0500

    Import upstream snapshot 8413069af2bd9282be6fafe5185f54dcdbe88b38
---
 LICENSE                                              |  2 +-
 README.rst                                           |  3 +++
 contact_form/forms.py                                | 14 +++++++-------
 contact_form/runtests.py                             |  7 ++++++-
 .../tests/templates/contact_form/contact_form.html   |  1 +
 .../tests/templates/contact_form/contact_form.txt    |  1 +
 .../templates/contact_form/contact_form_sent.html    |  1 +
 .../templates/contact_form/contact_form_subject.txt  |  1 +
 .../contact_form/test_callable_template_name.html    |  1 +
 contact_form/tests/test_forms.py                     |  3 +--
 contact_form/tests/test_views.py                     |  6 +++---
 contact_form/views.py                                | 20 ++++++++++++++++++++
 docs/conf.py                                         |  4 ++--
 docs/faq.rst                                         | 10 ++++------
 docs/install.rst                                     | 11 +++--------
 setup.cfg                                            | 16 ++++++++++++----
 setup.py                                             |  5 +++--
 17 files changed, 70 insertions(+), 36 deletions(-)

diff --git a/LICENSE b/LICENSE
index 1050a89..f8c707b 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2007-2013, James Bennett
+Copyright (c) 2007-2015, James Bennett
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/README.rst b/README.rst
index b38ae43..0751b15 100644
--- a/README.rst
+++ b/README.rst
@@ -1,5 +1,8 @@
 .. -*-restructuredtext-*-
 
+.. image:: https://travis-ci.org/ubernostrum/django-contact-form.svg?branch=master
+    :target: https://travis-ci.org/ubernostrum/django-contact-form
+
 This application provids simple, extensible contact-form functionality
 for `Django <https://www.djangoproject.com/>`_ sites.
 
diff --git a/contact_form/forms.py b/contact_form/forms.py
index de69edc..d77d587 100644
--- a/contact_form/forms.py
+++ b/contact_form/forms.py
@@ -6,11 +6,11 @@ a web interface.
 
 from django import forms
 from django.conf import settings
-from django.core.mail import send_mail
-from django.template import loader
-from django.template import RequestContext
-from django.contrib.sites.models import RequestSite
 from django.contrib.sites.models import Site
+from django.contrib.sites.requests import RequestSite
+from django.utils.translation import ugettext_lazy as _
+from django.core.mail import send_mail
+from django.template import RequestContext, loader
 
 
 class ContactForm(forms.Form):
@@ -20,11 +20,11 @@ class ContactForm(forms.Form):
 
     """
     name = forms.CharField(max_length=100,
-                           label=u'Your name')
+                           label=_(u'Your name'))
     email = forms.EmailField(max_length=200,
-                             label=u'Your email address')
+                             label=_(u'Your email address'))
     body = forms.CharField(widget=forms.Textarea,
-                           label=u'Your message')
+                           label=_(u'Your message'))
 
     from_email = settings.DEFAULT_FROM_EMAIL
 
diff --git a/contact_form/runtests.py b/contact_form/runtests.py
index 372356b..a2901e5 100644
--- a/contact_form/runtests.py
+++ b/contact_form/runtests.py
@@ -21,7 +21,12 @@ sys.path.insert(0, CONTACT_FORM_DIR)
 # Minimum settings required for django-contact-form to work.
 SETTINGS_DICT = {
     'BASE_DIR': CONTACT_FORM_DIR,
-    'INSTALLED_APPS': ('contact_form', 'django.contrib.sites'),
+    'INSTALLED_APPS': (
+        'contact_form',
+        'django.contrib.auth',
+        'django.contrib.contenttypes',
+        'django.contrib.sites',
+    ),
     'ROOT_URLCONF': 'contact_form.tests.urls',
     'DATABASES': {
         'default': {
diff --git a/contact_form/tests/templates/contact_form/contact_form.html b/contact_form/tests/templates/contact_form/contact_form.html
new file mode 100644
index 0000000..30580d0
--- /dev/null
+++ b/contact_form/tests/templates/contact_form/contact_form.html
@@ -0,0 +1 @@
+{{ body }}
diff --git a/contact_form/tests/templates/contact_form/contact_form.txt b/contact_form/tests/templates/contact_form/contact_form.txt
new file mode 100644
index 0000000..ba6f437
--- /dev/null
+++ b/contact_form/tests/templates/contact_form/contact_form.txt
@@ -0,0 +1 @@
+{{ body }}
\ No newline at end of file
diff --git a/contact_form/tests/templates/contact_form/contact_form_sent.html b/contact_form/tests/templates/contact_form/contact_form_sent.html
new file mode 100644
index 0000000..d77907c
--- /dev/null
+++ b/contact_form/tests/templates/contact_form/contact_form_sent.html
@@ -0,0 +1 @@
+<p>Message sent!</p>
diff --git a/contact_form/tests/templates/contact_form/contact_form_subject.txt b/contact_form/tests/templates/contact_form/contact_form_subject.txt
new file mode 100644
index 0000000..dbe1d01
--- /dev/null
+++ b/contact_form/tests/templates/contact_form/contact_form_subject.txt
@@ -0,0 +1 @@
+Contact form message
\ No newline at end of file
diff --git a/contact_form/tests/templates/contact_form/test_callable_template_name.html b/contact_form/tests/templates/contact_form/test_callable_template_name.html
new file mode 100644
index 0000000..7856439
--- /dev/null
+++ b/contact_form/tests/templates/contact_form/test_callable_template_name.html
@@ -0,0 +1 @@
+Callable template_name used.
diff --git a/contact_form/tests/test_forms.py b/contact_form/tests/test_forms.py
index 0491d58..0691163 100644
--- a/contact_form/tests/test_forms.py
+++ b/contact_form/tests/test_forms.py
@@ -1,7 +1,6 @@
 from django.conf import settings
 from django.core import mail
-from django.test import RequestFactory
-from django.test import TestCase
+from django.test import RequestFactory, TestCase
 
 from ..forms import ContactForm
 
diff --git a/contact_form/tests/test_views.py b/contact_form/tests/test_views.py
index 5860865..9dee61f 100644
--- a/contact_form/tests/test_views.py
+++ b/contact_form/tests/test_views.py
@@ -1,14 +1,14 @@
 from django.conf import settings
 from django.core import mail
 from django.core.urlresolvers import reverse
-from django.test import RequestFactory
-from django.test import TestCase
+from django.test import RequestFactory, TestCase
+from django.test.utils import override_settings
 
 from ..forms import ContactForm
 
 
+ at override_settings(ROOT_URLCONF='contact_form.tests.test_urls')
 class ContactFormViewTests(TestCase):
-    urls = 'contact_form.tests.test_urls'
 
     def test_get(self):
         """
diff --git a/contact_form/views.py b/contact_form/views.py
index ed08613..4115972 100644
--- a/contact_form/views.py
+++ b/contact_form/views.py
@@ -18,6 +18,26 @@ class ContactFormView(FormView):
         form.save()
         return super(ContactFormView, self).form_valid(form)
 
+    def form_invalid(self, form):
+        # tl;dr -- this method is implemented to work around Django
+        # ticket #25548, which is present in the Django 1.9 release
+        # (but not in Django 1.8).
+        #
+        # The longer explanation is that in Django 1.9,
+        # FormMixin.form_invalid() does not pass the form instance to
+        # get_context_data(). This causes get_context_data() to
+        # construct a new form instance with the same data in order to
+        # put it into the template context, and then any access to
+        # that form's ``errors`` or ``cleaned_data`` runs that form
+        # instance's validation. The end result is that validation
+        # gets run twice on an invalid form submission, which is
+        # undesirable for performance reasons.
+        #
+        # Manually implementing this method, and passing the form
+        # instance to get_context_data(), solves this issue (which
+        # will be fixed in Django 1.9.1 and Django 1.10).
+        return self.render_to_response(self.get_context_data(form=form))
+
     def get_form_kwargs(self):
         # ContactForm instances require instantiation with an
         # HttpRequest.
diff --git a/docs/conf.py b/docs/conf.py
index 96297f8..4d45081 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -8,8 +8,8 @@ source_suffix = '.rst'
 master_doc = 'index'
 project = u'django-contact-form'
 copyright = u'2007-2015, James Bennett'
-version = '1.1'
-release = '1.1'
+version = '1.2'
+release = '1.2'
 exclude_trees = ['_build']
 pygments_style = 'sphinx'
 html_static_path = ['_static']
diff --git a/docs/faq.rst b/docs/faq.rst
index 04c4c8b..32d9fe8 100644
--- a/docs/faq.rst
+++ b/docs/faq.rst
@@ -11,16 +11,14 @@ you when installing, configuring or using ``django-contact-form``.
 What versions of Django are supported?
 --------------------------------------
 
-As of ``django-contact-form`` |version|, Django 1.7 and 1.8 are
-supported.
+As of ``django-contact-form`` |version|, Django 1.8 and 1.9 are supported.
 
 
 What versions of Python are supported?
 --------------------------------------
 
-As of |version|, ``django-contact-form`` supports Python 2.7, 3.3, and
-3.4. It is anticipated that when Python 3.5 is released,
-``django-contact-form`` |version| will be compatible with it.
+As of |version|, ``django-contact-form`` supports Python 2.7, 3.3, 3.4, and
+3.5.
 
 
 Why aren't there any default templates I can use?
@@ -71,4 +69,4 @@ newlines in message headers
 is the exception Django raises when a newline is detected in a header.
 
 Note that this only applies to the headers of an email message; the
-message body can (and usually does) contain newlines.
\ No newline at end of file
+message body can (and usually does) contain newlines.
diff --git a/docs/install.rst b/docs/install.rst
index 53a9d21..8898a3c 100644
--- a/docs/install.rst
+++ b/docs/install.rst
@@ -10,12 +10,9 @@ information on obtaining and installing Django, consult the `Django
 download page <https://www.djangoproject.com/download/>`_, which
 offers convenient packaged downloads and installation instructions.
 
-The |version| release of ``django-contact-form`` supports Django 1.7
-and 1.8, on any of Python 2.7, 3.3 or 3.4. Older versions of Django
-and/or Python may work, but are not tested or officially supported. It
-is expected that ``django-contact-form`` |version| will be compatible
-with Python 3.5 once released (as of the release of
-``django-contact-form`` |version|, Python 3.5 was in beta testing).
+The |version| release of ``django-contact-form`` supports Django 1.8 and 1.9,
+on any of Python 2.7, 3.3, 3.4, or 3.5. Older versions of Django and/or Python
+may work, but are not tested or officially supported.
 
 
 Normal installation
@@ -147,5 +144,3 @@ to place it at ``/contact/``:
 .. code-block:: python
 
     url(r'^contact/', include('contact_form.urls')),
-
-
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..8caa9b1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,13 @@
-[egg_info]
-tag_build = 
-tag_date = 0
-tag_svn_revision = 0
+[coverage:run]
+include = contact_form/*
+omit = contact_form/tests/*
 
+[coverage:report]
+fail_under = 100
+
+[flake8]
+exclude = __pycache__,.pyc,templates
+max-complexity = 10
+
+[isort]
+lines_after_imports = 2
diff --git a/setup.py b/setup.py
index 8dd94de..ab3178e 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@ from setuptools import setup
 
 
 setup(name='django-contact-form',
-      version='1.1',
+      version='1.2',
       zip_safe=False, # eggs are the devil.
       description='Generic contact-form application for Django',
       long_description=open(os.path.join(os.path.dirname(__file__),
@@ -17,8 +17,8 @@ setup(name='django-contact-form',
       classifiers=['Development Status :: 5 - Production/Stable',
                    'Environment :: Web Environment',
                    'Framework :: Django',
-                   'Framework :: Django :: 1.7',
                    'Framework :: Django :: 1.8',
+                   'Framework :: Django :: 1.9',
                    'Intended Audience :: Developers',
                    'License :: OSI Approved :: BSD License',
                    'Operating System :: OS Independent',
@@ -28,5 +28,6 @@ setup(name='django-contact-form',
                    'Programming Language :: Python :: 3',
                    'Programming Language :: Python :: 3.3',
                    'Programming Language :: Python :: 3.4',
+                   'Programming Language :: Python :: 3.5',
                    'Topic :: Utilities'],
       )

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



More information about the Python-modules-commits mailing list