Ticket #2333: contrib.patch

File contrib.patch, 3.2 KB (added by Russell Keith-Magee, 18 years ago)

Changes to the django.contrib package

  • contrib/contenttypes/management.py

     
    55from django.dispatch import dispatcher
    66from django.db.models import get_models, signals
    77
    8 def create_contenttypes(app, created_models):
     8def create_contenttypes(app, created_models, verbosity, interactive):
    99    from django.contrib.contenttypes.models import ContentType
    1010    app_models = get_models(app)
    1111    if not app_models:
     
    1919            ct = ContentType(name=str(opts.verbose_name),
    2020                app_label=opts.app_label, model=opts.object_name.lower())
    2121            ct.save()
    22             print "Adding content type '%s | %s'" % (ct.app_label, ct.model)
     22            if verbosity >= 2:
     23                print "Adding content type '%s | %s'" % (ct.app_label, ct.model)
    2324
    2425dispatcher.connect(create_contenttypes, signal=signals.post_syncdb)
  • contrib/auth/management.py

     
    1616        perms.append((_get_permission_codename(action, opts), 'Can %s %s' % (action, opts.verbose_name)))
    1717    return perms + list(opts.permissions)
    1818
    19 def create_permissions(app, created_models):
     19def create_permissions(app, created_models, verbosity, interactive):
    2020    from django.contrib.contenttypes.models import ContentType
    2121    from django.contrib.auth.models import Permission
    2222    app_models = get_models(app)
     
    2727        for codename, name in _get_all_permissions(klass._meta):
    2828            p, created = Permission.objects.get_or_create(codename=codename, content_type__pk=ctype.id,
    2929                defaults={'name': name, 'content_type': ctype})
    30             if created:
     30            if created and verbosity >= 2:
    3131                print "Adding permission '%s'" % p
    3232
    33 def create_superuser(app, created_models):
     33def create_superuser(app, created_models, verbosity, interactive):
    3434    from django.contrib.auth.models import User
    3535    from django.contrib.auth.create_superuser import createsuperuser as do_create
    36     if User in created_models:
     36    if User in created_models and interactive:
    3737        msg = "\nYou just installed Django's auth system, which means you don't have " \
    3838                "any superusers defined.\nWould you like to create one now? (yes/no): "
    3939        confirm = raw_input(msg)
  • contrib/sites/management.py

     
    77from django.contrib.sites.models import Site
    88from django.contrib.sites import models as site_app
    99
    10 def create_default_site(app, created_models):
     10def create_default_site(app, created_models, verbosity, interactive):
    1111    if Site in created_models:
    12         print "Creating example.com Site object"
     12        if verbosity >= 2:
     13            print "Creating example.com Site object"
    1314        s = Site(domain="example.com", name="example.com")
    1415        s.save()
    1516
Back to Top