Commit dbaff0ba authored by Michael Fladischer's avatar Michael Fladischer

Update upstream source from tag 'upstream/1.3.0'

Update to upstream version '1.3.0'
with Debian dir 255cd0d1da760493eede2435048782b7e635bc12
parents e6bf1981 be6c5df2
# ----------------------------------------
# ---------------------------------------------------------------------------
# Python support matrix per Django version
#
# 2.6 1.5 1.6
# 2.7 1.5 1.6 1.7 1.8 1.9 1.10
# 2.7 1.5 1.6 1.7 1.8 1.9 1.10 1.11
# 3.3 1.5 1.6 1.7 1.8
# 3.4 1.7 1.8 1.9 1.10
# 3.5 1.8 1.9 1.10
# ----------------------------------------
# 3.4 1.7 1.8 1.9 1.10 1.11 2.0
# 3.5 1.8 1.9 1.10 1.11 2.0
# 3.6 1.10 1.11 2.0
# ---------------------------------------------------------------------------
sudo: false
language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "pypy"
- "pypy3"
env:
- DJANGO='Django<1.6' # Django 1.5
- DJANGO='Django<1.7' # Django 1.6
- DJANGO='Django<1.8' # Django 1.7
- DJANGO='Django<1.9' # Django 1.8
- DJANGO='Django<1.10' # Django 1.9
- DJANGO='Django<1.11' # Django 1.10
matrix:
exclude:
- python: "2.6"
env: DJANGO='Django<1.8'
- python: "2.6"
env: DJANGO='Django<1.9'
- python: "2.6"
env: DJANGO='Django<1.10'
- python: "2.6"
env: DJANGO='Django<1.11'
- python: "3.3"
env: DJANGO='Django<1.10'
- python: "3.3"
env: DJANGO='Django<1.11'
- python: "3.4"
env: DJANGO='Django<1.6'
- python: "3.4"
env: DJANGO='Django<1.7'
- python: "3.5"
env: DJANGO='Django<1.6'
- python: "3.5"
env: DJANGO='Django<1.7'
- python: "3.5"
env: DJANGO='Django<1.8'
- python: "pypy3"
env: DJANGO='Django<1.10'
- python: "pypy3"
env: DJANGO='Django<1.11'
include:
- { python: 2.6, env: TOXENV=py26-django15 }
- { python: 2.6, env: TOXENV=py26-django16 }
- { python: 2.7, env: TOXENV=py27-django15 }
- { python: 2.7, env: TOXENV=py27-django16 }
- { python: 2.7, env: TOXENV=py27-django17 }
- { python: 2.7, env: TOXENV=py27-django18 }
- { python: 2.7, env: TOXENV=py27-django19 }
- { python: 2.7, env: TOXENV=py27-django110 }
- { python: 2.7, env: TOXENV=py27-django111 }
- { python: 3.3, env: TOXENV=py33-django15 }
- { python: 3.3, env: TOXENV=py33-django16 }
- { python: 3.3, env: TOXENV=py33-django17 }
- { python: 3.3, env: TOXENV=py33-django18 }
- { python: 3.4, env: TOXENV=py34-django17 }
- { python: 3.4, env: TOXENV=py34-django18 }
- { python: 3.4, env: TOXENV=py34-django19 }
- { python: 3.4, env: TOXENV=py34-django110 }
- { python: 3.4, env: TOXENV=py34-django20 }
- { python: 3.4, env: TOXENV=py34-django111 }
- { python: 3.5, env: TOXENV=py35-django18 }
- { python: 3.5, env: TOXENV=py35-django19 }
- { python: 3.5, env: TOXENV=py35-django110 }
- { python: 3.5, env: TOXENV=py35-django111 }
- { python: 3.5, env: TOXENV=py35-django20 }
- { python: 3.6, env: TOXENV=py36-django110 }
- { python: 3.6, env: TOXENV=py36-django111 }
- { python: 3.6, env: TOXENV=py36-django20 }
install:
- 'pip install "${DJANGO}"'
- pip install coveralls
- pip install -e .
script: ./runtests.sh -v
- pip install tox
script: tox
after_success:
- coveralls
Changelog
=========
## v1.3.0 - 2017/12/13
- Added support for Django 2.0
- Added support for Django 1.11 and Python 3.6
- Dropped support for PyPy and PyPy3
## v1.2.1 - 2017/05/13
- Reverted "Fixed undesired caching in `is_group_member` factory"
## v1.2.0 - 2016/12/18
- Added logging to predicates
- Added support for Django 1.10
- Fixed undesired caching in `is_group_member` factory
## v1.1.1 - 2015/12/07
- Improved handling of skipped predicates
## v1.1.0 - 2015/12/05
- Fixed regression that wouldn't short-circuit boolean expressions
- Added support for Django 1.9 and Python 3.5
- Added support for skipping predicates simply by returning `None`.
The previous way of skipping predicates by raising `SkipPredicate`
has been deprecated and will not be supported in a future release.
## v1.0.0 - 2015/10/06
- Initial stable public release
- Dropped support for Python 3.2
- Added Django test suite
- Added function-based view decorator
- Added class-based view mixin
## v0.4 - 2015/02/16
- Added support for creating predicates from partial functions
- Added support for creating predicates from instance methods
- Added predicate invocation context
- Added support for automatically passing `self` to a predicate
- Added support for discarding a predicate's result
## v0.3 - 2014/10/15
- Added compatibility with PyPy and PyPy 3
- Added `always_true()` and `always_false()` predicates
- Added integration with Tox
- Bug fixes
## v0.2 - 2014/06/09
- Added compatibility with Python 3.4
- Improved admin integration
## v0.1 - 2014/03/07
- Initial public release
include CHANGELOG.md
include INSTALL
include LICENSE
include README.rst
......
......@@ -70,7 +70,6 @@ Table of Contents
- `Best practices`_
- `API Reference`_
- `Changelog`_
- `Licence`_
......@@ -912,55 +911,6 @@ Managing the permissions rule set
Tests the rule with the given name. See ``RuleSet.test_rule``.
Changelog
=========
``v1.2.1`` - 2017/05/13
- Reverted "Fixed undesired caching in `is_group_member` factory"
``v1.2.0`` - 2016/12/18
- Added logging to predicates
- Added support for Django 1.10
- Fixed undesired caching in `is_group_member` factory
``v1.1.1`` - 2015/12/07
- Improved handling of skipped predicates
``v1.1.0`` - 2015/12/05
- Fixed regression that wouldn't short-circuit boolean expressions
- Added support for Django 1.9 and Python 3.5
- Added support for skipping predicates simply by returning ``None``.
The previous way of skipping predicates by raising ``SkipPredicate``
has been deprecated and will not be supported in a future release.
``v1.0.0`` - 2015/10/06
- Initial stable public release
- Dropped support for Python 3.2
- Added Django test suite
- Added function-based view decorator
- Added class-based view mixin
``v0.4`` - 2015/02/16
- Added support for creating predicates from partial functions
- Added support for creating predicates from instance methods
- Added predicate invocation context
- Added support for automatically passing ``self`` to a predicate
- Added support for discarding a predicate's result
``v0.3`` - 2014/10/15
- Added compatibility with PyPy and PyPy 3
- Added ``always_true()`` and ``always_false()`` predicates
- Added integration with Tox
- Bug fixes
``v0.2`` - 2014/06/09
- Added compatibility with Python 3.4
- Improved admin integration
``v0.1`` - 2014/03/07
- Initial public release
Licence
=======
......
......@@ -4,6 +4,6 @@ from .predicates import (Predicate, predicate, always_true, always_false,
always_allow, always_deny, is_authenticated,
is_superuser, is_staff, is_active, is_group_member)
VERSION = (1, 2, 1, 'final', 1)
VERSION = (1, 3, 0, 'final', 1)
default_app_config = 'rules.apps.RulesConfig'
......@@ -219,7 +219,7 @@ class Predicate(object):
result = None if result is None else bool(result)
except SkipPredicate:
result = None
logger.debug(' %s = %s', self, 'skipped' if result is None else result)
return result
......
......@@ -4,14 +4,19 @@ from ..rulesets import default_rules
register = template.Library()
try:
# Django < 2.0
simple_tag = register.assignment_tag
except AttributeError: # pragma: no cover
simple_tag = register.simple_tag
@register.assignment_tag
@simple_tag
def test_rule(name, obj=None, target=None):
return default_rules.test_rule(name, obj, target)
@register.assignment_tag
@simple_tag
def has_perm(perm, user, obj=None):
if not hasattr(user, 'has_perm'): # pragma: no cover
return False # swapped user model that doesn't support permissions
......
......@@ -74,5 +74,6 @@ setup(
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
)
......@@ -7,7 +7,7 @@ from django.utils.encoding import python_2_unicode_compatible
class Book(models.Model):
isbn = models.CharField(max_length=50, unique=True)
title = models.CharField(max_length=100)
author = models.ForeignKey(settings.AUTH_USER_MODEL)
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
def __str__(self):
return self.title
......@@ -26,12 +26,15 @@ INSTALLED_APPS = [
'testapp',
]
MIDDLEWARE_CLASSES = [
MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
]
# Django < 2.0
MIDDLEWARE_CLASSES = MIDDLEWARE
AUTHENTICATION_BACKENDS = [
'rules.permissions.ObjectPermissionBackend',
'django.contrib.auth.backends.ModelBackend',
......
from django.conf.urls import include, url
from django.conf.urls import url
from django.contrib import admin
from .views import (change_book, delete_book,
......@@ -8,7 +8,7 @@ from .views import (change_book, delete_book,
admin.autodiscover()
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', admin.site.urls),
# Function-based views
url(r'^(?P<book_id>\d+)/change/$', change_book, name='change_book'),
......
from django.core.urlresolvers import reverse
from django.test import TestCase
try:
from django.urls import reverse
except ImportError:
# django < 1.10
from django.core.urlresolvers import reverse
try:
from django.urls import reverse
except ImportError:
# Django < 2.0
from django.core.urlresolvers import reverse
class ModelAdminTests(TestCase):
......
from __future__ import absolute_import
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django.http import HttpRequest, Http404
from django.test import TestCase
from django.utils.encoding import force_str
try:
from django.urls import reverse
except ImportError:
# Django < 2.0
from django.core.urlresolvers import reverse
from rules.contrib.views import objectgetter
from testapp.models import Book
......
[tox]
envlist =
{py26}-django{15,16},
{py27}-django{15,16,17,18,19,110},
{py27}-django{15,16,17,18,19,110,111},
{py33}-django{15,16,17,18},
{py34}-django{17,18,19,110},
{py35}-django{18,19,110},
{pypy}-django{15,16,17,18,19,110},
{pypy3}-django{15,16,17,18}
{py34}-django{17,18,19,110,111,20},
{py35}-django{18,19,110,111,20},
{py36}-django{110,111,20}
[testenv]
deps =
nose
coverage
django15: Django>=1.5,<1.6
django16: Django>=1.6,<1.7
django17: Django>=1.7,<1.8
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
django111: Django>=1.11,<1.12
django20: Django>=2.0,<2.1
commands =
{envbindir}/python runtests.py --nologcapture --nocapture {posargs}
coverage run --source=rules runtests.py --nologcapture --nocapture {posargs}
coverage report -m
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment