| Line 1033... |
Line 1033... |
| 1033 |
contact = m.group(1) if m.group(1) != '' else m.group(3)
|
1033 |
contact = m.group(1) if m.group(1) != '' else m.group(3)
|
| 1034 |
anotherCondition = and_(Retailers.title.ilike('%%%s%%'%(contact)), Retailers.pin==pin)
|
1034 |
anotherCondition = and_(Retailers.title.ilike('%%%s%%'%(contact)), Retailers.pin==pin)
|
| 1035 |
else:
|
1035 |
else:
|
| 1036 |
anotherCondition = Retailers.title.ilike('%%%s%%'%(contact))
|
1036 |
anotherCondition = Retailers.title.ilike('%%%s%%'%(contact))
|
| 1037 |
|
1037 |
|
| 1038 |
retailers = session.query(Retailers).filter(anotherCondition).all()
|
1038 |
retailers = session.query(Retailers).filter(anotherCondition).limit(20).all()
|
| 1039 |
if retailers is None:
|
1039 |
if retailers is None:
|
| 1040 |
resp.body = json.dumps("{}")
|
1040 |
resp.body = json.dumps("{}")
|
| 1041 |
else:
|
1041 |
else:
|
| 1042 |
for retailer in retailers:
|
1042 |
for retailer in retailers:
|
| 1043 |
otherContacts = [r for r, in session.query(RetailerContacts.mobile_number).filter_by(retailer_id=retailer.id).order_by(RetailerContacts.contact_type).limit(20).all()]
|
1043 |
otherContacts = [r for r, in session.query(RetailerContacts.mobile_number).filter_by(retailer_id=retailer.id).order_by(RetailerContacts.contact_type).all()]
|
| 1044 |
retailersJsonArray.append(todict(getRetailerObj(retailer, otherContacts)))
|
1044 |
retailersJsonArray.append(todict(getRetailerObj(retailer, otherContacts)))
|
| 1045 |
resp.body = json.dumps({"Retailers":retailersJsonArray}, encoding='utf-8')
|
1045 |
resp.body = json.dumps({"Retailers":retailersJsonArray}, encoding='utf-8')
|
| 1046 |
return
|
1046 |
return
|
| 1047 |
finally:
|
1047 |
finally:
|
| 1048 |
session.close()
|
1048 |
session.close()
|