diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-11-14 15:56:20 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-11-14 15:56:20 -0500 |
commit | 3fe4b2189cd4c9741eebc0fa6ac131a5663be535 (patch) | |
tree | e39105cd1c159e2a71b7302409c5b6de5a821dbe /devel/management | |
parent | ea04e4b3da76bbb74ec895a4995c6c2388146164 (diff) | |
parent | 604c748f8f8dee5e51e2ea5937d1be0b60fb0e7b (diff) |
Merge commit '604c748' (update)
Diffstat (limited to 'devel/management')
-rw-r--r-- | devel/management/commands/update_types_permissions.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/devel/management/commands/update_types_permissions.py b/devel/management/commands/update_types_permissions.py new file mode 100644 index 00000000..bbe8dc47 --- /dev/null +++ b/devel/management/commands/update_types_permissions.py @@ -0,0 +1,25 @@ +from django.core.management.base import BaseCommand +from django.db.models import get_models, get_app +from django.contrib.auth.management import create_permissions +from django.contrib.contenttypes.management import update_contenttypes + + +class Command(BaseCommand): + args = '<app app ...>' + help = 'reloads permissions for specified apps, or all apps if no args are specified' + + def handle(self, *args, **options): + if not args: + apps = [] + for model in get_models(): + apps.append(get_app(model._meta.app_label)) + else: + apps = [] + for arg in args: + apps.append(get_app(arg)) + + for app in apps: + update_contenttypes(app, None, options.get('verbosity', 2), interactive=True) + create_permissions(app, get_models(), options.get('verbosity', 0)) + +# vim: set ts=4 sw=4 et: |