| Line 1010... |
Line 1010... |
| 1010 |
def on_post(self, req, resp, agentId, searchType):
|
1010 |
def on_post(self, req, resp, agentId, searchType):
|
| 1011 |
try:
|
1011 |
try:
|
| 1012 |
jsonReq = json.loads(req.stream.read(), encoding='utf-8')
|
1012 |
jsonReq = json.loads(req.stream.read(), encoding='utf-8')
|
| 1013 |
lgr.info( "Request in Search----\n" + str(jsonReq))
|
1013 |
lgr.info( "Request in Search----\n" + str(jsonReq))
|
| 1014 |
contact=jsonReq.get('searchTerm')
|
1014 |
contact=jsonReq.get('searchTerm')
|
| - |
|
1015 |
anotherCondition = None
|
| 1015 |
retailerModifedCondition = and_(Retailers.modified is not None)
|
1016 |
retailerModifedCondition = and_(Retailers.modified is not None, anotherCondition)
|
| 1016 |
if(searchType=="number"):
|
1017 |
if(searchType=="number"):
|
| 1017 |
searchUser = session.query(Retailers).filter(or_(Retailers.contact1==contact,Retailers.contact2==contact), retailerModifedCondition).all()
|
1018 |
anotherCondition = or_(Retailers.contact1==contact,Retailers.contact2==contact)
|
| 1018 |
elif(searchType=="counter"):
|
1019 |
elif(searchType=="counter"):
|
| 1019 |
contact = contact.lower()
|
1020 |
contact = contact.lower()
|
| - |
|
1021 |
anotherCondition = or_(Retailers.contact1==contact,Retailers.contact2==contact)
|
| - |
|
1022 |
|
| 1020 |
searchUser = session.query(Retailers).filter(or_(func.lower(Retailers.address).like(contact)),(func.lower(Retailers.address_new).like(contact)), retailerModifedCondition).all()
|
1023 |
searchUser = session.query(Retailers).filter(retailerModifedCondition).all()
|
| 1021 |
if searchUser is None:
|
1024 |
if searchUser is None:
|
| 1022 |
resp.body = json.dumps("{}")
|
1025 |
resp.body = json.dumps("{}")
|
| 1023 |
else:
|
1026 |
else:
|
| 1024 |
resp.body = json.dumps({"Retailers":[todict(getRetailerObj(user)) for user in searchUser]}, encoding='utf-8')
|
1027 |
resp.body = json.dumps({"Retailers":[todict(getRetailerObj(user)) for user in searchUser]}, encoding='utf-8')
|
| 1025 |
finally:
|
1028 |
finally:
|