Exemplo n.º 1
0
def migrate_address(doc):
    from locations.models import Address, Country
    from accounts.models import Account
    from users.models import Profile
    from utils import utils
    add = Address()
    add.type = 'user'
    add.profile = Profile.objects.get(primary_phone=doc['mobile'])
    add.name = doc.get('deliveryName','')
    add.phone = doc.get('deliveryPhone','')
    add.pincode = doc.get('pincode2','')
    if doc.get('address2','').strip():
        add.address = doc.get('address2','')
    if doc.get('country2','').strip():
        add.country = utils.get_or_create_country(doc.get('country2',''))
    else:
        add.country = Country.objects.get(name='India')
    if doc.get('state2','').strip():
        add.state = utils.get_or_create_state(doc.get('state2',''), add.country, True)
        if doc.get('city2', ''):
            add.city = utils.get_or_create_city(doc.get('city2',''), add.state, True)
    try:
        if add.address and add.city and add.country and add.state and add.profile:
            add.save()
            amap = AddressMap(address=add)
            amap.save()
    except Exception, e:
        print repr(e)
Exemplo n.º 2
0
def migrate_address(doc):
    from locations.models import Address, Country
    from accounts.models import Account
    from users.models import Profile
    from utils import utils
    add = Address()
    add.type = 'user'
    add.profile = Profile.objects.get(primary_phone=doc['mobile'])
    add.name = doc.get('deliveryName', '')
    add.phone = doc.get('deliveryPhone', '')
    add.pincode = doc.get('pincode2', '')
    if doc.get('address2', '').strip():
        add.address = doc.get('address2', '')
    if doc.get('country2', '').strip():
        add.country = utils.get_or_create_country(doc.get('country2', ''))
    else:
        add.country = Country.objects.get(name='India')
    if doc.get('state2', '').strip():
        add.state = utils.get_or_create_state(doc.get('state2', ''),
                                              add.country, True)
        if doc.get('city2', ''):
            add.city = utils.get_or_create_city(doc.get('city2', ''),
                                                add.state, True)
    try:
        if add.address and add.city and add.country and add.state and add.profile:
            add.save()
            amap = AddressMap(address=add)
            amap.save()
    except Exception, e:
        print repr(e)
Exemplo n.º 3
0
        add.state = utils.get_or_create_state(doc.get('state2',''), add.country, True)
        if doc.get('city2', ''):
            add.city = utils.get_or_create_city(doc.get('city2',''), add.state, True)
    try:
        if add.address and add.city and add.country and add.state and add.profile:
            add.save()
            amap = AddressMap(address=add)
            amap.save()
    except Exception, e:
        print repr(e)


    addr = Address()
    addr.type = 'user'
    addr.profile = Profile.objects.get(primary_phone=doc['mobile'])
    addr.name = doc.get('name','')
    addr.phone = doc.get('mobile','')
    addr.pincode = doc.get('pincode','')
    if doc.get('address','').strip():
        addr.address = doc.get('address','')
    if doc.get('country','').strip():
        addr.country = utils.get_or_create_country(doc.get('country',''))
    else:
        addr.country = Country.objects.get(name='India')
    if doc.get('state','').strip():
        addr.state = utils.get_or_create_state(doc.get('state',''), addr.country, True)
        if doc.get('city', ''):
            addr.city = utils.get_or_create_city(doc.get('city',''), addr.state, True)
    try:
        if addr.address and addr.city and addr.country and addr.state and addr.profile:
            if not addr.is_same_as(add):
Exemplo n.º 4
0
                                              add.country, True)
        if doc.get('city2', ''):
            add.city = utils.get_or_create_city(doc.get('city2', ''),
                                                add.state, True)
    try:
        if add.address and add.city and add.country and add.state and add.profile:
            add.save()
            amap = AddressMap(address=add)
            amap.save()
    except Exception, e:
        print repr(e)

    addr = Address()
    addr.type = 'user'
    addr.profile = Profile.objects.get(primary_phone=doc['mobile'])
    addr.name = doc.get('name', '')
    addr.phone = doc.get('mobile', '')
    addr.pincode = doc.get('pincode', '')
    if doc.get('address', '').strip():
        addr.address = doc.get('address', '')
    if doc.get('country', '').strip():
        addr.country = utils.get_or_create_country(doc.get('country', ''))
    else:
        addr.country = Country.objects.get(name='India')
    if doc.get('state', '').strip():
        addr.state = utils.get_or_create_state(doc.get('state', ''),
                                               addr.country, True)
        if doc.get('city', ''):
            addr.city = utils.get_or_create_city(doc.get('city', ''),
                                                 addr.state, True)
    try: