make sure superusers is admin is nobody is

This commit is contained in:
j 2012-03-06 16:25:06 +01:00
parent 5a79659bb3
commit 6ab6ec541e

View file

@ -41,6 +41,11 @@ def load_config():
settings.CONFIG = config settings.CONFIG = config
admin = len(settings.CONFIG['userLevels']) - 1 admin = len(settings.CONFIG['userLevels']) - 1
if not 'syncdb' in sys.argv and not 'sqldiff' in sys.argv: if not 'syncdb' in sys.argv and not 'sqldiff' in sys.argv:
if User.objects.filter(profile__level=admin).count() == 0:
for u in User.objects.filter(is_superuser=True):
p = u.get_profile()
p.level = admin
p.save()
settings.ADMIN = tuple([(u.username, u.email) settings.ADMIN = tuple([(u.username, u.email)
for u in User.objects.filter(profile__level=admin)]) for u in User.objects.filter(profile__level=admin)])
settings.MANAGERS = settings.ADMINS settings.MANAGERS = settings.ADMINS