Subversion Repositories SmartDukaan

Rev

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

Rev 15285 Rev 15286
Line -... Line 1...
-
 
1
from sqlalchemy.sql.expression import func
1
from bson import json_util
2
from bson import json_util
2
from bson.json_util import dumps
3
from bson.json_util import dumps
3
from datetime import datetime, timedelta
4
from datetime import datetime, timedelta
4
from dtr import main
5
from dtr import main
5
from dtr.config import PythonPropertyReader
6
from dtr.config import PythonPropertyReader
Line 641... Line 642...
641
                fetchInfo.last_action = 'disposition'
642
                fetchInfo.last_action = 'disposition'
642
                fetchInfo.last_action_time = last_disposition.created
643
                fetchInfo.last_action_time = last_disposition.created
643
            fetchInfo.retailer_id = retailer.id
644
            fetchInfo.retailer_id = retailer.id
644
            session.commit()
645
            session.commit()
645
            
646
            
646
            otherContacts = 
647
            otherContacts = session.query(RetailerContacts).filter_by(retailer_id=retailer.id).all() 
647
            if retailer is None:
648
            if retailer is None:
648
                resp.body = "{}"
649
                resp.body = "{}"
649
            else:
650
            else:
650
                resp.body = json.dumps(todict(getRetailerObj(retailer)), encoding='utf-8')
651
                resp.body = json.dumps(todict(getRetailerObj(retailer, otherContacts)), encoding='utf-8')
651
            
652
            
652
            return
653
            return
653
            
654
            
654
        finally:
655
        finally:
655
            session.close()
656
            session.close()
Line 980... Line 981...
980
        return data
981
        return data
981
    else:
982
    else:
982
        return obj
983
        return obj
983
    
984
    
984
def getRetailerObj(retailer, otherContacts=[]):
985
def getRetailerObj(retailer, otherContacts=[]):
-
 
986
    otherContacts = [] if otherContacts is None else otherContacts
985
    obj = Mock()
987
    obj = Mock()
986
    obj.title = retailer.title
988
    obj.title = retailer.title
987
    obj.id = retailer.id
989
    obj.id = retailer.id
988
    if retailer.contact1 is not None and retailer.contact1 not in otherContacts:
990
    if retailer.contact1 is not None and retailer.contact1 not in otherContacts:
989
        otherContacts.append(retailer.contact1)
991
        otherContacts.append(retailer.contact1)