Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Django 4.2 #72

Merged
merged 10 commits into from
Nov 20, 2023
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
58 changes: 3 additions & 55 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,58 +1,6 @@
*.py[cod]
*~
\#*
.\#*
.history
.mypy_cache
.vscode
.python-version

# README.txt is just for the Cheeseshop; README.md is the authoritative one
/README.txt
/commcare_export/VERSION

# OSX droppings
.DS_Store

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
/pip-wheel-metadata

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
nosetests.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# PyCharm
.idea

# Excel
~*.xlsx

/docs/_build
/django-prbac.db
*.egg-info
__pycache__/
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:
return [membership.instantiated_to_role(assignment)
for membership in self.memberships_granted.all()]
except ValueError:
# Django 4 raises ValueError if fk relationship is accessed prior to save
return []
gherceg marked this conversation as resolved.
Show resolved Hide resolved

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',
gherceg marked this conversation as resolved.
Show resolved Hide resolved
'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