Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
2.1.0: Add support for django 4.0, 4.1. Add support for Python 3.10, 3.11.
2.1.0: Add support for django 4.0, 4.1. Add support for Python 3.10, 3.11, 3.12
2.0.3: remove upper bound on django requirement
2.0.2: Bump py, flake8 and other dependencies for security.
2.0.0: Support for django 2.0, 2.1, 2.2. Add support for Python3.7. Drop support for Python 2.7
Expand Down
27 changes: 25 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WITH_VENV=. $(VENV_ACTIVATE);
ifdef TRAVIS_PYTHON_VERSION
PYTHON=python$(TRAVIS_PYTHON_VERSION)
else
PYTHON=python3.9
PYTHON=python3.10
endif

ifdef TOX_ENV
Expand All @@ -23,7 +23,8 @@ default:
venv: $(VENV_ACTIVATE)

$(VENV_ACTIVATE): requirements*.txt setup.py
test -f $@ || virtualenv --python=$(PYTHON) $(VENV_DIR)
pip install virtualenv==20.8.1
test -f $@ || python3 -m venv $(VENV_DIR) || virtualenv --python=$(PYTHON) $(VENV_DIR)
$(WITH_VENV) pip install --no-deps -r requirements-setup.txt
$(WITH_VENV) pip install -e .
$(WITH_VENV) pip install --no-deps -r requirements-dev.txt
Expand Down Expand Up @@ -83,3 +84,25 @@ dist: venv
.PHONY: sdist
sdist: dist
@echo "runs dist"

### Infastructure for Github Actions
.PHONY: ci-libs
ci-libs:
sudo apt-get update -y
sudo apt-get install -y libldap2-dev libssl-dev libsasl2-dev

.PHONY: ci-install
ci-install: ci-libs venv

.PHONY: ci-lint
ci-lint: lint

.PHONY: ci-test
ci-test: test

.PHONY: ci-version
ci-version: version

.PHONY: ci-publish
ci-publish:
$(WITH_VENV) python setup.py sdist
3 changes: 1 addition & 2 deletions baya/backend.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from functools import partial
import six

from django.conf import settings
from django.contrib.auth import get_permission_codename
Expand Down Expand Up @@ -34,7 +33,7 @@ def get_all_permissions(self, user, obj=None):
user, obj)
from baya.admin.sites import _admin_registry
for admin_site in _admin_registry:
for model, opts in six.iteritems(admin_site._registry):
for model, opts in admin_site._registry.items():
app = model._meta.app_label
perm_name = partial(get_permission_codename, opts=model._meta)
if (hasattr(opts, 'user_has_add_permission') and
Expand Down
2 changes: 1 addition & 1 deletion baya/mock_ldap_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def mock_ldap_setup(
`.start()` on the returned value.
"""
from django.conf import settings
import mock
import mockldap
from unittest import mock

class MockLDAP(mockldap.MockLdap):
def start(self, *args, **kwargs):
Expand Down
20 changes: 10 additions & 10 deletions baya/permissions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import collections
import functools
import sys

if sys.version_info[:2] >= (3, 10):
collections.Callable = collections.abc.Callable
try:
from collections.abc import Callable
except Exception:
from collections import Callable


import django
from django.conf import settings
Expand All @@ -16,7 +17,6 @@
elif django.VERSION[0] >= 2:
from django.urls.resolvers import URLPattern
from django.urls.resolvers import URLResolver
import six

from .membership import BaseNode
from .membership import ValueNode
Expand Down Expand Up @@ -87,7 +87,7 @@ def _ensure_permission_node(self, groups):

if groups is None:
groups = []
elif isinstance(groups, six.string_types):
elif isinstance(groups, str):
groups = [group.strip() for group in groups.split(',')]

return self.DEFAULT_PERMISSION_NODE(*groups)
Expand Down Expand Up @@ -184,10 +184,10 @@ def __iadd__(self, other):
self.get_requires &= other.get_requires
self.post_requires &= other.post_requires
# Prefer other's login_url, if set
login_text_type = six.text_type(settings.BAYA_LOGIN_URL)
login_text_type = str(settings.BAYA_LOGIN_URL)
if (
other.login_url is not None and
six.text_type(other.login_url) != login_text_type
str(other.login_url) != login_text_type
):
self.login_url = other.login_url
return self
Expand Down Expand Up @@ -362,7 +362,7 @@ def __call__(self, fn, *args, **kwargs):
'Cannot decorate a bare functools.partial view. '
'You must invoke functools.update_wrapper(partial_view, '
'full_view) first.')
if not isinstance(fn, type) and isinstance(fn, collections.Callable):
if not isinstance(fn, type) and isinstance(fn, Callable):
return self.decorate_method(fn, *args, **kwargs)
elif isinstance(fn, tuple):
# Must be an include('my_app.urls') we're decorating
Expand All @@ -374,7 +374,7 @@ def __call__(self, fn, *args, **kwargs):
raise TypeError("Cannot decorate Inlines. See "
"baya.admin.options.BayaInline instead.")
return self.decorate_admin(fn, *args, **kwargs)
elif isinstance(fn, six.string_types):
elif isinstance(fn, str):
raise TypeError("Cannot decorate string-path to view: %s." % fn)
else:
# You'll probably only get here if you're trying to decorate
Expand Down
5 changes: 2 additions & 3 deletions baya/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.contenttypes',
'django_nose',
'baya',
'baya.tests',
'baya.tests.submod',
Expand Down Expand Up @@ -82,8 +81,6 @@

STATIC_URL = '/static/'

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

CSRF_USE_SESSIONS = False

MIDDLEWARE = (
Expand Down Expand Up @@ -129,3 +126,5 @@
ldap.SCOPE_SUBTREE,
"(objectClass=groupOfNames)"
)

USE_TZ = False
Loading