diff --git a/separate_users/management/commands/fix_proxy_permissions.py b/separate_users/management/commands/fix_proxy_permissions.py index d43dfe6..244891c 100644 --- a/separate_users/management/commands/fix_proxy_permissions.py +++ b/separate_users/management/commands/fix_proxy_permissions.py @@ -1,3 +1,4 @@ +import inspect import sys from django.contrib.auth.management import _get_all_permissions @@ -10,6 +11,7 @@ # where this comes from: https://gist.github.com/magopian/7543724#gistcomment-2185491 # as django adds permissions for proxy models in another app for the proxies parent # also, epic: https://code.djangoproject.com/ticket/11154 +# also: https://stackoverflow.com/questions/38391729/how-to-retrieve-all-permissions-of-a-specific-model-in-django class Command(BaseCommand): help = "Fix permissions for proxy models." @@ -21,7 +23,13 @@ def handle(self, *args, **options): app_label=opts.app_label, model=opts.object_name.lower()) - for codename, name in _get_all_permissions(opts): + argspecs = inspect.getargspec(_get_all_permissions) + if len(argspecs[0]) == 2: + # django < 1.10 + all_permissions = _get_all_permissions(opts, ctype) + else: + all_permissions = _get_all_permissions(opts) + for codename, name in all_permissions: sys.stdout.write(' --{}\n'.format(codename)) p, created = Permission.objects.get_or_create( codename=codename, diff --git a/separate_users/tests/test_admin.py b/separate_users/tests/test_admin.py index a54e7e7..05e2684 100644 --- a/separate_users/tests/test_admin.py +++ b/separate_users/tests/test_admin.py @@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- -from django.test import override_settings +# from django.test import override_settings from django.test.testcases import TestCase -from django.urls import reverse +try: + from django.urls import reverse +except ImportError: + from django.core.urlresolvers import reverse from separate_users.models import Editor, FrontendUser from separate_users.tests.utils.django_utils import create_superuser diff --git a/setup.py b/setup.py index 386d682..17b76dc 100755 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def read(fname): packages=find_packages(), install_requires=( # 'Django>=1.3,<1.5', # no need to limit while in development - 'Django>=1.11', + 'Django>=1.8', ), include_package_data=True, zip_safe=False, diff --git a/tox.ini b/tox.ini index 655e28e..e9a6595 100644 --- a/tox.ini +++ b/tox.ini @@ -16,20 +16,20 @@ deps = [testenv:django18] deps = - django>=1.8, <1.9 {[base]deps} + django>=1.8, <1.9 [testenv:django19] deps = - django>=1.9, <1.10 {[base]deps} + django>=1.9, <1.10 [testenv:django110] deps = - django>=1.10, <1.11 {[base]deps} + django>=1.10, <1.11 [testenv:django111] deps = + {[base]deps} django>=1.11, <1.12 - {[base]deps} \ No newline at end of file