~django-foundations-dev/ubuntu-django-foundations/extauth

« back to all changes in this revision

Viewing changes to management/commands/updateperms.py

  • Committer: Michael Hall
  • Date: 2010-12-21 04:08:41 UTC
  • Revision ID: mhall119@gmail.com-20101221040841-ae1uxq738j35xd18
Initial code

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
'''
 
2
Copyright 2009 H. Lee Moffitt Cancer Center and Research Institute, Inc. 
 
3
All rights reserved.
 
4
 
 
5
@author: Michael Hall <mhall119@gmail.com>
 
6
'''
 
7
from django.core.management.base import NoArgsCommand, CommandError
 
8
from extauth.management import create_model_permissions
 
9
from django.contrib.auth.management import create_permissions
 
10
from django.db.models import get_app, get_apps
 
11
from django.conf import settings
 
12
from django.db import transaction
 
13
 
 
14
class Command(NoArgsCommand):
 
15
    
 
16
    def handle_noargs(self, **options):
 
17
        verbosity = int(options.pop('verbosity', 1))
 
18
        
 
19
        for app in get_apps():
 
20
            if verbosity >= 1:
 
21
                print "Updating Permissions for %s" % app.__name__
 
22
                            
 
23
            if verbosity >= 2:
 
24
                print "Creating standard permissions"
 
25
            create_permissions(app, [], verbosity, **options)
 
26
            
 
27
            if verbosity >= 2:
 
28
                print "Creating ExtAuth model permissions"
 
29
            create_model_permissions(app, [], verbosity, **options)
 
30
            
 
31