Skip to content

Commit

Permalink
django 1.8/1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
benzkji committed Nov 5, 2017
1 parent 18669ec commit 893294e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
10 changes: 9 additions & 1 deletion separate_users/management/commands/fix_proxy_permissions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
import sys

from django.contrib.auth.management import _get_all_permissions
Expand All @@ -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."

Expand All @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions separate_users/tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit 893294e

Please sign in to comment.