Add further auto admin creation cleanups

This commit is contained in:
Roberto Rosario
2012-01-07 23:33:31 -04:00
parent c7ee18af85
commit 85875be859

View File

@@ -33,19 +33,19 @@ register_links(['about_view', 'changelog_view', 'license_view'], [about_view, ch
register_top_menu('about', link={'text': _(u'about'), 'view': 'about_view', 'famfam': 'information'}, position=-1)
#if common_settings.AUTO_CREATE_ADMIN:
# # From https://github.com/lambdalisue/django-qwert/blob/master/qwert/autoscript/__init__.py
# # From http://stackoverflow.com/questions/1466827/ --
# #
# # Prevent interactive question about wanting a superuser created. (This code
# # has to go in this otherwise empty "models" module so that it gets processed by
# # the "syncdb" command during database creation.)
# #
# # Create our own admin super user automatically.
@receiver(post_syncdb, dispatch_uid='create_superuser', sender=auth_models)
#def create_superuser(app, created_models, verbosity, **kwargs):
def create_superuser(sender, **kwargs):
"""
From https://github.com/lambdalisue/django-qwert/blob/master/qwert/autoscript/__init__.py
From http://stackoverflow.com/questions/1466827/ --
Prevent interactive question about wanting a superuser created. (This code
has to go in this otherwise empty "models" module so that it gets processed by
the "syncdb" command during database creation.)
Create our own admin super user automatically.
"""
if common_settings.AUTO_CREATE_ADMIN:
USERNAME = common_settings.AUTO_ADMIN_USERNAME
PASSWORD = common_settings.AUTO_ADMIN_PASSWORD
@@ -58,12 +58,6 @@ def create_superuser(sender, **kwargs):
assert auth_models.User.objects.create_superuser(USERNAME, 'x@x.com', PASSWORD)
else:
print 'Super admin user already exists. -- login: %s, password: %s' % (USERNAME, PASSWORD)
#signals.post_syncdb.disconnect(
# create_superuser,
# sender=auth_models,
# dispatch_uid='django.contrib.auth.management.create_superuser')
#signals.post_syncdb.connect(create_testuser,
# sender=auth_models, dispatch_uid='common.models.create_testuser')
if (validate_path(common_settings.TEMPORARY_DIRECTORY) == False) or (not common_settings.TEMPORARY_DIRECTORY):
setattr(common_settings, 'TEMPORARY_DIRECTORY', tempfile.mkdtemp())