diff --git a/.travis.yml b/.travis.yml index ba94b8a..396b100 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,26 @@ language: python +dist: xenial python: - "3.4" - "3.5" - "3.6" + - "3.7" env: - DJANGO=1.8 - DJANGO=1.11 - DJANGO=2.0 + - DJANGO=2.1 + +matrix: + exclude: + - python: "3.4" + env: DJANGO=2.1 + - python: "3.7" + env: DJANGO=1.8 + - python: "3.7" + env: DJANGO=1.11 install: - pip install tox tox-travis diff --git a/AUTHORS.rst b/AUTHORS.rst index 66e699f..0f28ba4 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -11,3 +11,4 @@ Contributors ------------ * Taavi Teska +* Jorgen Ader diff --git a/HISTORY.rst b/HISTORY.rst index bee8cb7..fb47f75 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,21 @@ History ======= +0.4.0 (2019-02-07) +------------------ + +* Supported Django and Python versions are listed below + +=============== ================== +Django version Python versions +--------------- ------------------ +Django 1.8 3.4, 3.5, 3.6 +Django 1.11 3.4, 3.5, 3.6 +Django 2.0 3.4, 3.5, 3.6, 3.7 +Django 2.1 3.5, 3.6, 3.7 +=============== ================== + + 0.3.0 (2018-03-12) ------------------ diff --git a/setup.py b/setup.py index 7795ca2..2e663dc 100755 --- a/setup.py +++ b/setup.py @@ -16,9 +16,6 @@ with open('HISTORY.rst') as history_file: history = history_file.read() -requirements = [ - 'django>=1.8,<2.1', -] setup( name='tg-utils', @@ -34,7 +31,9 @@ package_dir={'tg_utils': 'tg_utils'}, include_package_data=True, - install_requires=requirements, + install_requires=[ + 'django>=1.8,!=2.1.0,!=2.1.1,<2.2', + ], license="ISCL", zip_safe=False, keywords='tg-utils tg_utils', @@ -47,5 +46,6 @@ 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', ], ) diff --git a/tg_utils/__init__.py b/tg_utils/__init__.py index 15a098e..8513505 100644 --- a/tg_utils/__init__.py +++ b/tg_utils/__init__.py @@ -2,4 +2,4 @@ __author__ = 'Thorgate' __email__ = 'code@thorgate.eu' -__version__ = '0.3.0' +__version__ = '0.4.0' diff --git a/tg_utils/admin.py b/tg_utils/admin.py index 326c37f..66cb690 100644 --- a/tg_utils/admin.py +++ b/tg_utils/admin.py @@ -1,14 +1,28 @@ +import django + from django.contrib.admin.options import InlineModelAdmin from django.forms.models import BaseInlineFormSet +# Select correct has_add_permission signature based on Django version +if django.VERSION >= (2, 1): + class ReadOnlyAddAdminMixin: + def has_add_permission(self, request, obj): + return False + +else: + class ReadOnlyAddAdminMixin: + def has_add_permission(self, request): + return False + + class AutoMediaFormSet(BaseInlineFormSet): @property def media(self): return self.empty_form.media -class StaticModelAdmin(InlineModelAdmin): +class StaticModelAdmin(ReadOnlyAddAdminMixin, InlineModelAdmin): """ Displays inline models as read-only. """ @@ -18,9 +32,6 @@ class StaticModelAdmin(InlineModelAdmin): exclude = ('created_by', 'created_at', 'closed_by', 'closed_at', 'updated_at', ) - def has_add_permission(self, request): - return False - def has_delete_permission(self, request, obj=None): return False diff --git a/tox.ini b/tox.ini index b666a99..568dbd0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,12 @@ [tox] -envlist = py{34,35,36}-django{18,111,20} +envlist = py{34,35,36}-django{18,111,20},py{35,36,37}-django{20,21} [travis:env] DJANGO = 1.8: django18 1.11: django111 2.0: django20 + 2.1: django21 [testenv] setenv = @@ -16,6 +17,7 @@ deps = django18: Django>=1.8,<1.9 django111: Django>=1.11,<1.12 django20: Django>=2.0,<2.1 + django21: Django>=2.1,<2.2 -r{toxinidir}/requirements_test.txt [testenv:py36-django20]