def send_coupons_by_sms(request, total_coupon_codes, affiliate_name, sms_alert_on, show_avail_coupon): t_sms = get_template('notifications/subscriptions/%s.sms' % affiliate_name) sms_content = {} if show_avail_coupon: try: sms_content['coupon_code'] = total_coupon_codes[affiliate_name] except KeyError: pass try: sms_content['pantaloon'] = total_coupon_codes['pantaloon'] except KeyError: pass try: sms_content['bigbazaar'] = total_coupon_codes['bigbazaar'] except KeyError: pass try: sms_content['futurebazaar'] = total_coupon_codes['futurebazaar'] except KeyError: pass c_sms = Context(sms_content) sms_text = t_sms.render(c_sms) sms = SMS() sms.text = sms_text sms.mask = request.client.client.sms_mask sms.to = sms_alert_on.phone sms.send()
def send_coupons_by_sms(request, total_coupon_codes, affiliate_name, sms_alert_on, show_avail_coupon): t_sms = get_template("notifications/subscriptions/%s.sms" % affiliate_name) sms_content = {} if show_avail_coupon: try: sms_content["coupon_code"] = total_coupon_codes[affiliate_name] except KeyError: pass try: sms_content["pantaloon"] = total_coupon_codes["pantaloon"] except KeyError: pass try: sms_content["bigbazaar"] = total_coupon_codes["bigbazaar"] except KeyError: pass try: sms_content["futurebazaar"] = total_coupon_codes["futurebazaar"] except KeyError: pass c_sms = Context(sms_content) sms_text = t_sms.render(c_sms) sms = SMS() sms.text = sms_text sms.mask = request.client.client.sms_mask sms.to = sms_alert_on.phone sms.send()
def getNotifications(self): notifications = [] buyer = self.order.user order_items = OrderItem.objects.select_related( 'seller_rate_chart').filter(order=self.order) product = order_items[0].seller_rate_chart.product qty = order_items[0].qty products_map = {} for item in order_items: seller = item.seller_rate_chart.seller seller_id = seller.id product = item.seller_rate_chart.product products_map[product.id] = product email_body_ctxt = {} email_subject_ctxt = {} sms_body_ctxt = {} sms_subject_ctxt = {} self.fill_attributes(self.order, product, email_body_ctxt, email_subject_ctxt,\ buyer, products_map, qty) self.fill_attributes(self.order, product, sms_body_ctxt, sms_subject_ctxt,\ buyer, products_map, qty) t_body = get_template('notifications/order/shipped_order.email') t_sub = get_template('notifications/order/shipped_order_sub.email') ctxt_body = email_body_ctxt c_body = Context(ctxt_body) ctxt_sub = email_subject_ctxt c_sub = Context(ctxt_sub) email_body = t_body.render(c_body) email_subject = t_sub.render(c_sub) email_sent_from = "%s<fulfillment@%s>" % ( self.order.client.name, self.order.client.clientdomain_name) email_bcc, email_to = '', '' if buyer.get_primary_emails(): emails = '' for email in buyer.get_primary_emails(): emails += email.email + ',' email_to = emails.strip(',') email_bcc = "customerservice@%s" % self.order.client.clientdomain_name else: email_to = "customerservice@%s" % self.order.client.clientdomain_name email_bcc = "" bemail = NEmail() bemail.body = email_body bemail.subject = email_subject bemail.to = email_to bemail._from = email_sent_from bemail.bcc = email_bcc bemail.isHtml = True email_log = LEmail(client_domain=self.request.client, order=self.order, profile=self.order.user, sent_to=email_to[:999], bccied_to=email_bcc, sent_from=email_sent_from, subject=email_subject, body=email_body, status='in_queue', type='shipped_order') email_log.save() bemail.email_log_id = email_log.id notifications.append(bemail) if buyer.get_primary_phones(): sms = SMS() t_sms_body = get_template('notifications/order/shipped_order.sms') ctxt_sms_body = sms_body_ctxt c_sms_body = Context(ctxt_sms_body) sms.text = t_sms_body.render(c_sms_body) sms.to = buyer.get_primary_phones()[0].phone sms.mask = self.order.client.sms_mask notifications.append(sms) return notifications
def getNotifications(self): notifications = [] buyer = self.order.user # order_items = OrderItem.objects.select_related('seller_rate_chart').filter(order=self.order, state='cancelled') product = self.order_items[0].seller_rate_chart.product qty = self.order_items[0].qty products_map = {} sellers_map = {} sellers_order_item_map = {} seller_total_map = {} seller_mrp_map = {} seller_discount_map = {} seller_shipping_charges_map = {} seller_product_map = {} seller_coupon_map = {} for item in self.order_items: seller = item.seller_rate_chart.seller seller_id = seller.id product = item.seller_rate_chart.product products_map[product.id] = product sellers_map[seller_id] = seller sellers_order_item_map[seller_id] = 1 if seller_id in seller_total_map: seller_total_map[seller_id] += (item.sale_price + item.shipping_charges) else: seller_total_map[seller_id] = (item.sale_price + item.shipping_charges) if seller_id in seller_shipping_charges_map: seller_shipping_charges_map[seller_id] += (item.shipping_charges) else: seller_shipping_charges_map[seller_id] = (item.shipping_charges) if seller_id in seller_mrp_map: seller_mrp_map[seller_id] += (item.list_price if item.list_price else item.sale_price) else: seller_mrp_map[seller_id] = (item.list_price if item.list_price else item.sale_price) if seller_id in seller_discount_map: seller_discount_map[seller.id] += (item.list_price - item.sale_price) else: seller_discount_map[seller.id] = (item.list_price - item.sale_price) if seller_id in seller_product_map: seller_product_map[seller_id].append(product) else: seller_product_map[seller_id] = [product] buyer_st = {} subject_st = {} buyer_sms_st = {} subject_sms_st = {} self.fill_attributes(self.order, product, buyer_st, subject_st,\ buyer, products_map, sellers_map, None, qty, seller_total_map, seller_product_map,\ seller_coupon_map, seller_mrp_map, seller_discount_map, seller_shipping_charges_map) self.fill_attributes(self.order, product, buyer_sms_st, subject_sms_st,\ buyer, products_map, sellers_map, None, qty, seller_total_map, seller_product_map,\ seller_coupon_map, seller_mrp_map, seller_discount_map, seller_shipping_charges_map) t_body = get_template('order/buyer_cancelled_order.email') t_sub = get_template('order/buyer_cancelled_order_sub.email') ctxt_body = buyer_st c_body = Context(ctxt_body) ctxt_sub = subject_st c_sub = Context(ctxt_sub) email_sent_from = "%s<order@%s>" % (self.order.client.name, self.order.client.clientdomain_name) email_body = t_body.render(c_body) email_subject = t_sub.render(c_sub) if buyer.get_primary_emails(): emails = '' for email in buyer.get_primary_emails(): emails += email.email + ',' emails = emails.strip(',') email_to = emails email_bcc = "customerservice@%s" % self.order.client.clientdomain_name else: email_to = "customerservice@%s" % self.order.client.clientdomain_name email_bcc = "" bemail = CEmail() bemail._from = email_sent_from bemail.body = email_body bemail.subject = email_subject bemail.isHtml = True bemail.to = email_to bemail.bcc = email_bcc email_log = LEmail(client_domain = self.request.client, order = self.order, profile = self.order.user, sent_to = email_to[:999], bccied_to = email_bcc, sent_from = email_sent_from, subject = email_subject, body = email_body, status = 'in_queue', type = 'buyer_order_cancellation') email_log.save() bemail.email_log_id = email_log.id notifications.append(bemail) sms = SMS() t_sms_body = get_template('order/buyer_cancelled_order.sms') ctxt_sms_body = buyer_sms_st c_sms_body = Context(ctxt_sms_body) sms.text = t_sms_body.render(c_sms_body) sms.to = buyer.primary_phone sms.mask = self.order.client.sms_mask notifications.append(sms) for seller_id in sellers_map: current_seller = sellers_map[seller_id] seller_body = {} seller_sub = {} self.fill_attributes(self.order, product, seller_body,\ seller_sub, buyer, products_map, sellers_map, current_seller, qty, seller_total_map,\ seller_product_map, seller_coupon_map, seller_mrp_map, seller_discount_map, seller_shipping_charges_map) t_body = get_template('order/seller_cancelled_order.email') ctxt_body = seller_body c_body = Context(ctxt_body) t_sub = get_template('order/seller_cancelled_order_sub.email') ctxt_sub = seller_sub c_sub = Context(ctxt_sub) seller_emails = current_seller.get_confirmed_order_notification_email_addresses() email_sent_from = "%s<order@%s>" % (self.order.client.name, self.order.client.clientdomain_name) #self.order.client.pending_order_email email_body = t_body.render(c_body) email_subject = t_sub.render(c_sub) email_bcc = '' if seller_emails: email_to = seller_emails email_bcc = "fulfillment@%s" % self.order.client.clientdomain_name else: email_to = "fulfillment@%s" % self.order.client.clientdomain_name semail = CEmail() semail._from = email_sent_from semail.body = email_body semail.subject = email_subject semail.to = email_to semail.isHtml = True semail.bcc = email_bcc email_log = LEmail(client_domain = self.request.client, order = self.order, profile = self.order.user, sent_to = email_to[:999], bccied_to = email_bcc, sent_from = email_sent_from, subject = email_subject, body = email_body, status = 'in_queue', type = 'seller_order_cancellation') email_log.save() semail.email_log_id = email_log.id notifications.append(semail) return notifications
def getNotifications(self): notifications = [] buyer = self.order.user # order_items = OrderItem.objects.select_related('seller_rate_chart').filter(order=self.order, state='cancelled') product = self.order_items[0].seller_rate_chart.product qty = self.order_items[0].qty products_map = {} sellers_map = {} sellers_order_item_map = {} seller_total_map = {} seller_mrp_map = {} seller_discount_map = {} seller_shipping_charges_map = {} seller_product_map = {} seller_coupon_map = {} for item in self.order_items: seller = item.seller_rate_chart.seller seller_id = seller.id product = item.seller_rate_chart.product products_map[product.id] = product sellers_map[seller_id] = seller sellers_order_item_map[seller_id] = 1 if seller_id in seller_total_map: seller_total_map[seller_id] += (item.sale_price + item.shipping_charges) else: seller_total_map[seller_id] = (item.sale_price + item.shipping_charges) if seller_id in seller_shipping_charges_map: seller_shipping_charges_map[seller_id] += ( item.shipping_charges) else: seller_shipping_charges_map[seller_id] = ( item.shipping_charges) if seller_id in seller_mrp_map: seller_mrp_map[seller_id] += ( item.list_price if item.list_price else item.sale_price) else: seller_mrp_map[seller_id] = (item.list_price if item.list_price else item.sale_price) if seller_id in seller_discount_map: seller_discount_map[seller.id] += (item.list_price - item.sale_price) else: seller_discount_map[seller.id] = (item.list_price - item.sale_price) if seller_id in seller_product_map: seller_product_map[seller_id].append(product) else: seller_product_map[seller_id] = [product] buyer_st = {} subject_st = {} buyer_sms_st = {} subject_sms_st = {} self.fill_attributes(self.order, product, buyer_st, subject_st,\ buyer, products_map, sellers_map, None, qty, seller_total_map, seller_product_map,\ seller_coupon_map, seller_mrp_map, seller_discount_map, seller_shipping_charges_map) self.fill_attributes(self.order, product, buyer_sms_st, subject_sms_st,\ buyer, products_map, sellers_map, None, qty, seller_total_map, seller_product_map,\ seller_coupon_map, seller_mrp_map, seller_discount_map, seller_shipping_charges_map) t_body = get_template('order/buyer_cancelled_order.email') t_sub = get_template('order/buyer_cancelled_order_sub.email') ctxt_body = buyer_st c_body = Context(ctxt_body) ctxt_sub = subject_st c_sub = Context(ctxt_sub) email_sent_from = "%s<order@%s>" % ( self.order.client.name, self.order.client.clientdomain_name) email_body = t_body.render(c_body) email_subject = t_sub.render(c_sub) if buyer.get_primary_emails(): emails = '' for email in buyer.get_primary_emails(): emails += email.email + ',' emails = emails.strip(',') email_to = emails email_bcc = "customerservice@%s" % self.order.client.clientdomain_name else: email_to = "customerservice@%s" % self.order.client.clientdomain_name email_bcc = "" bemail = CEmail() bemail._from = email_sent_from bemail.body = email_body bemail.subject = email_subject bemail.isHtml = True bemail.to = email_to bemail.bcc = email_bcc email_log = LEmail(client_domain=self.request.client, order=self.order, profile=self.order.user, sent_to=email_to[:999], bccied_to=email_bcc, sent_from=email_sent_from, subject=email_subject, body=email_body, status='in_queue', type='buyer_order_cancellation') email_log.save() bemail.email_log_id = email_log.id notifications.append(bemail) sms = SMS() t_sms_body = get_template('order/buyer_cancelled_order.sms') ctxt_sms_body = buyer_sms_st c_sms_body = Context(ctxt_sms_body) sms.text = t_sms_body.render(c_sms_body) sms.to = buyer.primary_phone sms.mask = self.order.client.sms_mask notifications.append(sms) for seller_id in sellers_map: current_seller = sellers_map[seller_id] seller_body = {} seller_sub = {} self.fill_attributes(self.order, product, seller_body,\ seller_sub, buyer, products_map, sellers_map, current_seller, qty, seller_total_map,\ seller_product_map, seller_coupon_map, seller_mrp_map, seller_discount_map, seller_shipping_charges_map) t_body = get_template('order/seller_cancelled_order.email') ctxt_body = seller_body c_body = Context(ctxt_body) t_sub = get_template('order/seller_cancelled_order_sub.email') ctxt_sub = seller_sub c_sub = Context(ctxt_sub) seller_emails = current_seller.get_confirmed_order_notification_email_addresses( ) email_sent_from = "%s<order@%s>" % ( self.order.client.name, self.order.client.clientdomain_name ) #self.order.client.pending_order_email email_body = t_body.render(c_body) email_subject = t_sub.render(c_sub) email_bcc = '' if seller_emails: email_to = seller_emails email_bcc = "fulfillment@%s" % self.order.client.clientdomain_name else: email_to = "fulfillment@%s" % self.order.client.clientdomain_name semail = CEmail() semail._from = email_sent_from semail.body = email_body semail.subject = email_subject semail.to = email_to semail.isHtml = True semail.bcc = email_bcc email_log = LEmail(client_domain=self.request.client, order=self.order, profile=self.order.user, sent_to=email_to[:999], bccied_to=email_bcc, sent_from=email_sent_from, subject=email_subject, body=email_body, status='in_queue', type='seller_order_cancellation') email_log.save() semail.email_log_id = email_log.id notifications.append(semail) return notifications
def getNotifications(self): notifications = [] buyer = self.order.user #if self.order.payment_mode in ['cash-at-store', 'card-at-store']: # Skip notifications for cash and card at store now # Might need to reenable them. Need to move this # checking to domain payment options. # return [] order_items = OrderItem.objects.select_related('seller_rate_chart').filter(order=self.order) product = order_items[0].seller_rate_chart.product qty = order_items[0].qty products_map = {} sellers_map = {} sellers_order_item_map = {} seller_total_map = {} seller_mrp_map = {} seller_offer_price_map = {} seller_discount_map = {} seller_cashback_map ={} seller_shipping_charges_map = {} seller_product_map = {} seller_coupon_map = {} for item in order_items: seller = item.seller_rate_chart.seller seller_id = seller.id product = item.seller_rate_chart.product products_map[product.id] = product sellers_map[seller_id] = seller sellers_order_item_map[seller_id] = 1 if seller_id in seller_total_map: seller_total_map[seller_id] += (item.sale_price + item.shipping_charges) else: seller_total_map[seller_id] = (item.sale_price + item.shipping_charges) if seller_id in seller_shipping_charges_map: seller_shipping_charges_map[seller_id] += (item.shipping_charges) else: seller_shipping_charges_map[seller_id] = (item.shipping_charges) if seller_id in seller_mrp_map: seller_mrp_map[seller_id] += (item.list_price if item.list_price else item.sale_price) else: seller_mrp_map[seller_id] = (item.list_price if item.list_price else item.sale_price) if seller_id in seller_offer_price_map: seller_offer_price_map[seller_id] += item.sale_price else: seller_offer_price_map[seller_id] = item.sale_price if seller_id in seller_discount_map: seller_discount_map[seller.id] += (item.list_price - item.sale_price) else: seller_discount_map[seller.id] = (item.list_price - item.sale_price) if seller_id in seller_cashback_map: seller_cashback_map[seller.id] += item.cashback_amount else: seller_cashback_map[seller.id] = item.cashback_amount if seller_id in seller_product_map: seller_product_map[seller_id].append(product) else: seller_product_map[seller_id] = [product] buyer_st = {} subject_st = {} buyer_sms_st = {} subject_sms_st = {} self.fill_attributes(self.order, order_items[0], product, buyer_st, subject_st,\ buyer, products_map, sellers_map, None, qty, seller_total_map, seller_product_map,\ seller_coupon_map, seller_mrp_map, seller_offer_price_map, seller_discount_map, seller_cashback_map, seller_shipping_charges_map) self.fill_attributes(self.order, order_items[0], product, buyer_sms_st, subject_sms_st,\ buyer, products_map, sellers_map, None, qty, seller_total_map, seller_product_map,\ seller_coupon_map, seller_mrp_map, seller_offer_price_map, seller_discount_map, seller_cashback_map, seller_shipping_charges_map) t_body = get_template('notifications/order/buyer_pending_order.email') t_sub = get_template('notifications/order/buyer_pending_order_sub.email') ctxt_body = buyer_st ctxt_body['clientdomain_name'] = 'www.%s' % self.order.client.clientdomain_name c_body = Context(ctxt_body) ctxt_sub = subject_st c_sub = Context(ctxt_sub) log.info('emails %s' % buyer.get_primary_emails()) email_sent_from = "%s<lead@%s>" % (self.order.client.name, self.order.client.clientdomain_name) email_body = t_body.render(c_body) email_subject = t_sub.render(c_sub) if buyer.get_primary_emails(): emails = '' for email in buyer.get_primary_emails(): emails += email.email + ',' emails = emails.strip(',') email_to = emails log.info('to%s' % email_to) email_bcc = "presales@%s" % self.order.client.clientdomain_name else: email_to = "presales@%s" % self.order.client.clientdomain_name email_bcc = '' bemail = NEmail() bemail._from = email_sent_from bemail.body = email_body bemail.subject = email_subject bemail.isHtml = True bemail.to = email_to bemail.bcc = email_bcc email_to = email_to[:1000] email_log = LEmail(client_domain = self.request.client, order = self.order, profile = self.order.user, sent_to = email_to[:999], bccied_to = email_bcc, sent_from = email_sent_from, subject = email_subject, body = email_body, status = 'in_queue', type = 'buyer_pending_order') email_log.save() bemail.email_log_id = email_log.id if 'buyer' in self.groups: notifications.append(bemail) # elif 'admin' in self.groups: # bemail.to = "presales@%s" % self.order.client.clientdomain_name # notifications.append(bemail) if 'buyer' in self.groups: if buyer.get_primary_phones(): bsms = SMS() t_sms_body = get_template('notifications/order/buyer_pending_order.sms') ctxt_sms_body = buyer_sms_st c_sms_body = Context(ctxt_sms_body) bsms.text = t_sms_body.render(c_sms_body) bsms.to = buyer.get_primary_phones()[0].phone bsms.mask = self.order.client.sms_mask notifications.append(bsms) for seller_id in sellers_map: current_seller = sellers_map[seller_id] seller_body = {} seller_sub = {} self.fill_attributes(self.order, order_items[0], product, seller_body,\ seller_sub, buyer, products_map, sellers_map, current_seller, qty, seller_total_map,\ seller_product_map, seller_coupon_map, seller_mrp_map, seller_offer_price_map, seller_discount_map, seller_cashback_map, seller_shipping_charges_map) t_body = get_template('notifications/order/seller_pending_order.email') ctxt_body = seller_body c_body = Context(ctxt_body) t_sub = get_template('notifications/order/seller_pending_order_sub.email') ctxt_sub = seller_sub c_sub = Context(ctxt_sub) seller_emails = current_seller.get_pending_order_notification_email_addresses() email_sent_from = "%s<lead@%s>" % (self.order.client.name, self.order.client.clientdomain_name) email_body = t_body.render(c_body) email_subject = t_sub.render(c_sub) email_bcc = '' if seller_emails: email_to = seller_emails email_bcc = "fulfillment@%s" % self.order.client.clientdomain_name else: email_to = "fulfillment@%s" % self.order.client.clientdomain_name semail = NEmail() semail._from = email_sent_from semail.body = email_body semail.subject = email_subject semail.to = email_to semail.isHtml = True semail.bcc = email_bcc email_log = LEmail(client_domain = self.request.client, order = self.order, profile = self.order.user, sent_to = email_to[:999], bccied_to = email_bcc, sent_from = email_sent_from, subject = email_subject, body = email_body, status = 'in_queue', type = 'seller_pending_order') email_log.save() semail.email_log_id = email_log.id if 'seller' in self.groups: notifications.append(semail) # elif 'admin' in self.groups: # notifications.append(semail) return notifications
def getNotifications(self): notifications = [] buyer = self.order.user order_items = OrderItem.objects.select_related('seller_rate_chart').filter(order=self.order) product = order_items[0].seller_rate_chart.product qty = order_items[0].qty products_map = {} for item in order_items: seller = item.seller_rate_chart.seller seller_id = seller.id product = item.seller_rate_chart.product products_map[product.id] = product email_body_ctxt = {} email_subject_ctxt = {} sms_body_ctxt = {} sms_subject_ctxt = {} self.fill_attributes(self.order, product, email_body_ctxt, email_subject_ctxt,\ buyer, products_map, qty) self.fill_attributes(self.order, product, sms_body_ctxt, sms_subject_ctxt,\ buyer, products_map, qty) t_body = get_template('notifications/order/shipped_order.email') t_sub = get_template('notifications/order/shipped_order_sub.email') ctxt_body = email_body_ctxt c_body = Context(ctxt_body) ctxt_sub = email_subject_ctxt c_sub = Context(ctxt_sub) email_body = t_body.render(c_body) email_subject = t_sub.render(c_sub) email_sent_from = "%s<fulfillment@%s>" % (self.order.client.name, self.order.client.clientdomain_name) email_bcc, email_to = '', '' if buyer.get_primary_emails(): emails = '' for email in buyer.get_primary_emails(): emails += email.email + ',' email_to = emails.strip(',') email_bcc = "customerservice@%s" % self.order.client.clientdomain_name else: email_to = "customerservice@%s" % self.order.client.clientdomain_name email_bcc = "" bemail = NEmail() bemail.body = email_body bemail.subject = email_subject bemail.to = email_to bemail._from = email_sent_from bemail.bcc = email_bcc bemail.isHtml = True email_log = LEmail(client_domain = self.request.client, order = self.order, profile = self.order.user, sent_to = email_to[:999], bccied_to = email_bcc, sent_from = email_sent_from, subject = email_subject, body = email_body, status = 'in_queue', type = 'shipped_order') email_log.save() bemail.email_log_id = email_log.id notifications.append(bemail) if buyer.get_primary_phones(): sms = SMS() t_sms_body = get_template('notifications/order/shipped_order.sms') ctxt_sms_body = sms_body_ctxt c_sms_body = Context(ctxt_sms_body) sms.text = t_sms_body.render(c_sms_body) sms.to = buyer.get_primary_phones()[0].phone sms.mask = self.order.client.sms_mask notifications.append(sms) return notifications
def getNotifications(self): notifications = [] buyer = self.order.user #if self.order.payment_mode in ['cash-at-store', 'card-at-store']: # Skip notifications for cash and card at store now # Might need to reenable them. Need to move this # checking to domain payment options. # return [] order_items = OrderItem.objects.select_related( 'seller_rate_chart').filter(order=self.order) product = order_items[0].seller_rate_chart.product qty = order_items[0].qty products_map = {} sellers_map = {} sellers_order_item_map = {} seller_total_map = {} seller_mrp_map = {} seller_offer_price_map = {} seller_discount_map = {} seller_cashback_map = {} seller_shipping_charges_map = {} seller_product_map = {} seller_coupon_map = {} for item in order_items: seller = item.seller_rate_chart.seller seller_id = seller.id product = item.seller_rate_chart.product products_map[product.id] = product sellers_map[seller_id] = seller sellers_order_item_map[seller_id] = 1 if seller_id in seller_total_map: seller_total_map[seller_id] += (item.sale_price + item.shipping_charges) else: seller_total_map[seller_id] = (item.sale_price + item.shipping_charges) if seller_id in seller_shipping_charges_map: seller_shipping_charges_map[seller_id] += ( item.shipping_charges) else: seller_shipping_charges_map[seller_id] = ( item.shipping_charges) if seller_id in seller_mrp_map: seller_mrp_map[seller_id] += ( item.list_price if item.list_price else item.sale_price) else: seller_mrp_map[seller_id] = (item.list_price if item.list_price else item.sale_price) if seller_id in seller_offer_price_map: seller_offer_price_map[seller_id] += item.sale_price else: seller_offer_price_map[seller_id] = item.sale_price if seller_id in seller_discount_map: seller_discount_map[seller.id] += (item.list_price - item.sale_price) else: seller_discount_map[seller.id] = (item.list_price - item.sale_price) if seller_id in seller_cashback_map: seller_cashback_map[seller.id] += item.cashback_amount else: seller_cashback_map[seller.id] = item.cashback_amount if seller_id in seller_product_map: seller_product_map[seller_id].append(product) else: seller_product_map[seller_id] = [product] buyer_st = {} subject_st = {} buyer_sms_st = {} subject_sms_st = {} self.fill_attributes(self.order, order_items[0], product, buyer_st, subject_st,\ buyer, products_map, sellers_map, None, qty, seller_total_map, seller_product_map,\ seller_coupon_map, seller_mrp_map, seller_offer_price_map, seller_discount_map, seller_cashback_map, seller_shipping_charges_map) self.fill_attributes(self.order, order_items[0], product, buyer_sms_st, subject_sms_st,\ buyer, products_map, sellers_map, None, qty, seller_total_map, seller_product_map,\ seller_coupon_map, seller_mrp_map, seller_offer_price_map, seller_discount_map, seller_cashback_map, seller_shipping_charges_map) t_body = get_template('notifications/order/buyer_pending_order.email') t_sub = get_template( 'notifications/order/buyer_pending_order_sub.email') ctxt_body = buyer_st ctxt_body[ 'clientdomain_name'] = 'www.%s' % self.order.client.clientdomain_name c_body = Context(ctxt_body) ctxt_sub = subject_st c_sub = Context(ctxt_sub) log.info('emails %s' % buyer.get_primary_emails()) email_sent_from = "%s<lead@%s>" % (self.order.client.name, self.order.client.clientdomain_name) email_body = t_body.render(c_body) email_subject = t_sub.render(c_sub) if buyer.get_primary_emails(): emails = '' for email in buyer.get_primary_emails(): emails += email.email + ',' emails = emails.strip(',') email_to = emails log.info('to%s' % email_to) email_bcc = "presales@%s" % self.order.client.clientdomain_name else: email_to = "presales@%s" % self.order.client.clientdomain_name email_bcc = '' bemail = NEmail() bemail._from = email_sent_from bemail.body = email_body bemail.subject = email_subject bemail.isHtml = True bemail.to = email_to bemail.bcc = email_bcc email_to = email_to[:1000] email_log = LEmail(client_domain=self.request.client, order=self.order, profile=self.order.user, sent_to=email_to[:999], bccied_to=email_bcc, sent_from=email_sent_from, subject=email_subject, body=email_body, status='in_queue', type='buyer_pending_order') email_log.save() bemail.email_log_id = email_log.id if 'buyer' in self.groups: notifications.append(bemail) # elif 'admin' in self.groups: # bemail.to = "presales@%s" % self.order.client.clientdomain_name # notifications.append(bemail) if 'buyer' in self.groups: if buyer.get_primary_phones(): bsms = SMS() t_sms_body = get_template( 'notifications/order/buyer_pending_order.sms') ctxt_sms_body = buyer_sms_st c_sms_body = Context(ctxt_sms_body) bsms.text = t_sms_body.render(c_sms_body) bsms.to = buyer.get_primary_phones()[0].phone bsms.mask = self.order.client.sms_mask notifications.append(bsms) for seller_id in sellers_map: current_seller = sellers_map[seller_id] seller_body = {} seller_sub = {} self.fill_attributes(self.order, order_items[0], product, seller_body,\ seller_sub, buyer, products_map, sellers_map, current_seller, qty, seller_total_map,\ seller_product_map, seller_coupon_map, seller_mrp_map, seller_offer_price_map, seller_discount_map, seller_cashback_map, seller_shipping_charges_map) t_body = get_template( 'notifications/order/seller_pending_order.email') ctxt_body = seller_body c_body = Context(ctxt_body) t_sub = get_template( 'notifications/order/seller_pending_order_sub.email') ctxt_sub = seller_sub c_sub = Context(ctxt_sub) seller_emails = current_seller.get_pending_order_notification_email_addresses( ) email_sent_from = "%s<lead@%s>" % ( self.order.client.name, self.order.client.clientdomain_name) email_body = t_body.render(c_body) email_subject = t_sub.render(c_sub) email_bcc = '' if seller_emails: email_to = seller_emails email_bcc = "fulfillment@%s" % self.order.client.clientdomain_name else: email_to = "fulfillment@%s" % self.order.client.clientdomain_name semail = NEmail() semail._from = email_sent_from semail.body = email_body semail.subject = email_subject semail.to = email_to semail.isHtml = True semail.bcc = email_bcc email_log = LEmail(client_domain=self.request.client, order=self.order, profile=self.order.user, sent_to=email_to[:999], bccied_to=email_bcc, sent_from=email_sent_from, subject=email_subject, body=email_body, status='in_queue', type='seller_pending_order') email_log.save() semail.email_log_id = email_log.id if 'seller' in self.groups: notifications.append(semail) # elif 'admin' in self.groups: # notifications.append(semail) return notifications