Skip to content

Commit

Permalink
Fixes #56: Added support for Django 3 and added envs in travisci for …
Browse files Browse the repository at this point in the history
…python 3.7 and 3.8

* Updated setup.py to allow django 3 while still excluding versions referenced in: GHSA-hmr4-m2h5-33qx
* Added py3.7 and py3.8 support to .travis.yml
* Django 3 took out the need for python_2_unicode_compatible as can be seen in other large django packages.  Lef as a version switch for backwards compatibility.
* Django 3 changed the signature of from_db_value and removed the context parameter as a positional arg.  The old code never used it anyhow so this change should work and is also the recommended change from looking at other Django packages

Ran through all the tests manually for each python environment and everything passed.
  • Loading branch information
Steve Graham committed Aug 4, 2020
1 parent effeb38 commit 2b9fae4
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -2,6 +2,9 @@
*~
\#*
.\#*
.history
.mypy_cache
.vscode

# README.txt is just for the Cheeseshop; README.md is the authoritative one
/README.txt
Expand Down
11 changes: 9 additions & 2 deletions .travis.yml
Expand Up @@ -3,9 +3,12 @@ python:
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
env:
- DJANGO_VERSION_MIN=1.11 DJANGO_VERSION_MAX=2.0
- DJANGO_VERSION_MIN=2.2 DJANGO_VERSION_MAX=2.3
- DJANGO_VERSION_MIN=2.2 DJANGO_VERSION_MAX<3
- DJANGO_VERSION_MIN=3.0.3 DJANGO_VERSION_MAX<4
install:
- pip install "django>=$DJANGO_VERSION_MIN,<$DJANGO_VERSION_MAX"
- "pip install -e ."
Expand All @@ -19,4 +22,8 @@ after_success:
matrix:
exclude:
- python: "3.4"
env: DJANGO_VERSION_MIN=2.2 DJANGO_VERSION_MAX=2.3
env: DJANGO_VERSION_MIN=2.2 DJANGO_VERSION_MAX<3
- python: "3.4"
env: DJANGO_VERSION_MIN=3.0.3 DJANGO_VERSION_MAX<4
- python: "3.5"
env: DJANGO_VERSION_MIN=3.0.3 DJANGO_VERSION_MAX<4
11 changes: 11 additions & 0 deletions Pipfile
@@ -0,0 +1,11 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]

[requires]
python_version = "3.4"
20 changes: 20 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions django_prbac/fields.py
Expand Up @@ -61,7 +61,7 @@ def formfield(self, **kwargs):
defaults.update(kwargs)
return super(StringListField, self).formfield(**defaults)

def from_db_value(self, value, expression, connection, context):
def from_db_value(self, value, expression, connection, *args, **kwargs):
return self.to_python(value)


Expand Down Expand Up @@ -108,5 +108,5 @@ def get_prep_value(self, value):
else:
return super(StringSetField, self).get_prep_value(sorted(value))

def from_db_value(self, value, expression, connection, context):
def from_db_value(self, value, expression, connection, *args, **kwargs):
return self.to_python(value)
8 changes: 7 additions & 1 deletion django_prbac/models.py
Expand Up @@ -6,9 +6,15 @@
import weakref

# Django imports
from django import VERSION
from django.db import models
from django.conf import settings
from django.utils.encoding import python_2_unicode_compatible
if VERSION[0] < 3:
from django.utils.encoding import python_2_unicode_compatible
else:
def python_2_unicode_compatible(fn):
return fn


# External Library imports
import jsonfield
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -32,9 +32,9 @@ def get_readme():
packages=find_packages(),
zip_safe=False,
install_requires=[
# avoid django 1 <1.11.28 and django 2 <2.2.10
# avoid django 1 <1.11.28 and django 2 <2.2.10 and django 3 < 3.0.3
# https://github.com/advisories/GHSA-hmr4-m2h5-33qx
'django>=1.11.28,!=2.0.*,!=2.1.*,!=2.2.0,!=2.2.1,!=2.2.2,!=2.2.3,!=2.2.4,!=2.2.5,!=2.2.6,!=2.2.7,!=2.2.8,!=2.2.9,<3',
'django>=1.11.28,!=2.0.*,!=2.1.*,!=2.2.0,!=2.2.1,!=2.2.2,!=2.2.3,!=2.2.4,!=2.2.5,!=2.2.6,!=2.2.7,!=2.2.8,!=2.2.9,!=3.0.0,!=3.0.1,!=3.0.2',
'jsonfield>=1.0.3,<3',
'simplejson',
'six',
Expand Down

0 comments on commit 2b9fae4

Please sign in to comment.