Subversion Repositories SmartDukaan

Rev

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

Rev 18895 Rev 18923
Line 23... Line 23...
23
import string
23
import string
24
from shop2020.clients.CRMClient import CRMClient
24
from shop2020.clients.CRMClient import CRMClient
25
from shop2020.clients.UserClient import UserClient
25
from shop2020.clients.UserClient import UserClient
26
from shop2020.thriftpy.crm.ttypes import SearchFilter, TicketCategory, Ticket, \
26
from shop2020.thriftpy.crm.ttypes import SearchFilter, TicketCategory, Ticket, \
27
     Activity, TicketPriority, TicketStatus, ActivityType
27
     Activity, TicketPriority, TicketStatus, ActivityType
-
 
28
from dtr.utils.MailSender import Email
28
#TODO Need to add messy stuff to conf.
29
#TODO Need to add messy stuff to conf.
29
 
30
 
30
 
31
 
31
SENDER = "cnc.center@shop2020.in"
32
SENDER = "cnc.center@shop2020.in"
32
PASSWORD = "5h0p2o2o"
33
PASSWORD = "5h0p2o2o"
Line 419... Line 420...
419
    emailpushrequest.add_header("Authorization", "Basic %s" % DTR_API_BASIC_AUTH)
420
    emailpushrequest.add_header("Authorization", "Basic %s" % DTR_API_BASIC_AUTH)
420
    connection = urllib2.urlopen(emailpushrequest)
421
    connection = urllib2.urlopen(emailpushrequest)
421
    connection.close()
422
    connection.close()
422
    
423
    
423
def generateCrmTicket(customerFeedBack):
424
def generateCrmTicket(customerFeedBack):
-
 
425
    sendCrmProjectMailByDtr(customerFeedBack)
424
    crmServiceClient = CRMClient().get_client() 
426
    crmServiceClient = CRMClient().get_client() 
425
    userServiceClient = UserClient().get_client()   
427
    userServiceClient = UserClient().get_client()   
426
    ticket = Ticket()
428
    ticket = Ticket()
427
    activity = Activity()
429
    activity = Activity()
428
    ticket.creatorId = 1
430
    ticket.creatorId = 1
Line 475... Line 477...
475
    ticketId = crmServiceClient.insertTicket(ticket, activity)
477
    ticketId = crmServiceClient.insertTicket(ticket, activity)
476
    
478
    
477
    if ticketId > 0:
479
    if ticketId > 0:
478
        return True
480
        return True
479
    else:
481
    else:
480
        return False    
482
        return False
-
 
483
        
-
 
484
def sendCrmProjectMailByDtr(customerFeedback):
-
 
485
    mailServer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
-
 
486
    mailServer.ehlo()
-
 
487
    mailServer.starttls()
-
 
488
    mailServer.ehlo()
-
 
489
    title=customerFeedback.get('subject')    
-
 
490
    msg = MIMEMultipart()
-
 
491
    msg['Subject'] = title
-
 
492
    msg.preamble = title
-
 
493
    message="User Id :" + str(customerFeedback.get('user_id'))
-
 
494
    message1="Email :" + str(customerFeedback.get('email'))
-
 
495
    message2="Mobile Number : " + str(customerFeedback.get('mobile_number'))
-
 
496
    message3="Subject : " + str(customerFeedback.get('subject'))
-
 
497
    message4="Message : " + str(customerFeedback.get('message'))
-
 
498
    html_msg = MIMEText(message+"<br>"+message1+"<br>"+message2+"<br>"+message3+"<br>"+message4, 'html')
-
 
499
    msg.attach(MIMEText(html_msg, 'html'))
-
 
500
    
-
 
501
    #MAILTO = ['amit.sirohi@shop2020.in','rajneesh.arora@saholic.com', 'shailesh.kumar@shop2020.in','chaitnaya.vats@shop2020.in','manas.kapoor@shop2020.in']
-
 
502
    MAILTO = ['manas.kapoor@saholic.com']
-
 
503
    mailServer.login(SENDER, PASSWORD)
-
 
504
    try:
-
 
505
        mailServer.sendmail(SENDER, MAILTO, msg.as_string())
-
 
506
    except:
-
 
507
        m = Email('localhost')
-
 
508
        mFrom = "dtr@shop2020.in"
-
 
509
        m.setFrom(mFrom)
-
 
510
        for receipient in MAILTO:
-
 
511
            m.addRecipient(receipient)
-
 
512
        m.setSubject(title)
-
 
513
        m.send()
-
 
514
    return    
481
515