Merge pull request #90 from uncovertruth/drop_unsupported_versions

Drop unsupported versions and Add new versions
This commit is contained in:
tomasgarzon 2019-09-19 06:51:55 +02:00 committed by GitHub
commit 72177cc624
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 116 additions and 275 deletions

View file

@ -1,80 +1,27 @@
language: python language: python
python: python:
- "2.6"
- "2.7" - "2.7"
- "3.3"
- "3.4" - "3.4"
- "3.5" - "3.5"
- "3.6" - "3.6"
env: env:
- DJANGO_VERSION='Django>=1.4,<1.5'
- DJANGO_VERSION='Django>=1.5,<1.6'
- DJANGO_VERSION='Django>=1.6,<1.7'
- DJANGO_VERSION='Django>=1.7,<1.8'
- DJANGO_VERSION='Django>=1.8,<1.9'
- DJANGO_VERSION='Django>=1.9,<1.10'
- DJANGO_VERSION='Django>=1.10,<1.11'
- DJANGO_VERSION='Django>=1.11,<2.0' - DJANGO_VERSION='Django>=1.11,<2.0'
- DJANGO_VERSION='Django>=2.0,<2.1'
- DJANGO_VERSION='Django>=2.1,<2.2'
- DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz' - DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
matrix: matrix:
exclude: exclude:
- python: "2.6" - python: "2.7"
env: DJANGO_VERSION='Django>=1.7,<1.8' env: DJANGO_VERSION='Django>=2.0,<2.1'
- python: "2.6" - python: "2.7"
env: DJANGO_VERSION='Django>=1.8,<1.9' env: DJANGO_VERSION='Django>=2.1,<2.2'
- python: "2.6"
env: DJANGO_VERSION='Django>=1.9,<1.10'
- python: "2.6"
env: DJANGO_VERSION='Django>=1.10,<1.11'
- python: "2.6"
env: DJANGO_VERSION='Django>=1.11,<2.0'
- python: "2.6"
env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- python: "2.7" - python: "2.7"
env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz' env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- python: "3.3" - python: "3.4"
env: DJANGO_VERSION='Django>=1.4,<1.5' env: DJANGO_VERSION='Django>=2.1,<2.2'
- python: "3.3" - python: "2.7"
env: DJANGO_VERSION='Django>=1.5,<1.6'
- python: "3.3"
env: DJANGO_VERSION='Django>=1.9,<1.10'
- python: "3.3"
env: DJANGO_VERSION='Django>=1.10,<1.11'
- python: "3.3"
env: DJANGO_VERSION='Django>=1.11,<2.0'
- python: "3.3"
env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz' env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- python: "3.4"
env: DJANGO_VERSION='Django>=1.4,<1.5'
- python: "3.4"
env: DJANGO_VERSION='Django>=1.5,<1.6'
- python: "3.4"
env: DJANGO_VERSION='Django>=1.6,<1.7'
- python: "3.4"
env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- python: "3.5"
env: DJANGO_VERSION='Django>=1.4,<1.5'
- python: "3.5"
env: DJANGO_VERSION='Django>=1.5,<1.6'
- python: "3.5"
env: DJANGO_VERSION='Django>=1.6,<1.7'
- python: "3.5"
env: DJANGO_VERSION='Django>=1.7,<1.8'
- python: "3.6"
env: DJANGO_VERSION='Django>=1.4,<1.5'
- python: "3.6"
env: DJANGO_VERSION='Django>=1.5,<1.6'
- python: "3.6"
env: DJANGO_VERSION='Django>=1.6,<1.7'
- python: "3.6"
env: DJANGO_VERSION='Django>=1.7,<1.8'
- python: "3.6"
env: DJANGO_VERSION='Django>=1.8,<1.9'
- python: "3.6"
env: DJANGO_VERSION='Django>=1.9,<1.10'
- python: "3.6"
env: DJANGO_VERSION='Django>=1.10,<1.11'
allow_failures: allow_failures:
- env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz' - env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'

View file

@ -14,9 +14,9 @@ A new model field and form field. With this you can get a multiple select from a
This egg is inspired by this `snippet <http://djangosnippets.org/snippets/1200/>`_. This egg is inspired by this `snippet <http://djangosnippets.org/snippets/1200/>`_.
Supported Python versions: 2.6, 2.7, 3.3+ Supported Python versions: 2.7, 3.4+
Supported Django versions: 1.4-1.11+ Supported Django versions: 1.11-2.0+
Installation Installation
============ ============

View file

@ -32,11 +32,7 @@ else:
u = str u = str
if VERSION < (1, 9): def get_field(model, name):
def get_field(model, name):
return model._meta.get_field_by_name(name)[0]
else:
def get_field(model, name):
return model._meta.get_field(name) return model._meta.get_field(name)
@ -77,10 +73,6 @@ class MultiSelectTestCase(TestCase):
# call Field.from_db_field, it simply returns a Python representation # call Field.from_db_field, it simply returns a Python representation
# of the data in the database (which in our case is a string of # of the data in the database (which in our case is a string of
# comma-separated values). The bug was fixed in Django 1.8+. # comma-separated values). The bug was fixed in Django 1.8+.
if VERSION >= (1, 6) and VERSION < (1, 8):
self.assertStringEqual(tag_list_list, [u('sex,work,happy')])
self.assertStringEqual(categories_list_list, [u('1,3,5')])
else:
self.assertListEqual(tag_list_list, [['sex', 'work', 'happy']]) self.assertListEqual(tag_list_list, [['sex', 'work', 'happy']])
self.assertListEqual(categories_list_list, [['1', '3', '5']]) self.assertListEqual(categories_list_list, [['1', '3', '5']])
@ -139,7 +131,7 @@ class MultiSelectTestCase(TestCase):
self.assertEqual(len(form_class.base_fields), 1) self.assertEqual(len(form_class.base_fields), 1)
form = form_class(initial={'published_in': ['BC', 'AK']}) form = form_class(initial={'published_in': ['BC', 'AK']})
expected_html = u("""<p><label for="id_published_in_0">Province or State:</label> <ul id="id_published_in"><li>Canada - Provinces<ul id="id_published_in_0"><li><label for="id_published_in_0_0"><input id="id_published_in_0_0" name="published_in" type="checkbox" value="AB" /> Alberta</label></li>\n""" expected_html = u("""<p><label>Province or State:</label> <ul id="id_published_in"><li>Canada - Provinces<ul id="id_published_in_0"><li><label for="id_published_in_0_0"><input id="id_published_in_0_0" name="published_in" type="checkbox" value="AB" /> Alberta</label></li>\n"""
"""<li><label for="id_published_in_0_1"><input checked="checked" id="id_published_in_0_1" name="published_in" type="checkbox" value="BC" /> British Columbia</label></li></ul></li>\n""" """<li><label for="id_published_in_0_1"><input checked="checked" id="id_published_in_0_1" name="published_in" type="checkbox" value="BC" /> British Columbia</label></li></ul></li>\n"""
"""<li>USA - States<ul id="id_published_in_1"><li><label for="id_published_in_1_0"><input checked="checked" id="id_published_in_1_0" name="published_in" type="checkbox" value="AK" /> Alaska</label></li>\n""" """<li>USA - States<ul id="id_published_in_1"><li><label for="id_published_in_1_0"><input checked="checked" id="id_published_in_1_0" name="published_in" type="checkbox" value="AK" /> Alaska</label></li>\n"""
"""<li><label for="id_published_in_1_1"><input id="id_published_in_1_1" name="published_in" type="checkbox" value="AL" /> Alabama</label></li>\n""" """<li><label for="id_published_in_1_1"><input id="id_published_in_1_1" name="published_in" type="checkbox" value="AL" /> Alabama</label></li>\n"""
@ -147,17 +139,9 @@ class MultiSelectTestCase(TestCase):
actual_html = form.as_p() actual_html = form.as_p()
if (1, 11) <= VERSION < (2, 0): if VERSION >= (2, 0):
# Django 1.11+ does not assign 'for' attributes on labels if they expected_html = expected_html.replace('input checked="checked"', 'input checked')
# are group labels
expected_html = expected_html.replace('label for="id_published_in_0"', 'label')
if VERSION < (1, 6):
# Django 1.6 renders the Python repr() for each group (eg: tuples
# with HTML entities), so we skip the test for that version
self.assertEqual(expected_html.replace('\n', ''), actual_html.replace('\n', ''))
if VERSION >= (1, 7):
self.assertHTMLEqual(expected_html, actual_html) self.assertHTMLEqual(expected_html, actual_html)

View file

@ -19,7 +19,7 @@ from django.conf import settings
from django.contrib.auth import login from django.contrib.auth import login
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.core.urlresolvers import reverse from django.urls import reverse
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect

View file

@ -14,43 +14,33 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>. # along with this software. If not, see <http://www.gnu.org/licenses/>.
from django import VERSION
from django.conf import settings from django.conf import settings
try: try:
from django.conf.urls import include, url from django.conf.urls import include, url
except ImportError:
# Compatibility for Django > 1.8 from django.urls import include, url
def patterns(prefix, *args):
if VERSION < (1, 9):
from django.conf.urls import patterns as django_patterns
return django_patterns(prefix, *args)
elif prefix != '':
raise NotImplementedError("You need to update your URLConf for "
"Django 1.10, or tweak it to remove the "
"prefix parameter")
else:
return list(args)
except ImportError: # Django < 1.4
from django.conf.urls.defaults import include, patterns, url
from django.contrib import admin from django.contrib import admin
from django.views.static import serve from django.views.static import serve
admin.autodiscover() admin.autodiscover()
js_info_dict = { js_info_dict = {
'packages': ('django.conf',), 'packages': ('django.conf',),
} }
urlpatterns = patterns( urlpatterns = [
'',
url(r'^', include('app.urls')), url(r'^', include('app.urls')),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', admin.site.urls),
) ]
urlpatterns += patterns( urlpatterns += [
'', url(
url(r'^%s(?P<path>.*)$' % settings.MEDIA_URL[1:], r'^%s(?P<path>.*)$' % settings.MEDIA_URL[1:],
serve, serve,
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), {
) 'document_root': settings.MEDIA_ROOT,
'show_indexes': True,
},
),
]

View file

@ -19,10 +19,9 @@
import os import os
import sys import sys
import django
from django.conf import ENVIRONMENT_VARIABLE from django.conf import ENVIRONMENT_VARIABLE
from django.core import management from django.core import management
from django.core.wsgi import get_wsgi_application
if len(sys.argv) == 1: if len(sys.argv) == 1:
@ -30,8 +29,6 @@ if len(sys.argv) == 1:
else: else:
os.environ[ENVIRONMENT_VARIABLE] = sys.argv[1] os.environ[ENVIRONMENT_VARIABLE] = sys.argv[1]
if django.VERSION[0] == 1 and django.VERSION[1] >= 7: application = get_wsgi_application()
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
management.call_command('test', 'app') management.call_command('test', 'app')

View file

@ -102,7 +102,7 @@ class MultiSelectField(models.CharField):
return choices_selected return choices_selected
def value_to_string(self, obj): def value_to_string(self, obj):
value = self._get_val_from_obj(obj) value = super(MultiSelectField, self).value_from_object(obj)
return self.get_prep_value(value) return self.get_prep_value(value)
def validate(self, value, model_instance): def validate(self, value, model_instance):
@ -147,10 +147,16 @@ class MultiSelectField(models.CharField):
return value if isinstance(value, list) else MSFList(choices, value.split(',')) return value if isinstance(value, list) else MSFList(choices, value.split(','))
return MSFList(choices, []) return MSFList(choices, [])
if VERSION < (2, ):
def from_db_value(self, value, expression, connection, context): def from_db_value(self, value, expression, connection, context):
if value is None: if value is None:
return value return value
return self.to_python(value) return self.to_python(value)
else:
def from_db_value(self, value, expression, connection):
if value is None:
return value
return self.to_python(value)
def contribute_to_class(self, cls, name): def contribute_to_class(self, cls, name):
super(MultiSelectField, self).contribute_to_class(cls, name) super(MultiSelectField, self).contribute_to_class(cls, name)

View file

@ -41,13 +41,12 @@ setup(
'Framework :: Django', 'Framework :: Django',
'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)', 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
], ],
license="LGPL 3", license="LGPL 3",
keywords="django,multiple,select,field,choices", keywords="django,multiple,select,field,choices",
@ -55,13 +54,13 @@ setup(
packages=find_packages(), packages=find_packages(),
include_package_data=True, include_package_data=True,
tests_require=[ tests_require=[
'django>=1.4', 'django>=1.11',
'tox', 'tox',
'coverage', 'coverage',
'flake8', 'flake8',
], ],
install_requires=[ install_requires=[
'django>=1.4', 'django>=1.11',
], ],
zip_safe=False, zip_safe=False,
) )

212
tox.ini
View file

@ -1,5 +1,5 @@
[tox] [tox]
envlist = py26-dj14,py26-dj15,py26-dj16,py27-dj14,py27-dj15,py27-dj16,py27-dj17,py27-dj18,py27-dj19,py27-dj110,py33-dj16,py33-dj17,py33-dj18,py34-dj17,py34-dj18,py34-dj19,py34-dj110,py35-dj18,py35-dj19,py35-dj110 envlist = py{27,34,35,36}-dj111,py{34,35,36,37}-dj20,py{35,36,37}-dj21
[testenv] [testenv]
usedevelop = True usedevelop = True
@ -12,186 +12,104 @@ commands =
install_command = install_command =
pip install {opts} {packages} pip install {opts} {packages}
[testenv:py26-dj14] [testenv:py27-dj111]
basepython = python2.6
deps =
django==1.4.22
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
flake8
[testenv:py26-dj15]
basepython = python2.6
deps =
django==1.5.12
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
flake8
[testenv:py26-dj16]
basepython = python2.6
deps =
django==1.6.11
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
flake8
[testenv:py27-dj14]
basepython = python2.7 basepython = python2.7
deps = deps =
django==1.4.22 django==1.11.15
pillow==1.7.8 pillow==1.7.8
PyYAML==3.10 PyYAML==3.13
coveralls==0.3
flake8
[testenv:py27-dj15]
basepython = python2.7
deps =
django==1.5.12
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
flake8
[testenv:py27-dj16]
basepython = python2.7
deps =
django==1.6.11
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
flake8
[testenv:py27-dj17]
basepython = python2.7
deps =
django==1.7.11
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
flake8
[testenv:py27-dj18]
basepython = python2.7
deps =
django==1.8.17
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
flake8
[testenv:py27-dj19]
basepython = python2.7
deps =
django==1.9.12
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
flake8
[testenv:py27-dj110]
basepython = python2.7
deps =
django==1.10.4
pillow==1.7.8
PyYAML==3.10
coveralls==0.3 coveralls==0.3
flake8 flake8
[testenv:py33-dj16] [testenv:py34-dj111]
basepython = python3.3
deps =
django==1.6.11
pillow==2.1.0
PyYAML==3.10
coveralls==0.3
flake8
[testenv:py33-dj17]
basepython = python3.3
deps =
django==1.7.11
pillow==2.1.0
PyYAML==3.10
coveralls==0.3
flake8
[testenv:py33-dj18]
basepython = python3.3
deps =
django==1.8.17
pillow==2.1.0
PyYAML==3.10
coveralls==0.3
flake8
[testenv:py34-dj17]
basepython = python3.4 basepython = python3.4
deps = deps =
django==1.7.11 django==1.11.15
pillow==2.1.0 pillow==2.1.0
PyYAML==3.10 PyYAML==3.13
coveralls==0.3 coveralls==0.3
flake8 flake8
[testenv:py34-dj18] [testenv:py34-dj20]
basepython = python3.4 basepython = python3.4
deps = deps =
django==1.8.17 django==2.0.8
pillow==2.1.0 pillow==2.1.0
PyYAML==3.10 PyYAML==3.13
coveralls==0.3
flake8
[testenv:py34-dj19]
basepython = python3.4
deps =
django==1.9.12
pillow==2.1.0
PyYAML==3.10
coveralls==0.3
flake8
[testenv:py34-dj110]
basepython = python3.4
deps =
django==1.10.4
pillow==2.1.0
PyYAML==3.10
coveralls==0.3 coveralls==0.3
flake8 flake8
[testenv:py35-dj18] [testenv:py35-dj111]
basepython = python3.5 basepython = python3.5
deps = deps =
django==1.8.17 django==1.11.15
pillow==2.1.0 pillow==2.1.0
PyYAML==3.10 PyYAML==3.13
coveralls==0.3 coveralls==0.3
flake8 flake8
[testenv:py35-dj19] [testenv:py35-dj20]
basepython = python3.5 basepython = python3.5
deps = deps =
django==1.9.12 django==2.0.8
pillow==2.1.0 pillow==2.1.0
PyYAML==3.10 PyYAML==3.13
coveralls==0.3 coveralls==0.3
flake8 flake8
[testenv:py35-dj110] [testenv:py35-dj21]
basepython = python3.5 basepython = python3.5
deps = deps =
django==1.10.4 django==2.1.1
pillow==2.1.0 pillow==2.1.0
PyYAML==3.10 PyYAML==3.13
coveralls==0.3
flake8
[testenv:py36-dj111]
basepython = python3.6
deps =
django==1.11.15
pillow==2.1.0
PyYAML==3.13
coveralls==0.3
flake8
[testenv:py36-dj20]
basepython = python3.6
deps =
django==2.0.8
pillow==2.1.0
PyYAML==3.13
coveralls==0.3
flake8
[testenv:py36-dj21]
basepython = python3.6
deps =
django==2.1.1
pillow==2.1.0
PyYAML==3.13
coveralls==0.3
flake8
[testenv:py37-dj20]
basepython = python3.7
deps =
django==2.0.8
pillow==2.1.0
PyYAML==3.13
coveralls==0.3
flake8
[testenv:py37-dj21]
basepython = python3.7
deps =
django==2.1.1
pillow==2.1.0
PyYAML==3.13
coveralls==0.3 coveralls==0.3
flake8 flake8