Ticket #9057: 9057.2.patch

File 9057.2.patch, 1.2 KB (added by hvendelbo, 7 years ago)

Check settings before creating permissions and superuser

  • django/contrib/auth/management/__init__.py

    a b Creates permissions for all installed apps that need permissions. 
    44
    55from django.db.models import get_models, signals
    66from django.contrib.auth import models as auth_app
     7from django.conf import settings
    78
    89def _get_permission_codename(action, opts):
    910    return u'%s_%s' % (action, opts.object_name.lower())
    def create_superuser(app, created_models, verbosity, **kwargs): 
    4445                call_command("createsuperuser", interactive=True)
    4546            break
    4647
    47 signals.post_syncdb.connect(create_permissions,
    48     dispatch_uid = "django.contrib.auth.management.create_permissions")
    49 signals.post_syncdb.connect(create_superuser,
    50     sender=auth_app, dispatch_uid = "django.contrib.auth.management.create_superuser")
     48if settings.AUTH_AUTO_CREATE_PERMISSIONS:
     49    signals.post_syncdb.connect(create_permissions,
     50        dispatch_uid = "django.contrib.auth.management.create_permissions")
     51if settings.AUTH_AUTO_CREATE_SUPERUSER:
     52    signals.post_syncdb.connect(create_superuser,
     53        sender=auth_app, dispatch_uid = "django.contrib.auth.management.create_superuser")
Back to Top