Skip to content

Commit

Permalink
Merge pull request #72 from dimagi/gh/tests/update-versions
Browse files Browse the repository at this point in the history
Add support for Django 4.2
  • Loading branch information
gherceg authored Nov 20, 2023
2 parents 43e1d2a + 538989a commit f8ad9b2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ jobs:

strategy:
matrix:
python-version: [ "3.7", "3.8", "3.9" ]
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
django-version: [ "3.2.*", "4.2.*" ]

steps:
- uses: actions/checkout@v4
Expand All @@ -21,12 +22,12 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: install dependencies
run: |
pip install django==3.2.*
pip install django==${{ matrix.django-version }}
pip install -e .
pip install coverage coveralls
- name: run tests
run: |
coverage run --source='django_prbac' `which django-admin.py` test django_prbac --settings django_prbac.mock_settings --traceback
coverage run --source='django_prbac' `which django-admin` test django_prbac --settings django_prbac.mock_settings --traceback
- name: report coverage stats
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ nosetests.xml

/docs/_build
/django-prbac.db

# virtualenv
.python-version
8 changes: 6 additions & 2 deletions django_prbac/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ def get_privileges(self, assignment):
return self._granted_privileges
except AttributeError:
pass
return [membership.instantiated_to_role(assignment)
for membership in self.memberships_granted.all()]
try:
memberships = self.memberships_granted.all()
except ValueError:
# Django 4 raises ValueError if fk relationship is accessed prior to save
return []
return [m.instantiated_to_role(assignment) for m in memberships]

def instantiate(self, assignment):
"""
Expand Down
4 changes: 2 additions & 2 deletions django_prbac/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.conf.urls import url
from django.urls import re_path
from django.contrib import admin

admin.autodiscover()

urlpatterns = [
url(r'^admin/', admin.site.urls),
re_path(r'^admin/', admin.site.urls),
]
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def get_readme():
packages=find_packages(),
zip_safe=False,
install_requires=[
# avoid django 2 <2.2.10 and django 3 < 3.0.7
# avoid django 3 < 3.0.7
# https://github.com/advisories/GHSA-hmr4-m2h5-33qx
'django>=2.2.13,!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,!=3.0.4,!=3.0.5,!=3.0.6,<4',
'django>=3.0.7,<5',
'jsonfield>=1.0.3,<4',
'simplejson',
],
Expand All @@ -45,9 +45,10 @@ def get_readme():
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Software Development :: Libraries :: Python Modules',
],
options={"bdist_wheel": {"universal": "1"}},
Expand Down

0 comments on commit f8ad9b2

Please sign in to comment.