| Line 15... |
Line 15... |
| 15 |
|
15 |
|
| 16 |
class __SkuInfo:
|
16 |
class __SkuInfo:
|
| 17 |
|
17 |
|
| 18 |
def __init__(self, _id, skuBundleId, category_id, mrp, available_price, source_id, rank, maxNlc, minNlc, schemeAmount, minDiscount, \
|
18 |
def __init__(self, _id, skuBundleId, category_id, mrp, available_price, source_id, rank, maxNlc, minNlc, schemeAmount, minDiscount, \
|
| 19 |
maxDiscount, discountType, dp, nlcPoints, bestSellerPoints, totalPoints,in_stock,maxprice,showDeal,persPoints, \
|
19 |
maxDiscount, discountType, dp, nlcPoints, bestSellerPoints, totalPoints,in_stock,maxprice,showDeal,persPoints, \
|
| 20 |
fav_weight,brand_weight,asp_weight):
|
20 |
fav_weight,brand_weight,asp_weight,catalogBestSellerPoints):
|
| 21 |
self._id = _id
|
21 |
self._id = _id
|
| 22 |
self.skuBundleId = skuBundleId
|
22 |
self.skuBundleId = skuBundleId
|
| 23 |
self.category_id = category_id
|
23 |
self.category_id = category_id
|
| 24 |
self.mrp = mrp
|
24 |
self.mrp = mrp
|
| 25 |
self.available_price = available_price
|
25 |
self.available_price = available_price
|
| Line 40... |
Line 40... |
| 40 |
self.showDeal = showDeal
|
40 |
self.showDeal = showDeal
|
| 41 |
self.persPoints = persPoints
|
41 |
self.persPoints = persPoints
|
| 42 |
self.fav_weight = fav_weight
|
42 |
self.fav_weight = fav_weight
|
| 43 |
self.brand_weight = brand_weight
|
43 |
self.brand_weight = brand_weight
|
| 44 |
self.asp_weight = asp_weight
|
44 |
self.asp_weight = asp_weight
|
| - |
|
45 |
self.catalogBestSellerPoints = catalogBestSellerPoints
|
| 45 |
|
46 |
|
| 46 |
|
47 |
|
| 47 |
def get_mongo_connection(host='localhost', port=27017):
|
48 |
def get_mongo_connection(host='localhost', port=27017):
|
| 48 |
global con
|
49 |
global con
|
| 49 |
if con is None:
|
50 |
if con is None:
|
| Line 138... |
Line 139... |
| 138 |
sorted_deals = sorted(all_category_deals, key = lambda x: (x['persPoints'],x['totalPoints'],x['bestSellerPoints'], x['nlcPoints'], x['rank']),reverse=True)
|
139 |
sorted_deals = sorted(all_category_deals, key = lambda x: (x['persPoints'],x['totalPoints'],x['bestSellerPoints'], x['nlcPoints'], x['rank']),reverse=True)
|
| 139 |
p = []
|
140 |
p = []
|
| 140 |
for x in sorted_deals:
|
141 |
for x in sorted_deals:
|
| 141 |
s_info = __SkuInfo(x['_id'], x['skuBundleId'], x['category_id'],x['mrp'],x['available_price'],x['source_id'],x['rank'],x['maxNlc'], \
|
142 |
s_info = __SkuInfo(x['_id'], x['skuBundleId'], x['category_id'],x['mrp'],x['available_price'],x['source_id'],x['rank'],x['maxNlc'], \
|
| 142 |
x['minNlc'], x['schemeAmount'],x['minDiscount'],x['maxDiscount'],x['discountType'],x['dp'],x['nlcPoints'],x['bestSellerPoints'], \
|
143 |
x['minNlc'], x['schemeAmount'],x['minDiscount'],x['maxDiscount'],x['discountType'],x['dp'],x['nlcPoints'],x['bestSellerPoints'], \
|
| 143 |
x['totalPoints'],x['in_stock'],x['maxprice'],x['showDeal'],x['persPoints'],x['fav_weight'],x['brand_weight'],x['asp_weight'])
|
144 |
x['totalPoints'],x['in_stock'],x['maxprice'],x['showDeal'],x['persPoints'],x['fav_weight'],x['brand_weight'],x['asp_weight'], \
|
| - |
|
145 |
x['catalogBestSellerPoints'])
|
| 144 |
p.append(s_info)
|
146 |
p.append(s_info)
|
| 145 |
|
147 |
|
| 146 |
|
148 |
|
| 147 |
wbk = xlwt.Workbook()
|
149 |
wbk = xlwt.Workbook()
|
| 148 |
sheet = wbk.add_sheet('User Deals')
|
150 |
sheet = wbk.add_sheet('User Deals')
|
| Line 176... |
Line 178... |
| 176 |
sheet.write(0, 20, "Min Nlc", heading_xf)
|
178 |
sheet.write(0, 20, "Min Nlc", heading_xf)
|
| 177 |
sheet.write(0, 21, "Max Price", heading_xf)
|
179 |
sheet.write(0, 21, "Max Price", heading_xf)
|
| 178 |
sheet.write(0, 22, "Rank", heading_xf)
|
180 |
sheet.write(0, 22, "Rank", heading_xf)
|
| 179 |
sheet.write(0, 23, "Nlc Points", heading_xf)
|
181 |
sheet.write(0, 23, "Nlc Points", heading_xf)
|
| 180 |
sheet.write(0, 24, "Best Seller Points", heading_xf)
|
182 |
sheet.write(0, 24, "Best Seller Points", heading_xf)
|
| - |
|
183 |
sheet.write(0, 25, "Catalog Best Seller Points", heading_xf)
|
| 181 |
sheet.write(0, 25, "Total Points", heading_xf)
|
184 |
sheet.write(0, 26, "Total Points", heading_xf)
|
| 182 |
sheet.write(0, 26, "Pers Points", heading_xf)
|
185 |
sheet.write(0, 27, "Pers Points", heading_xf)
|
| 183 |
sheet.write(0, 27, "Show Deals", heading_xf)
|
186 |
sheet.write(0, 28, "Show Deals", heading_xf)
|
| 184 |
sheet.write(0, 28, "Fav Weight", heading_xf)
|
187 |
sheet.write(0, 29, "Fav Weight", heading_xf)
|
| 185 |
sheet.write(0, 29, "Brand Weight", heading_xf)
|
188 |
sheet.write(0, 30, "Brand Weight", heading_xf)
|
| 186 |
sheet.write(0, 30, "Asp Weight", heading_xf)
|
189 |
sheet.write(0, 31, "Asp Weight", heading_xf)
|
| 187 |
|
190 |
|
| 188 |
it = 1
|
191 |
it = 1
|
| 189 |
for x in p:
|
192 |
for x in p:
|
| 190 |
y = list(get_mongo_connection().Catalog.MasterData.find({'_id':x._id}))
|
193 |
y = list(get_mongo_connection().Catalog.MasterData.find({'_id':x._id}))
|
| 191 |
sheet.write(it, 0, x._id)
|
194 |
sheet.write(it, 0, x._id)
|
| Line 221... |
Line 224... |
| 221 |
sheet.write(it, 20, x.minNlc)
|
224 |
sheet.write(it, 20, x.minNlc)
|
| 222 |
sheet.write(it, 21, x.maxprice)
|
225 |
sheet.write(it, 21, x.maxprice)
|
| 223 |
sheet.write(it, 22, x.rank)
|
226 |
sheet.write(it, 22, x.rank)
|
| 224 |
sheet.write(it, 23, x.nlcPoints)
|
227 |
sheet.write(it, 23, x.nlcPoints)
|
| 225 |
sheet.write(it, 24, x.bestSellerPoints)
|
228 |
sheet.write(it, 24, x.bestSellerPoints)
|
| - |
|
229 |
sheet.write(it, 25, x.catalogBestSellerPoints)
|
| 226 |
sheet.write(it, 25, x.totalPoints)
|
230 |
sheet.write(it, 26, x.totalPoints)
|
| 227 |
sheet.write(it, 26, x.persPoints)
|
231 |
sheet.write(it, 27, x.persPoints)
|
| 228 |
sheet.write(it, 27, x.showDeal)
|
232 |
sheet.write(it, 28, x.showDeal)
|
| 229 |
sheet.write(it, 28, x.fav_weight)
|
233 |
sheet.write(it, 29, x.fav_weight)
|
| 230 |
sheet.write(it, 29, x.brand_weight)
|
234 |
sheet.write(it, 30, x.brand_weight)
|
| 231 |
sheet.write(it, 30, x.asp_weight)
|
235 |
sheet.write(it, 31, x.asp_weight)
|
| 232 |
it+=1
|
236 |
it+=1
|
| 233 |
filename = "/tmp/deal-data-user-specific"+str(datetime.now())+".xls"
|
237 |
filename = "/tmp/deal-data-user-specific"+str(datetime.now())+".xls"
|
| 234 |
wbk.save(filename)
|
238 |
wbk.save(filename)
|
| 235 |
smtpServer = smtplib.SMTP('localhost')
|
239 |
smtpServer = smtplib.SMTP('localhost')
|
| 236 |
#smtpServer.set_debuglevel(1)
|
240 |
#smtpServer.set_debuglevel(1)
|
| Line 244... |
Line 248... |
| 244 |
msg['From'] = sender
|
248 |
msg['From'] = sender
|
| 245 |
msg['To'] = ",".join(recipients)
|
249 |
msg['To'] = ",".join(recipients)
|
| 246 |
fileMsg = email.mime.base.MIMEBase('application','vnd.ms-excel')
|
250 |
fileMsg = email.mime.base.MIMEBase('application','vnd.ms-excel')
|
| 247 |
fileMsg.set_payload(file(filename).read())
|
251 |
fileMsg.set_payload(file(filename).read())
|
| 248 |
email.encoders.encode_base64(fileMsg)
|
252 |
email.encoders.encode_base64(fileMsg)
|
| 249 |
fileMsg.add_header('Content-Disposition','attachment;filename=User_Deal_Sheet_Dtr.xls')
|
253 |
fileMsg.add_header('Content-Disposition','attachment;filename=User_Deal_Sheet_Dtr'+str(userId)+"" + ' - ' + str(datetime.now())+'.xls')
|
| 250 |
msg.attach(fileMsg)
|
254 |
msg.attach(fileMsg)
|
| 251 |
try:
|
255 |
try:
|
| 252 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
256 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
| 253 |
print "Successfully sent email"
|
257 |
print "Successfully sent email"
|
| 254 |
except:
|
258 |
except:
|