Source

django-extauth / extauth / management / commands / updateperms.py

'''
Copyright 2009 H. Lee Moffitt Cancer Center and Research Institute, Inc. 
All rights reserved.

@author: Michael Hall <mhall119@gmail.com>
'''
from django.core.management.base import NoArgsCommand, CommandError
from extauth.management import create_model_permissions
from django.contrib.auth.management import create_permissions
from django.db.models import get_app, get_apps
from django.conf import settings
from django.db import transaction

class Command(NoArgsCommand):
    
    def handle_noargs(self, **options):
        verbosity = int(options.pop('verbosity', 1))
        
        for app in get_apps():
            if verbosity >= 1:
                print "Updating Permissions for %s" % app.__name__
                            
            if verbosity >= 2:
                print "Creating standard permissions"
            create_permissions(app, [], verbosity, **options)
            
            if verbosity >= 2:
                print "Creating ExtAuth model permissions"
            create_model_permissions(app, [], verbosity, **options)