| Line 5... |
Line 5... |
| 5 |
from dtr import main
|
5 |
from dtr import main
|
| 6 |
from dtr.config import PythonPropertyReader
|
6 |
from dtr.config import PythonPropertyReader
|
| 7 |
from dtr.storage import Mongo
|
7 |
from dtr.storage import Mongo
|
| 8 |
from dtr.storage.DataService import Retailers, Users, CallHistory, RetryConfig, \
|
8 |
from dtr.storage.DataService import Retailers, Users, CallHistory, RetryConfig, \
|
| 9 |
RetailerLinks, Activation_Codes, Agents, Agent_Roles, AgentLoginTimings, \
|
9 |
RetailerLinks, Activation_Codes, Agents, Agent_Roles, AgentLoginTimings, \
|
| 10 |
FetchDataHistory, RetailerContacts, Orders, OnboardedRetailerChecklists
|
10 |
FetchDataHistory, RetailerContacts, Orders, OnboardedRetailerChecklists,\
|
| - |
|
11 |
RetailerAddresses
|
| 11 |
from dtr.storage.Mongo import get_mongo_connection
|
12 |
from dtr.storage.Mongo import get_mongo_connection
|
| 12 |
from dtr.storage.Mysql import fetchResult
|
13 |
from dtr.storage.Mysql import fetchResult
|
| 13 |
from dtr.utils import FetchLivePrices, DealSheet as X_DealSheet, \
|
14 |
from dtr.utils import FetchLivePrices, DealSheet as X_DealSheet, \
|
| 14 |
UserSpecificDeals
|
15 |
UserSpecificDeals
|
| 15 |
from dtr.utils.utils import getLogger
|
16 |
from dtr.utils.utils import getLogger
|
| Line 929... |
Line 930... |
| 929 |
contactType = jsonReq.get("contacttype")
|
930 |
contactType = jsonReq.get("contacttype")
|
| 930 |
addContactToRetailer(agentId, retailerId, mobile, callType, contactType)
|
931 |
addContactToRetailer(agentId, retailerId, mobile, callType, contactType)
|
| 931 |
session.commit()
|
932 |
session.commit()
|
| 932 |
finally:
|
933 |
finally:
|
| 933 |
session.close()
|
934 |
session.close()
|
| - |
|
935 |
|
| - |
|
936 |
class AddAddessToRetailer():
|
| - |
|
937 |
def on_post(self,req,resp, agentId):
|
| - |
|
938 |
agentId = int(agentId)
|
| - |
|
939 |
try:
|
| - |
|
940 |
jsonReq = json.loads(req.stream.read(), encoding='utf-8')
|
| - |
|
941 |
retailerId = int(jsonReq.get("retailerid"))
|
| - |
|
942 |
address = jsonReq.get("address")
|
| - |
|
943 |
storeName = jsonReq.get("storename")
|
| - |
|
944 |
pin = jsonReq.get("pin")
|
| - |
|
945 |
city = jsonReq.get("city")
|
| - |
|
946 |
state = jsonReq.get("state")
|
| - |
|
947 |
updateType = jsonReq.get("updatetype")
|
| - |
|
948 |
addAddressToRetailer(agentId, retailerId, address, storeName, pin, city,state, updateType)
|
| - |
|
949 |
session.commit()
|
| - |
|
950 |
finally:
|
| - |
|
951 |
session.close()
|
| 934 |
|
952 |
|
| 935 |
def addContactToRetailer(agentId, retailerId, mobile, callType, contactType):
|
953 |
def addContactToRetailer(agentId, retailerId, mobile, callType, contactType):
|
| 936 |
retailerContact = session.query(RetailerContacts).filter_by(retailer_id=retailerId).filter_by(mobile_number=mobile).first()
|
954 |
retailerContact = session.query(RetailerContacts).filter_by(retailer_id=retailerId).filter_by(mobile_number=mobile).first()
|
| 937 |
if retailerContact is None:
|
955 |
if retailerContact is None:
|
| 938 |
retailerContact = RetailerContacts()
|
956 |
retailerContact = RetailerContacts()
|
| Line 942... |
Line 960... |
| 942 |
retailerContact.contact_type = contactType
|
960 |
retailerContact.contact_type = contactType
|
| 943 |
retailerContact.mobile_number = mobile
|
961 |
retailerContact.mobile_number = mobile
|
| 944 |
else:
|
962 |
else:
|
| 945 |
if CONTACT_PRIORITY.index(retailerContact.contact_type) > CONTACT_PRIORITY.index(contactType):
|
963 |
if CONTACT_PRIORITY.index(retailerContact.contact_type) > CONTACT_PRIORITY.index(contactType):
|
| 946 |
retailerContact.contact_type = contactType
|
964 |
retailerContact.contact_type = contactType
|
| - |
|
965 |
|
| - |
|
966 |
def addAddressToRetailer(agentId, retailerId, address, storeName, pin, city,state, updateType):
|
| - |
|
967 |
if updateType=='new':
|
| - |
|
968 |
retailer = session.query(Retailers).filter_by(id=retailerId)
|
| - |
|
969 |
retailer.address = address
|
| - |
|
970 |
retailer.title = storeName
|
| - |
|
971 |
retailer.city = city
|
| - |
|
972 |
retailer.state = state
|
| - |
|
973 |
retailer.pin = pin
|
| - |
|
974 |
raddress = RetailerAddresses()
|
| - |
|
975 |
raddress.address = address
|
| - |
|
976 |
raddress.agent_id = agentId
|
| - |
|
977 |
raddress.city = city
|
| - |
|
978 |
raddress.pin = pin
|
| - |
|
979 |
raddress.retailer_id = retailerId
|
| - |
|
980 |
raddress.state = state
|
| - |
|
981 |
session.commit()
|
| 947 |
|
982 |
|
| 948 |
|
983 |
|
| 949 |
|
984 |
|
| 950 |
class Login():
|
985 |
class Login():
|
| 951 |
|
986 |
|
| 952 |
def on_get(self, req, resp, agentId, role):
|
987 |
def on_get(self, req, resp, agentId, role):
|