-
Notifications
You must be signed in to change notification settings - Fork 1
/
loadFixtures.py
executable file
·59 lines (50 loc) · 1.21 KB
/
loadFixtures.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from os import system
fixtures = ()
"""
'auth.yaml',
'member.yaml',
'publications.yaml',
'events.yaml',
)
"""
###########
# CLEAN
###########
# clean everything
print '=> Cleaning everything ...'
system('rm db.sqlite3')
system('rm ../db.sqlite3')
print '=> Done'
###########
# CONF DB
###########
# sync db
print '=> Sync db + migrate'
system('python manage.py syncdb --noinput')
system('./manage.py migrate')
print '=> Done'
###########
# ADD DATA
###########
# create super user
print '=> Creating super user ...'
code = (
"from django.contrib.auth.models import User",
"user = User.objects.create_superuser('Nodraak', '[email protected]', 'mdp')",
)
system('echo "%s" | ./manage.py shell' % '\n'.join(code))
print '=> Done'
# load data
print '=> Loading fixtures ...'
for fixture in fixtures:
print '=> %s :' % fixture
system('python manage.py loaddata %s' % fixture)
print '=> Done'
print '=> Loading data from old website'
system('./manage.py loaddata prod/f_auth.yaml')
system('./manage.py loaddata prod/f_member.yaml')
system('./manage.py loaddata prod/f_pub.yaml')
print '=> Done'
print '#####\n# TODO : Creer un profil pour Nodraak\n#####'