Пример #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)
Пример #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)
Пример #3
0
    def add_delivery_address(self,old_order,profile):
        address = Address()
        address.phone = old_order.deliveryphone or ''
        address.name = old_order.deliveryname or ''
        address.address = old_order.deliveryaddress or ''
        address.pincode = old_order.deliverypincode or ''

        address.country = utils.get_or_create_country(old_order.deliverycountry or '', True)
        address.state = utils.get_or_create_state(old_order.deliverystate or '', address.country, True)
        address.city = utils.get_or_create_city(old_order.deliverycity or '', address.state, True)
        
        address.type = 'delivery'
        address.profile = profile
        address.save()
        return address
Пример #4
0
    def add_delivery_address(self, old_order, profile):
        address = Address()
        address.phone = old_order.deliveryphone or ''
        address.name = old_order.deliveryname or ''
        address.address = old_order.deliveryaddress or ''
        address.pincode = old_order.deliverypincode or ''

        address.country = utils.get_or_create_country(
            old_order.deliverycountry or '', True)
        address.state = utils.get_or_create_state(
            old_order.deliverystate or '', address.country, True)
        address.city = utils.get_or_create_city(old_order.deliverycity or '',
                                                address.state, True)

        address.type = 'delivery'
        address.profile = profile
        address.save()
        return address
Пример #5
0
    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):
                addr.save()
                amap = AddressMap(address=addr)
                amap.save()
    except Exception, e:
        print repr(e)

def migrate_active_user_addresses():
    count_query = solr_search('isActive:true')
    total = int(str(count_query.numFound))
    batch_size = 1000
    retrieved = 0
Пример #6
0
    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):
                addr.save()
                amap = AddressMap(address=addr)
                amap.save()
    except Exception, e:
        print repr(e)


def migrate_active_user_addresses():
    count_query = solr_search('isActive:true')
    total = int(str(count_query.numFound))
    batch_size = 1000
    retrieved = 0