| Line 986... |
Line 986... |
| 986 |
data[classkey] = obj.__class__.__name__
|
986 |
data[classkey] = obj.__class__.__name__
|
| 987 |
return data
|
987 |
return data
|
| 988 |
else:
|
988 |
else:
|
| 989 |
return obj
|
989 |
return obj
|
| 990 |
|
990 |
|
| 991 |
def getRetailerObj(retailer, otherContacts1=None):
|
991 |
def getRetailerObj(retailer, otherContacts=None):
|
| 992 |
print "before otherContacts1",otherContacts1
|
992 |
print "before otherContacts1",otherContacts1
|
| 993 |
otherContacts = [] if otherContacts1 is None else otherContacts1
|
993 |
otherContacts = [] if otherContacts is None else otherContacts
|
| 994 |
print "afotherContacts1",otherContacts1
|
994 |
print "afotherContacts1",otherContacts
|
| 995 |
obj = Mock()
|
995 |
obj = Mock()
|
| 996 |
obj.title = retailer.title
|
996 |
obj.title = retailer.title
|
| 997 |
obj.id = retailer.id
|
997 |
obj.id = retailer.id
|
| 998 |
if retailer.contact1 is not None and retailer.contact1 not in otherContacts:
|
998 |
if retailer.contact1 is not None and retailer.contact1 not in otherContacts:
|
| 999 |
otherContacts1.append(retailer.contact1)
|
999 |
otherContacts.append(retailer.contact1)
|
| 1000 |
if retailer.contact2 is not None and retailer.contact2 not in otherContacts:
|
1000 |
if retailer.contact2 is not None and retailer.contact2 not in otherContacts:
|
| 1001 |
otherContacts1.append(retailer.contact2)
|
1001 |
otherContacts.append(retailer.contact2)
|
| 1002 |
obj.address = retailer.address_new if retailer.address_new is not None else retailer.address
|
1002 |
obj.address = retailer.address_new if retailer.address_new is not None else retailer.address
|
| 1003 |
obj.contact1 = otherContacts1[0]
|
1003 |
obj.contact1 = otherContacts[0]
|
| 1004 |
obj.contact2 = None if len(otherContacts1)==1 else otherContacts1[1]
|
1004 |
obj.contact2 = None if len(otherContacts)==1 else otherContacts[1]
|
| 1005 |
obj.scheduled = (retailer.call_priority is not None)
|
1005 |
obj.scheduled = (retailer.call_priority is not None)
|
| 1006 |
obj.status = retailer.status
|
1006 |
obj.status = retailer.status
|
| 1007 |
return obj
|
1007 |
return obj
|
| 1008 |
|
1008 |
|
| 1009 |
def make_tiny(code):
|
1009 |
def make_tiny(code):
|
| Line 1037... |
Line 1037... |
| 1037 |
retailers = session.query(Retailers).filter(anotherCondition).all()
|
1037 |
retailers = session.query(Retailers).filter(anotherCondition).all()
|
| 1038 |
if retailers is None:
|
1038 |
if retailers is None:
|
| 1039 |
resp.body = json.dumps("{}")
|
1039 |
resp.body = json.dumps("{}")
|
| 1040 |
else:
|
1040 |
else:
|
| 1041 |
for retailer in retailers:
|
1041 |
for retailer in retailers:
|
| 1042 |
otherContacts = [r for r, in session.query(RetailerContacts.mobile_number).filter_by(retailer_id=retailer.id).order_by(RetailerContacts.contact_type).all()]
|
1042 |
otherContacts = [r for r, in session.query(RetailerContacts.mobile_number).filter_by(retailer_id=retailer.id).order_by(RetailerContacts.contact_type).all()]
|
| 1043 |
retailersJsonArray.append(todict(getRetailerObj(retailer, otherContacts)))
|
1043 |
retailersJsonArray.append(todict(getRetailerObj(retailer, otherContacts)))
|
| 1044 |
resp.body = json.dumps({"Retailers":retailersJsonArray}, encoding='utf-8')
|
1044 |
resp.body = json.dumps({"Retailers":retailersJsonArray}, encoding='utf-8')
|
| 1045 |
return
|
1045 |
return
|
| 1046 |
finally:
|
1046 |
finally:
|
| 1047 |
session.close()
|
1047 |
session.close()
|