Subversion Repositories SmartDukaan

Rev

Rev 15685 | Rev 15699 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15685 Rev 15686
Line 1114... Line 1114...
1114
def getRetailerObj(retailer, otherContacts1=None, callType=None):
1114
def getRetailerObj(retailer, otherContacts1=None, callType=None):
1115
    print "before otherContacts1",otherContacts1
1115
    print "before otherContacts1",otherContacts1
1116
    otherContacts = [] if otherContacts1 is None else otherContacts1
1116
    otherContacts = [] if otherContacts1 is None else otherContacts1
1117
    print "after otherContacts1",otherContacts
1117
    print "after otherContacts1",otherContacts
1118
    obj = Mock()
1118
    obj = Mock()
1119
    obj.title = retailer.title
-
 
1120
    obj.id = retailer.id
1119
    obj.id = retailer.id
-
 
1120
    
-
 
1121
        
1121
    if retailer.contact1 is not None and retailer.contact1 not in otherContacts:
1122
    if retailer.contact1 is not None and retailer.contact1 not in otherContacts:
1122
        otherContacts.append(retailer.contact1)
1123
        otherContacts.append(retailer.contact1)
1123
    if retailer.contact2 is not None and retailer.contact2 not in otherContacts:
1124
    if retailer.contact2 is not None and retailer.contact2 not in otherContacts:
1124
        otherContacts.append(retailer.contact2)
1125
        otherContacts.append(retailer.contact2)
1125
    obj.address = retailer.address_new if retailer.address_new is not None else retailer.address
-
 
1126
    obj.contact1 = None if len(otherContacts)==0 else otherContacts[0]
1126
    obj.contact1 = None if len(otherContacts)==0 else otherContacts[0]
1127
    if obj.contact1 is not None:
1127
    if obj.contact1 is not None:
1128
        obj.contact2 = None if len(otherContacts)==1 else otherContacts[1]
1128
        obj.contact2 = None if len(otherContacts)==1 else otherContacts[1]
1129
    obj.scheduled = (retailer.call_priority is not None)
1129
    obj.scheduled = (retailer.call_priority is not None)
-
 
1130
    address = None
-
 
1131
    try:
-
 
1132
        address = session.query(RetailerAddresses).filter_by(retailer_id=retailer.id).order_by(RetailerAddresses.created.desc()).first()
-
 
1133
    finally:
-
 
1134
        session.close()
-
 
1135
    if address is not None:
-
 
1136
        obj.address = address.address
-
 
1137
        obj.title = address.title
-
 
1138
        obj.city = address.city
-
 
1139
        obj.state = address.state
-
 
1140
        obj.pin = address.pin 
-
 
1141
        obj.status = address.status
-
 
1142
    else:
-
 
1143
        obj.address = retailer.address_new if retailer.address_new is not None else retailer.address
-
 
1144
        obj.title = retailer.title
1130
    obj.city = retailer.city
1145
        obj.city = retailer.city
1131
    obj.state = retailer.state
1146
        obj.state = retailer.state
1132
    obj.pin = retailer.pin 
1147
        obj.pin = retailer.pin 
1133
    obj.status = retailer.status
1148
        obj.status = retailer.status
-
 
1149
        
1134
    if hasattr(retailer, 'contact'):
1150
    if hasattr(retailer, 'contact'):
1135
        obj.contact = retailer.contact
1151
        obj.contact = retailer.contact
1136
    if callType == 'onboarding':
1152
    if callType == 'onboarding':
1137
        try:
1153
        try:
1138
            userId, activatedTime = session.query(RetailerLinks.user_id, RetailerLinks.activated).filter(RetailerLinks.retailer_id==retailer.id).first()
1154
            userId, activatedTime = session.query(RetailerLinks.user_id, RetailerLinks.activated).filter(RetailerLinks.retailer_id==retailer.id).first()