summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-12-05 23:10:44 -0600
committerDan McGee <dan@archlinux.org>2011-12-05 23:10:44 -0600
commit94c5bda1c13960f8626b3c8e8ec47d9e3005f792 (patch)
tree8b4e0dd30df725f980ff3714bd3e38f7fe66b372
parent09e7d2706e9b15da7d566c6156b68f96dab25320 (diff)
downloadarchweb-94c5bda1c13960f8626b3c8e8ec47d9e3005f792.tar.gz
archweb-94c5bda1c13960f8626b3c8e8ec47d9e3005f792.zip
Add a stub admin command to help fix permissions/content types
I needed this today to get the application working from scratch on another host. Probably not all there yet, but we'll see how far it gets us. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--devel/management/commands/update_types_permissions.py25
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: