forked from pedrogaudencio/kiosks-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
executable file
·34 lines (27 loc) · 1.14 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
from django.conf import settings
from django.contrib.auth import models as auth_models
from django.contrib.auth.management import create_superuser
from django.db.models import signals
# 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.)
signals.post_syncdb.disconnect(
create_superuser,
sender=auth_models,
dispatch_uid='django.contrib.auth.management.create_superuser')
# Create our own test user automatically.
def create_testuser(app, created_models, verbosity, **kwargs):
if not settings.DEBUG:
return
try:
auth_models.User.objects.get(username='admin')
except auth_models.User.DoesNotExist:
print '*' * 80
print 'Creating users...'
print '*' * 80
assert auth_models.User.objects.create_superuser('admin', 'admin@iifa.pt', 'qwerty')
signals.post_syncdb.connect(create_testuser,
sender=auth_models, dispatch_uid='common.models.create_testuser')