forked from leah/django-elsewhere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
management.py
33 lines (26 loc) · 1019 Bytes
/
management.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
from django.db.models import signals
from elsewhere.default_list import *
from elsewhere.models import SocialNetwork, InstantMessenger
# this function will fill the database with default data (stored in default_lists.py)
def fill_db(sender=None, **kwargs):
for item in default_social_networks: # fill social networks
if item.has_key('identifier'):
ident = item['identifier']
else:
ident = ''
SocialNetwork.objects.get_or_create(name=item['name'], defaults={
'url': item['url'],
'identifier': ident,
'icon': item['icon']
})
for item in default_im_networks: # fill IM networks
if item.has_key('identifier'):
ident = item['identifier']
else:
ident = ''
InstantMessenger.objects.get_or_create(name=item['name'], defaults={
'url': item['url'],
'identifier': ident,
'icon': item['icon']
})
signals.post_syncdb.connect(fill_db)