summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-04-16 02:07:35 -0400
committerLuke Shumaker <lukeshu@parabola.nu>2018-01-15 13:34:42 -0500
commit8a08dedf59ac5be029bc824cc5ed0c81cc2f63ea (patch)
tree3fbf8a12cf356865a19d883ecd92a3e27bc89974
parentca5701c15f341047efc2a956a5821dc22a431b91 (diff)
Update update_types_permissions to work with Django 1.7 and up.
Django commit 00110904ac67050c639f93cfd7b5e19218b changed the signatures of update_contenttypes and create_permissions. The relevant lines from the commit are: -def update_contenttypes(app, created_models, verbosity=2, db=DEFAULT_DB_ALIAS, **kwargs): +def update_contenttypes(app_config, verbosity=2, interactive=True, db=DEFAULT_DB_ALIAS, **kwargs): -def create_permissions(app, created_models, verbosity, db=DEFAULT_DB_ALIAS, **kwargs): +def create_permissions(app_config, verbosity=22, interactive=True, db=DEFAULT_DB_ALIAS, **kwargs):
-rw-r--r--devel/management/commands/update_types_permissions.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/devel/management/commands/update_types_permissions.py b/devel/management/commands/update_types_permissions.py
index bbe8dc47..ac8fcfa5 100644
--- a/devel/management/commands/update_types_permissions.py
+++ b/devel/management/commands/update_types_permissions.py
@@ -1,5 +1,5 @@
from django.core.management.base import BaseCommand
-from django.db.models import get_models, get_app
+from django.apps import apps
from django.contrib.auth.management import create_permissions
from django.contrib.contenttypes.management import update_contenttypes
@@ -10,16 +10,14 @@ class Command(BaseCommand):
def handle(self, *args, **options):
if not args:
- apps = []
- for model in get_models():
- apps.append(get_app(model._meta.app_label))
+ app_configs = apps.get_app_configs()
else:
- apps = []
+ app_configs = []
for arg in args:
- apps.append(get_app(arg))
+ apps.append(apps.get_app_config(arg))
- for app in apps:
- update_contenttypes(app, None, options.get('verbosity', 2), interactive=True)
- create_permissions(app, get_models(), options.get('verbosity', 0))
+ for app_config in app_configs:
+ update_contenttypes(app_config, options.get('verbosity', 2))
+ create_permissions(app_config, options.get('verbosity', 22))
# vim: set ts=4 sw=4 et: