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 # Python support matrix per Django version
# #
# 2.6 1.5 1.6 # 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.3 1.5 1.6 1.7 1.8
# 3.4 1.7 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 # 3.5 1.8 1.9 1.10 1.11 2.0
# ---------------------------------------- # 3.6 1.10 1.11 2.0
# ---------------------------------------------------------------------------
sudo: false sudo: false
language: python 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: matrix:
exclude: include:
- python: "2.6" - { python: 2.6, env: TOXENV=py26-django15 }
env: DJANGO='Django<1.8' - { python: 2.6, env: TOXENV=py26-django16 }
- python: "2.6" - { python: 2.7, env: TOXENV=py27-django15 }
env: DJANGO='Django<1.9' - { python: 2.7, env: TOXENV=py27-django16 }
- python: "2.6" - { python: 2.7, env: TOXENV=py27-django17 }
env: DJANGO='Django<1.10' - { python: 2.7, env: TOXENV=py27-django18 }
- python: "2.6" - { python: 2.7, env: TOXENV=py27-django19 }
env: DJANGO='Django<1.11' - { python: 2.7, env: TOXENV=py27-django110 }
- python: "3.3" - { python: 2.7, env: TOXENV=py27-django111 }
env: DJANGO='Django<1.10' - { python: 3.3, env: TOXENV=py33-django15 }
- python: "3.3" - { python: 3.3, env: TOXENV=py33-django16 }
env: DJANGO='Django<1.11' - { python: 3.3, env: TOXENV=py33-django17 }
- python: "3.4" - { python: 3.3, env: TOXENV=py33-django18 }
env: DJANGO='Django<1.6' - { python: 3.4, env: TOXENV=py34-django17 }
- python: "3.4" - { python: 3.4, env: TOXENV=py34-django18 }
env: DJANGO='Django<1.7' - { python: 3.4, env: TOXENV=py34-django19 }
- python: "3.5" - { python: 3.4, env: TOXENV=py34-django110 }
env: DJANGO='Django<1.6' - { python: 3.4, env: TOXENV=py34-django20 }
- python: "3.5" - { python: 3.4, env: TOXENV=py34-django111 }
env: DJANGO='Django<1.7' - { python: 3.5, env: TOXENV=py35-django18 }
- python: "3.5" - { python: 3.5, env: TOXENV=py35-django19 }
env: DJANGO='Django<1.8' - { python: 3.5, env: TOXENV=py35-django110 }
- python: "pypy3" - { python: 3.5, env: TOXENV=py35-django111 }
env: DJANGO='Django<1.10' - { python: 3.5, env: TOXENV=py35-django20 }
- python: "pypy3" - { python: 3.6, env: TOXENV=py36-django110 }
env: DJANGO='Django<1.11' - { python: 3.6, env: TOXENV=py36-django111 }
- { python: 3.6, env: TOXENV=py36-django20 }
install: install:
- 'pip install "${DJANGO}"' - pip install tox
- pip install coveralls script: tox
- pip install -e .
script: ./runtests.sh -v
after_success: after_success:
- coveralls - 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 INSTALL
include LICENSE include LICENSE
include README.rst include README.rst
......
...@@ -70,7 +70,6 @@ Table of Contents ...@@ -70,7 +70,6 @@ Table of Contents
- `Best practices`_ - `Best practices`_
- `API Reference`_ - `API Reference`_
- `Changelog`_
- `Licence`_ - `Licence`_
...@@ -912,55 +911,6 @@ Managing the permissions rule set ...@@ -912,55 +911,6 @@ Managing the permissions rule set
Tests the rule with the given name. See ``RuleSet.test_rule``. 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 Licence
======= =======
......
...@@ -4,6 +4,6 @@ from .predicates import (Predicate, predicate, always_true, always_false, ...@@ -4,6 +4,6 @@ from .predicates import (Predicate, predicate, always_true, always_false,
always_allow, always_deny, is_authenticated, always_allow, always_deny, is_authenticated,
is_superuser, is_staff, is_active, is_group_member) 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' default_app_config = 'rules.apps.RulesConfig'
...@@ -219,7 +219,7 @@ class Predicate(object): ...@@ -219,7 +219,7 @@ class Predicate(object):
result = None if result is None else bool(result) result = None if result is None else bool(result)
except SkipPredicate: except SkipPredicate:
result = None result = None
logger.debug(' %s = %s', self, 'skipped' if result is None else result) logger.debug(' %s = %s', self, 'skipped' if result is None else result)
return result return result
......
...@@ -4,14 +4,19 @@ from ..rulesets import default_rules ...@@ -4,14 +4,19 @@ from ..rulesets import default_rules
register = template.Library() 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): def test_rule(name, obj=None, target=None):
return default_rules.test_rule(name, obj, target) return default_rules.test_rule(name, obj, target)
@register.assignment_tag @simple_tag
def has_perm(perm, user, obj=None): def has_perm(perm, user, obj=None):
if not hasattr(user, 'has_perm'): # pragma: no cover if not hasattr(user, 'has_perm'): # pragma: no cover
return False # swapped user model that doesn't support permissions return False # swapped user model that doesn't support permissions
......
...@@ -74,5 +74,6 @@ setup( ...@@ -74,5 +74,6 @@ setup(
'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
], ],
) )
...@@ -7,7 +7,7 @@ from django.utils.encoding import python_2_unicode_compatible ...@@ -7,7 +7,7 @@ from django.utils.encoding import python_2_unicode_compatible
class Book(models.Model): class Book(models.Model):
isbn = models.CharField(max_length=50, unique=True) isbn = models.CharField(max_length=50, unique=True)
title = models.CharField(max_length=100) 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): def __str__(self):
return self.title return self.title
...@@ -26,12 +26,15 @@ INSTALLED_APPS = [ ...@@ -26,12 +26,15 @@ INSTALLED_APPS = [
'testapp', 'testapp',
] ]
MIDDLEWARE_CLASSES = [ MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
] ]
# Django < 2.0
MIDDLEWARE_CLASSES = MIDDLEWARE
AUTHENTICATION_BACKENDS = [ AUTHENTICATION_BACKENDS = [
'rules.permissions.ObjectPermissionBackend', 'rules.permissions.ObjectPermissionBackend',
'django.contrib.auth.backends.ModelBackend', 'django.contrib.auth.backends.ModelBackend',
......
from django.conf.urls import include, url from django.conf.urls import url
from django.contrib import admin from django.contrib import admin
from .views import (change_book, delete_book, from .views import (change_book, delete_book,
...@@ -8,7 +8,7 @@ from .views import (change_book, delete_book, ...@@ -8,7 +8,7 @@ from .views import (change_book, delete_book,
admin.autodiscover() admin.autodiscover()
urlpatterns = [ urlpatterns = [
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', admin.site.urls),
# Function-based views # Function-based views
url(r'^(?P<book_id>\d+)/change/$', change_book, name='change_book'), url(r'^(?P<book_id>\d+)/change/$', change_book, name='change_book'),
......
from django.core.urlresolvers import reverse
from django.test import TestCase 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): class ModelAdminTests(TestCase):
......
from __future__ import absolute_import from __future__ import absolute_import
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django.http import HttpRequest, Http404 from django.http import HttpRequest, Http404
from django.test import TestCase from django.test import TestCase
from django.utils.encoding import force_str 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 rules.contrib.views import objectgetter
from testapp.models import Book from testapp.models import Book
......
[tox] [tox]
envlist = envlist =
{py26}-django{15,16}, {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}, {py33}-django{15,16,17,18},
{py34}-django{17,18,19,110}, {py34}-django{17,18,19,110,111,20},
{py35}-django{18,19,110}, {py35}-django{18,19,110,111,20},
{pypy}-django{15,16,17,18,19,110}, {py36}-django{110,111,20}
{pypy3}-django{15,16,17,18}
[testenv] [testenv]
deps = deps =
nose nose
coverage
django15: Django>=1.5,<1.6 django15: Django>=1.5,<1.6
django16: Django>=1.6,<1.7 django16: Django>=1.6,<1.7
django17: Django>=1.7,<1.8 django17: Django>=1.7,<1.8
django18: Django>=1.8,<1.9 django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10 django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11 django110: Django>=1.10,<1.11
django111: Django>=1.11,<1.12
django20: Django>=2.0,<2.1
commands = 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