示例#1
0
def contacts(db):
    for c in TEST_CONTACTS:
        # create some contacts
        contact = Contact()
        contact.name = c[0]
        contact.url = c[1]
        contact.image = c[2]
        contact.social = c[3]
        contact.nicks = [Nick(name=n) for n in c[4]]
        db.session.add(contact)
    db.session.commit()
示例#2
0
def contacts(db):
    for c in TEST_CONTACTS:
        # create some contacts
        contact = Contact()
        contact.name = c[0]
        contact.url = c[1]
        contact.image = c[2]
        contact.social = c[3]
        contact.nicks = [Nick(name=n) for n in c[4]]
        db.session.add(contact)
    db.session.commit()
示例#3
0
from redwind.models import Contact, Nick, AddressBook
from redwind import db
from redwind.util import filter_empty_keys

for name, entry in AddressBook().entries.items():
    contact = Contact()
    contact.name = name
    contact.image = entry.get('photo')
    contact.url = entry.get('url')
    contact.social = filter_empty_keys({
        'twitter': entry.get('twitter'),
        'facebook': entry.get('facebook')
    })
    if 'twitter' in entry:
        nick = Nick()
        nick.name = entry.get('twitter')
        contact.nicks = [nick]
        db.session.add(nick)
    db.session.add(contact)

db.session.commit()
示例#4
0
from redwind.models import Contact, Nick, AddressBook
from redwind import db
from redwind.util import filter_empty_keys


for name, entry in AddressBook().entries.items():
    contact = Contact()
    contact.name = name
    contact.image = entry.get('photo')
    contact.url = entry.get('url')
    contact.social = filter_empty_keys(
        {'twitter': entry.get('twitter'), 'facebook': entry.get('facebook')})
    if 'twitter' in entry:
        nick = Nick()
        nick.name = entry.get('twitter')
        contact.nicks = [nick]
        db.session.add(nick)
    db.session.add(contact)

db.session.commit()