Subversion Repositories SmartDukaan

Rev

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

Rev 5978 Rev 6029
Line 29... Line 29...
29
import sys
29
import sys
30
import threading
30
import threading
31
import urllib2
31
import urllib2
32
 
32
 
33
sourceId = int(ConfigClient().get_property("sourceid"))
33
sourceId = int(ConfigClient().get_property("sourceid"))
34
to_addresses = ["cnc.center@shop2020.in", "ashutosh.saxena@shop2020.in"]
34
to_addresses = ["ashutosh.saxena@shop2020.in",  "chaitnaya.vats@shop2020.in"]
35
from_user = "cnc.center@shop2020.in"
35
mail_user = "cnc.center@shop2020.in"
36
from_pwd = "5h0p2o2o"
36
mail_password = "5h0p2o2o"
-
 
37
source_name = "Saholic"
-
 
38
source_url = "www.saholic.com"
37
skippedItems = { 175 : [27, 2160, 2175, 2163, 2158, 7128, 26, 2154],
39
skippedItems = { 175 : [27, 2160, 2175, 2163, 2158, 7128, 26, 2154],
38
                 193 : [5839] }
40
                 193 : [5839] }
39
 
41
 
40
def initialize(dbname='catalog', db_hostname="localhost"):
42
def initialize(dbname='catalog', db_hostname="localhost"):
41
    DataService.initialize(dbname, db_hostname)
43
    DataService.initialize(dbname, db_hostname)
Line 971... Line 973...
971
    product_name = product_name.replace("  "," ")
973
    product_name = product_name.replace("  "," ")
972
    return product_name
974
    return product_name
973
 
975
 
974
 
976
 
975
def __get_product_url(item):
977
def __get_product_url(item):
976
    product_url = "http://www.saholic.com/mobile-phones/" + item.brand + "-" + item.model_name + "-" + item.model_number + "-" + str(item.catalog_item_id)
978
    product_url = "http://" + source_url + "/mobile-phones/" + item.brand + "-" + item.model_name + "-" + item.model_number + "-" + str(item.catalog_item_id)
977
    product_url = product_url.replace("--","-")
979
    product_url = product_url.replace("--","-")
978
    product_url = product_url.replace(" ","")
980
    product_url = product_url.replace(" ","")
979
    return product_url
981
    return product_url
980
 
982
 
981
def get_all_brands_by_category(category_id):
983
def get_all_brands_by_category(category_id):
Line 996... Line 998...
996
        <html>
998
        <html>
997
        <body>
999
        <body>
998
        <div>
1000
        <div>
999
        <p>
1001
        <p>
1000
            Hi,<br /><br />
1002
            Hi,<br /><br />
1001
            The product requested by you on $date is now available on saholic.com.
1003
            The product requested by you on $date is now available on $source_url.
1002
        </p>
1004
        </p>
1003
            
1005
            
1004
        <p>    
1006
        <p>    
1005
        <strong>Product: $product </strong>
1007
        <strong>Product: $product </strong>
1006
        </p>
1008
        </p>
Line 1010... Line 1012...
1010
        <br/>
1012
        <br/>
1011
        $url
1013
        $url
1012
        </p>
1014
        </p>
1013
        <p>
1015
        <p>
1014
        Regards,<br/>
1016
        Regards,<br/>
1015
        Saholic Customer Support Team<br/>
1017
        $source_name Customer Support Team<br/>
1016
        www.saholic.com<br/>
1018
        $source_url<br/>
1017
        Email: help@saholic.com<br/>
1019
        Email: help@saholic.com<br/>
1018
        </p>
1020
        </p>
1019
        </div>
1021
        </div>
1020
        </body>
1022
        </body>
1021
        </html>
1023
        </html>
1022
        """
1024
        """
1023
 
1025
 
1024
    html = Template(html).substitute(dict(product=product,date=date,url=url))
1026
    html = Template(html).substitute(dict(product=product,date=date,url=url,source_url=source_url,source_name=source_name))
1025
    
1027
    
1026
    try:
1028
    try:
1027
        helper_client = HelperClient().get_client()
1029
        helper_client = HelperClient().get_client()
1028
        helper_client.saveUserEmailForSending([email], "", "Product requested by you is available now.", html, str(itemId), "ProductNotification", [], [])
1030
        helper_client.saveUserEmailForSending([email], "", "Product requested by you is available now.", html, str(itemId), "ProductNotification", [], [])
1029
    except Exception as e:
1031
    except Exception as e:
Line 1207... Line 1209...
1207
    session.commit()
1209
    session.commit()
1208
    return True
1210
    return True
1209
 
1211
 
1210
def __send_mail_for_oos_item(item): 
1212
def __send_mail_for_oos_item(item): 
1211
    try:
1213
    try:
1212
        EmailAttachmentSender.mail('cnc.center@shop2020.in', '5h0p2o2o', ['abhishek.mathur@shop2020.in', 'chaitnaya.vats@shop2020.in'], "Item is out of stock. ID: " + str(item.id)  + " " + str(item.brand) +  " " + str(item.model_name) + " " + str(item.model_number)+ " " + str(item.color), None)
1214
        EmailAttachmentSender.mail(mail_user, mail_password, to_addresses + ["abhishek.mathur@shop2020.in"], "Item is out of stock. ID: " + str(item.id)  + " " + str(item.brand) +  " " + str(item.model_name) + " " + str(item.model_number)+ " " + str(item.color), None)
1213
    except Exception as e:
1215
    except Exception as e:
1214
        print e
1216
        print e
1215
 
1217
 
1216
def __send_mail(subject, message):
1218
def __send_mail(subject, message):
1217
    try:
1219
    try:
1218
        thread = threading.Thread(target=partial(mail, from_user, from_pwd, to_addresses, subject, message))
1220
        thread = threading.Thread(target=partial(mail, mail_user, mail_password, to_addresses, subject, message))
1219
        thread.start()
1221
        thread.start()
1220
    except Exception as ex:
1222
    except Exception as ex:
1221
        print ex    
1223
        print ex    
1222
 
1224
 
1223
def get_clearance_sale_catalog_ids():
1225
def get_clearance_sale_catalog_ids():