Exemplo n.º 1
0
def contact_us(request):
    if request.method == "POST":
        form = ContactUsForm(request.POST)
        if form.is_valid():
            contact_us = form.save(commit=False)
            contact_us.submitted_on = datetime.now()
            contact_us.client = request.client.client
            contact_us.save()
            t_body = get_template('notifications/feedback/contactus.email')
            email_body = {}
            email_body['contact_us'] = contact_us
            c_body = Context(email_body)
            mail_obj = Email()
            mail_obj.isHtml = True
            mail_obj._from = request.client.client.noreply_email
            mail_obj.body = t_body.render(c_body)
            mail_obj.subject = "Contact-Us Form"
            u_emails = contact_us.email
            u_emails = u_emails.strip(',')
            mail_obj.to = "*****@*****.**"
            mail_obj.send()
            return render_to_response('pages/about/thank_you-contactus.html',
                                      None,
                                      context_instance=RequestContext(request))
    else:
        form = ContactUsForm()
    return render_to_response('pages/about/contactus.html', {
        'form': form,
    },
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
Arquivo: fb.py Projeto: daasara/riba
def send_coupons_by_email(request,coupon,affiliate_name,email_alert_on, show_avail_coupon):
    t_body = get_template('notifications/subscriptions/%s.email' % affiliate_name)
    email_body = {}
    pantaloon_coupon, bigbazaar_coupon, futurebazaar_coupon = None,None,None
    if show_avail_coupon and affiliate_name not in ["afaqs", "vcomm"]:
        try:
            email_body["coupon_code"] = coupon[str(affiliate_name)]
        except KeyError:
            pass
        try:
            email_body['pantaloon'] =  coupon['pantaloon']
        except KeyError:
            pass
        try:
            email_body['bigbazaar'] =  coupon['bigbazaar']
        except KeyError:
            pass
        try:
            email_body['futurebazaar'] =  coupon['futurebazaar']
        except KeyError:
            pass
    
    mail_obj = Email()
    mail_obj._from = "*****@*****.**"
    mail_obj.body = t_body.render(Context(email_body))
    mail_obj.subject = "Avail your futurebazaar.com coupon codes."
    mail_obj.to = email_alert_on.email
    mail_obj.send()
Exemplo n.º 3
0
def contact_us(request):
    if request.method == "POST":
        form = ContactUsForm(request.POST)
        if form.is_valid():
            contact_us = form.save(commit=False)
            contact_us.submitted_on = datetime.now()
            contact_us.client = request.client.client
            contact_us.save()
            t_body = get_template('notifications/feedback/contactus.email')
            email_body = {}
            email_body['contact_us'] = contact_us
            c_body = Context(email_body)
            mail_obj = Email()
            mail_obj.isHtml = True
            mail_obj._from = request.client.client.noreply_email
            mail_obj.body = t_body.render(c_body)
            mail_obj.subject = "Contact-Us Form"
            u_emails = contact_us.email
            u_emails = u_emails.strip(',')
            mail_obj.to = "*****@*****.**"
            mail_obj.send()
            return render_to_response('pages/about/thank_you-contactus.html',None,context_instance = RequestContext(request))
    else:
        form = ContactUsForm()
    return render_to_response('pages/about/contactus.html', 
        {
            'form':form,
        },context_instance = RequestContext(request))
Exemplo n.º 4
0
def send_coupons_by_email(coupons, affiliate, email_alert_on):
    mail_obj = Email()
    mail_obj.isHtml = True
    mail_obj._from = "*****@*****.**"
    mail_obj.body = render_to_string(
        'notifications/subscriptions/alliance_subscription.html', {
            'affiliate': affiliate,
            'coupon_codes': coupons
        })
    mail_obj.subject = "Avail your futurebazaar.com coupon codes."
    mail_obj.to = email_alert_on.email
    mail_obj.send()
Exemplo n.º 5
0
def send_coupons_by_email(coupons, affiliate, email_alert_on):
    mail_obj = Email()
    mail_obj.isHtml = True
    mail_obj._from = "*****@*****.**"
    mail_obj.body = render_to_string(
        "notifications/subscriptions/alliance_subscription.html", {"affiliate": affiliate, "coupon_codes": coupons}
    )
    mail_obj.subject = "Avail your futurebazaar.com coupon codes."
    mail_obj.to = email_alert_on.email
    mail_obj.send()
Exemplo n.º 6
0
def send_coupons_by_email(request, coupon, affiliate_name, email_alert_on, show_avail_coupon):
    t_body = get_template("notifications/subscriptions/%s.email" % affiliate_name)
    email_body = {}
    pantaloon_coupon, bigbazaar_coupon, futurebazaar_coupon = None, None, None
    if show_avail_coupon and affiliate_name not in ["afaqs", "vcomm"]:
        try:
            email_body["coupon_code"] = coupon[str(affiliate_name)]
        except KeyError:
            pass
        try:
            email_body["pantaloon"] = coupon["pantaloon"]
        except KeyError:
            pass
        try:
            email_body["bigbazaar"] = coupon["bigbazaar"]
        except KeyError:
            pass
        try:
            email_body["futurebazaar"] = coupon["futurebazaar"]
        except KeyError:
            pass

    mail_obj = Email()
    mail_obj._from = "*****@*****.**"
    mail_obj.body = t_body.render(Context(email_body))
    mail_obj.subject = "Avail your futurebazaar.com coupon codes."
    mail_obj.to = email_alert_on.email
    mail_obj.send()
Exemplo n.º 7
0
 def getNotifications(self):
     notifications = []
     t_body = get_template('products/share_product.email')
     t_sub = get_template('products/share_product_sub.email')
     product_body = {}
     product_sub = {}
     self.fillAttributes(self.seller_rate_chart, self.profile, product_body,
                         product_sub)
     if self.profile.primary_email:
         pemail = Email()
         c_body = Context(product_body)
         c_sub = Context(product_sub)
         pemail.body = t_body.render(c_body)
         pemail.subject = t_sub.render(c_sub)
         pemail.to = self.profile.primary_email
         pemail._from = self.seller_rate_chart.seller.share_product_email  #"Chaupaati Bazaar<*****@*****.**>"
         images = ProductImage.objects.filter(
             product=self.seller_rate_chart.product)
         if images:
             thumbnail = images[0]
             pemail.isAttachment = True
             pemail.attachment = thumbnail.image.path
         notifications.append(pemail)
     return notifications
Exemplo n.º 8
0
 def getNotifications(self):
     notifications = []
     t_body = get_template("products/share_product.email")
     t_sub = get_template("products/share_product_sub.email")
     product_body = {}
     product_sub = {}
     self.fillAttributes(self.seller_rate_chart, self.profile, product_body, product_sub)
     if self.profile.primary_email:
         pemail = Email()
         c_body = Context(product_body)
         c_sub = Context(product_sub)
         pemail.body = t_body.render(c_body)
         pemail.subject = t_sub.render(c_sub)
         pemail.to = self.profile.primary_email
         pemail._from = self.seller_rate_chart.seller.share_product_email  # "Chaupaati Bazaar<*****@*****.**>"
         images = ProductImage.objects.filter(product=self.seller_rate_chart.product)
         if images:
             thumbnail = images[0]
             pemail.isAttachment = True
             pemail.attachment = thumbnail.image.path
         notifications.append(pemail)
     return notifications
Exemplo n.º 9
0
def create_notification(**kwargs):
    uid = kwargs['uid']
    notification_name = kwargs['notification_name']
    string_data = kwargs['string_data']
    user = kwargs['user']
    from_user = kwargs['from_user']
    notification_created = kwargs['notification_created']
    bounty = kwargs.get('bounty')
    subject = kwargs['subject']
    platform = kwargs.get('platform', '')
    is_activity = kwargs.get('is_activity', True)
    url = kwargs.get('url', '')

    notification, created = Notification.objects.get_or_create(
        uid=str(uid),
        defaults={
            'notification_name': notification_name,
            'user': user,
            'from_user': from_user,
            'notification_created': notification_created,
            'dashboard': True,
            'platform': platform,
        },
    )

    # this function is atomic, so this is a good way to be sure
    # we never notify more than once
    if not created:
        return

    DashboardNotification.objects.create(
        notification=notification,
        string_data=string_data,
        is_activity=is_activity,
        data={
            'link': url,
            'bounty_title': bounty and bounty.title or kwargs.get('subject')
        },
    )

    # from here on out, all we care about is email
    if not user.email:
        return

    email_settings = user.settings.emails
    activity_emails = email_settings['activity']

    if is_activity and not activity_emails:
        return

    if (not is_activity and notification_name
            not in user.settings.accepted_email_settings()):
        return

    if platform not in settings.PLATFORM_MAPPING:
        return

    if notification.email_sent:
        return

    if notification_name not in Email.templates:
        return

    email = Email(**kwargs)

    email_html = email.render()

    send_email(user.email, subject, email_html)
    notification.email_sent = True
    notification.save()
Exemplo n.º 10
0
datas =  [{'mobile': 9372432527L, 'email': u'*****@*****.**', 'gift': u'Kodak Camera'}, {'mobile': 9850422424L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9765399947L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9850951750L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9028213566L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9373683444L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9325006406L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9620488823L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9916292621L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9880180666L, 'email': u'*****@*****.**', 'gift': u'Nokia Phone'}, {'mobile': 9945422991L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9243558351L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9980885456L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 7829800014L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9902335505L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9985022272L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9975437775L, 'email': u'*****@*****.**', 'gift': u'Philips HT System'}, {'mobile': 9860505208L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9970390733L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9096684138L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9881130436L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 7798577670L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9925566163L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 8866821971L, 'email': u'*****@*****.**', 'gift': u'Kodak Camera'}, {'mobile': 9427027091L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9033005060L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9879010322L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9930008251L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9825234998L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 7898919600L, 'email': u'*****@*****.**', 'gift': u'Philips HT System'}, {'mobile': 957536300, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9752080123L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9826622274L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9826955831L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9179994422L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9425208288L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9664011191L, 'email': u'*****@*****.**', 'gift': u'Philips HT System'}, {'mobile': 9920972223L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9920221979L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9819974559L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9663508080L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9820610341L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9820464872L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9167144350L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9820283870L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9004479635L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9004111420L, 'email': u'*****@*****.**', 'gift': u'Nokia Phone'}, {'mobile': 9930876208L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9892156669L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9820665508L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9560886122L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9999600036L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9582212075L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 8901429324L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9810591907L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9811209373L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9999618985L, 'email': u'*****@*****.**', 'gift': u'Sensei 2GB Mp3 Player'}, {'mobile': 7207842296L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9573637212L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9963034488L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 7893969632L, 'email': u'*****@*****.**', 'gift': u'Kodak Camera'}, {'mobile': 9959963198L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9885699772L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 7702254563L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9406811017L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9977505111L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 8082302726L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 8602660464L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9827244999L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9755549236L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 8085111232L, 'email': u'*****@*****.**', 'gift': u'Sensei 2GB Mp3 Player'}, {'mobile': 9414222553L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9785079497L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9314977702L, 'email': u'*****@*****.**', 'gift': u'Sensei 2GB Mp3 Player'}, {'mobile': 9887636903L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9314470704L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 8233311111L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9828166202L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 8867803364L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9900282726L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 7204852726L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9590864678L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9717583995L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9945036832L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9035494989L, 'email': u'*****@*****.**', 'gift': u'Apple iPad2'}, {'mobile': 9880034445L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9731622811L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9739609893L, 'email': u'*****@*****.**', 'gift': u'Sensei 2GB Mp3 Player'}, {'mobile': 9916330444L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9900664433L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9886673896L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9620204307L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9892556031L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9967400297L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9867063692L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9323955477L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9769288125L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9920061300L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9987097633L, 'email': u'*****@*****.**', 'gift': u'Nokia Phone'}, {'mobile': 9824126128L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 8905377004L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9327919961L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 8000655255L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9913495786L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9974041165L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 7600817769L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9727076465L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9428007524L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9537528634L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9662052517L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9979016660L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9687042726L, 'email': u'*****@*****.**', 'gift': u'Apple iPad2'}, {'mobile': 8767906061L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9819758681L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9769636343L, 'email': u'*****@*****.**', 'gift': u"LG 42' LED TV"}, {'mobile': 9867497175L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9892385115L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9987085828L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9820880505L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9848365125L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 7396518686L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9494400763L, 'email': u'*****@*****.**', 'gift': u'Sensei 2GB Mp3 Player'}, {'mobile': 9885110486L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9959531555L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9985012240L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9395143959L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9836286415L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9051662686L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9830287441L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9689909306L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9029292526L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9923012739L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9730065854L, 'email': u'*****@*****.**', 'gift': u'Apple iPad2'}, {'mobile': 9527120033L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9970350188L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 8097307407L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9664622636L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9833369654L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9925929999L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9727714285L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9979857055L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 8800690466L, 'email': u'*****@*****.**', 'gift': u'Nokia Phone'}, {'mobile': 9868616989L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9717380286L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 7838129159L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9871501911L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9873060564L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 7376811881L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 993572229, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9810730064L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9910790153L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9967080080L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9226767265L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9920309079L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9502665000L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 7702355255L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9392494101L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9930344541L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9272970017L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9769107023L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9434063577L, 'email': u'*****@*****.**', 'gift': u'Kodak Camera'}, {'mobile': 9831983934L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9830477916L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9823375170L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9021703700L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9916626470L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9945705407L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9339938079L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9007216775L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9707912327L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9435343777L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9864688557L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9413380477L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9406669168L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9096311167L, 'email': u'*****@*****.**', 'gift': u'Nokia Phone'}, {'mobile': 9923967878L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9960741852L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9052068884L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9703246575L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9000666930L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9804745564L, 'email': u'*****@*****.**', 'gift': u"LG 42' LED TV"}, {'mobile': 9883102352L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9831030148L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9978537720L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9970769478L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9820066891L, 'email': u'*****@*****.**', 'gift': u'Philips HT System'}, {'mobile': 9869135928L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 8286904848L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 7204085771L, 'email': u'*****@*****.**', 'gift': u'Philips HT System'}, {'mobile': 9739314473L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9535344853L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 8097598807L, 'email': u'*****@*****.**', 'gift': u'Kodak Camera'}, {'mobile': 9167023147L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9833352108L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9619338908L, 'email': u'*****@*****.**', 'gift': u'Apple iPad2'}, {'mobile': 9930777566L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9004260889L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9860980736L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9860124121L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9146492929L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9884493503L, 'email': u'*****@*****.**', 'gift': u'Nokia Phone'}, {'mobile': 9840811975L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9841801885L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9811899299L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9717183177L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9833422118L, 'email': u'*****@*****.**', 'gift': u'Kodak Camera'}, {'mobile': 9769759374L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 8087122887L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9220529385L, 'email': u'*****@*****.**', 'gift': u'Sensei 2GB Mp3 Player'}, {'mobile': 9892736066L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9223289834L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9650596653L, 'email': u'*****@*****.**', 'gift': u'Sensei 2GB Mp3 Player'}, {'mobile': 9811738170L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 7503191832L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9839315155L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9830457865L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 965077064, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9017283717L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9238338180L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9583178633L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9899622155L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9711255579L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9871224075L, 'email': u'*****@*****.**', 'gift': u'Sensei 2GB Mp3 Player'}, {'mobile': 9810104922L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9560244886L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9820608220L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9004613616L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 954011601, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9811726081L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9844009872L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 8050047709L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9903623874L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9830273163L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 8100150200L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9840144810L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9381066505L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9825106925L, 'email': u'*****@*****.**', 'gift': u'Trolley Bag'}, {'mobile': 9824113391L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9998112243L, 'email': u'*****@*****.**', 'gift': u'Fujezone Mini Speakers'}, {'mobile': 9428880804L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9974003318L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9869258876L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9987587236L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9819635629L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9426612822L, 'email': u'*****@*****.**', 'gift': u'Philips DVD Player'}, {'mobile': 9898389990L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9879514018L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 8148872260L, 'email': u'*****@*****.**', 'gift': u'Sensei 2GB Mp3 Player'}, {'mobile': 9043283357L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9884294908L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}, {'mobile': 9886207095L, 'email': u'*****@*****.**', 'gift': u'Sensei 2GB Mp3 Player'}, {'mobile': 9663310652L, 'email': u'*****@*****.**', 'gift': u'Duffle Bag'}, {'mobile': 9731301435L, 'email': u'*****@*****.**', 'gift': u'Haversack Bag'}]


from notifications.email import Email as EmailAddress
from notifications.sms import SMS
from django.template import Context, Template
from django.template.loader import get_template


for data in datas:
    t_body = get_template('notifications/subscriptions/win_winner.email')
    email_body = {}
    email_body['gift'] = data['gift']
    c_body = Context(email_body)
    email_from = {}
    mail_obj = EmailAddress()
    mail_obj.isHtml = True
    mail_obj._from = "promotions.futurebazaar.com"
    mail_obj.body = t_body.render(c_body)
    mail_obj.subject = "Winner"
    u_emails = ""
    email = str(data['email'])
    mail_obj.to = email
    mail_obj.send()
    sms_text = 'Congratulations!! You are the winner of "Scratch in a Flash or Miss the Bash" Contest. Visit win.futurebazaar.com / Call 0922-222-1947 for details'
    sms = SMS()
    sms.text = sms_text
    phone = str(data['mobile'])
    sms.to = phone
    sms.send()
Exemplo n.º 11
0
    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 = {}
        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 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)

        
        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_confirmed_order.email')
            ctxt_body = seller_body
            seller_sub['client_name'] = self.order.client.name
            c_body = Context(ctxt_body)
            t_sub = get_template('order/seller_confirmed_order_sub.email')
            ctxt_sub = seller_sub
            c_sub = Context(ctxt_sub)
            seller_emails = current_seller.get_confirmed_order_notification_email_addresses()
            tmp_emails = seller_emails.split(',')[1:]
            seller_emails = ','.join(email for email in tmp_emails)
            if seller_emails:
                email = Email()
                email.body = t_body.render(c_body)
                email.subject = t_sub.render(c_sub)
                email.to = seller_emails
                email.bcc = "*****@*****.**"
                email._from = "Chaupaati Bazaar<*****@*****.**>"
                notifications.append(email)
            else:
                email = Email()
                email.body = t_body.render(c_body)
                email.subject = t_sub.render(c_sub)
                email.to = "*****@*****.**"
                email._from = "Chaupaati Bazaar<*****@*****.**>"
                notifications.append(email)
        
        return notifications
Exemplo n.º 12
0
    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
Exemplo n.º 13
0
    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
Exemplo n.º 14
0
    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('order/buyer_payment_reminder.email')
        t_sub = get_template('order/buyer_payment_reminder_sub.email')
        ctxt_body = buyer_st
        # We will cancel the order 4 days after booking.
        cancel_time = self.order.timestamp + timedelta(days=4)
        now = datetime.now()
        if now > cancel_time:
            raise Exception(
                "Cannot send payment reminder after cancellation due date")
        remaining = (cancel_time - now)
        if remaining.days:
            ctxt_body['time_remaining'] = '%s days remaining' % remaining.days
        if remaining.days == 1:
            ctxt_body['time_remaining'] = '%s day remaining' % remaining.days
        if remaining.days == 0:
            ctxt_body['time_remaining'] = 'Last day'
        ctxt_body['clientdomain_name'] = 'www.%s' % self.order.client.clientdomain_name
        c_body = Context(ctxt_body)
        ctxt_sub = subject_st
        ctxt_sub['time_remaining'] = ctxt_body['time_remaining']
        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] 
        try:
            cd = ClientDomain.objects.get(client=self.order.client,
                domain = 'www.%s' % self.order.client.clientdomain_name)
            email_log = LEmail(client_domain = cd,
                              order = self.order,
                              profile = self.order.user,
                              sent_to = email_to,
                              bccied_to = email_bcc,
                              sent_from = email_sent_from,
                              subject = email_subject,
                              body = email_body,
                              status = 'in_queue',
                              type = 'buyer_payment_reminder')
            email_log.save()
            bemail.email_log_id = email_log.id
        except Exception:
            log.exception('Error saving payment_reminder log for %s' % self.order.id)

        if 'buyer' in self.groups:
            notifications.append(bemail)

        '''
        if 'buyer' in self.groups:
            if buyer.get_primary_phones():
                bsms = SMS()
                t_sms_body = get_template('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)
        '''      
        return notifications
Exemplo n.º 15
0
from django.db import models
from django.contrib.auth.models import User
from affiliates.models import *
import xlrd
from notifications.notification import Notification
from notifications.email import Email as EmailAddress
from django.template import Context, Template
from django.template.loader import get_template
from django.core.mail import send_mail
from django.template.loader import render_to_string

wb = xlrd.open_workbook('report.xls')
s= wb.sheet_by_index(0)
coupon = Coupon.objects.get(code = 'dclm1010a6d')

for k in range(1,s.nrows):
    row = s.row(k)
    email = row[0].value
    print email
    coupon.uses += 1
    user_email = Email.objects.get(email=email)
    #coupon_email_map = CouponEmailMapping(coupon=coupon,email=user_email)
    #coupon_email_map.save()
    mail_obj = EmailAddress()
    mail_obj.isHtml = True
    mail_obj._from = "*****@*****.**"
    mail_obj.body = render_to_string('notifications/subscriptions/apologize.html',None)
    mail_obj.subject = "Avail your revised futurebazaar.com discount coupon codes"
    mail_obj.to = email
    mail_obj.send()
Exemplo n.º 16
0
    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
Exemplo n.º 17
0
def subscribe_email_link(request, alliance_name=None):
    form = FBRegisterForm()
    url = request.get_full_path()
    if not alliance_name:
        raise Http404
    else:
        affiliate_name = alliance_name.strip()
    try:
        affiliate_subscription = SubscriptionLink.objects.get(path="/" + affiliate_name)
    except:
        raise Http404
    affiliate = affiliate_subscription.affiliate
    affiliate_logo = affiliate.logo
    affiliate_text = affiliate.text
    newsletter = affiliate_subscription.newsletter
    do_post = True
    show_avail_coupon = affiliate.is_coupon_avail
    if affiliate_name == "afaqs":
        do_post = False
    errors = []
    welcome_html = "fb/register_for_deals.html"
    special_offers = ["gift"]
    if affiliate_name in special_offers:
        welcome_html = "fb/register_for_special_offers.html"
    if request.method == "POST":
        form = FBRegisterForm(request.POST)
        error = ""
        already_subscribed = False
        if form.is_valid():
            f = form.cleaned_data
            email_id = f["email"].strip()
            mobile_no = f["mobile"].strip()
            name = f["name"].strip()
            email_user, phone_user, email_alert_on, sms_alert_on = get_user_by_email_or_mobile(email_id, mobile_no)
            html_page = "fb/discount-%s.html" % affiliate_name

            is_valid = True
            _coupon = Voucher.objects.filter(affiliate=affiliate, status="active").order_by("id")
            text = "your"
            total_coupon_codes = {}
            if affiliate.is_coupon_avail:
                if _coupon:
                    _coupon = _coupon[0]
                    total_coupon_codes[affiliate_name] = _coupon.code
                else:
                    errors.append("Sorry!! Coupons are not available")
                    is_valid = False
                if affiliate_name == "esc":
                    total_coupon_codes = assign_coupons(affiliate)
            if is_valid:
                if not email_user and not phone_user:  # new user
                    user, profile = utils.get_or_create_user(email_id, email_id, None, name)

                    email = UserEmail.objects.get(user=profile, type="primary", email=email_id)
                    email_alert_on = email
                    phone = Phone(user=profile, type="primary", phone=mobile_no)
                    phone.save()
                    sms_alert_on = phone
                elif email_user and phone_user:
                    if phone_user == email_user:
                        is_valid = True
                    else:
                        errors.append("Email id and Phone are not registered for the same user.")
                        is_valid = False
                elif (
                    not email_user and phone_user
                ):  # user with phone number already exist, update his email address only
                    errors.append("Mobile number is already subscribed.")
                    is_valid = False
                elif not phone_user and email_user:  # user with email already exist, update his phone number only
                    errors.append("Email address is already subscribed.")
                    is_valid = False

            if not is_valid:
                return render_to_response(
                    welcome_html,
                    {
                        "form": form,
                        "affiliate_logo": affiliate_logo,
                        "affiliate_text": affiliate_text,
                        "affiliate_name": affiliate_name,
                        "do_post": do_post,
                        "errors": errors,
                    },
                    context_instance=RequestContext(request),
                )
            url = request.get_full_path()
            existing_subscription_email = DailySubscription.objects.filter(
                newsletter=newsletter, email_alert_on=email_alert_on, source=affiliate_name
            )
            existing_subscription_phone = DailySubscription.objects.filter(
                newsletter=newsletter, sms_alert_on=sms_alert_on, source=affiliate_name
            )
            if affiliate_name in ["vcomm", "affinity", "tyroo"]:
                existing_subscription_email = DailySubscription.objects.filter(email_alert_on=email_alert_on)
                existing_subscription_phone = None
            if not existing_subscription_email and not existing_subscription_phone:
                subscribe = DailySubscription()
                subscribe.newsletter = newsletter
                subscribe.sms_alert_on = sms_alert_on
                subscribe.email_alert_on = email_alert_on
                subscribe.source = affiliate_name
                subscribe.save()

                if request.POST.get("selected_affiliates", "") == "selected_affiliates":

                    t_body = get_template("notifications/users/affiliates_afaqs.email")
                    email_body = {}
                    email_body["request"] = request
                    email_body["name"] = name
                    c_body = Context(email_body)
                    t_subject = get_template("notifications/users/subscribe_sub.email")
                    email_from = {}
                    email_subject = {}
                    c_subject = Context(email_subject)
                    mail_obj = EmailAddress()
                    if is_future_ecom(request.client.client):
                        mail_obj.isHtml = True
                    mail_obj._from = request.client.client.promotions_email
                    mail_obj.body = t_body.render(c_body)
                    mail_obj.subject = t_subject.render(c_subject)
                    u_emails = ""
                    email = str(email_id)
                    u_emails = email.strip(",")
                    mail_obj.to = u_emails
                    mail_obj.send()

                    utils.subscribe_send_sms(mobile_no)
                    return HttpResponseRedirect("/")

                if not affiliate.is_coupon_avail:
                    if affiliate_name in special_offers:
                        send_coupons_by_email(
                            request, total_coupon_codes, affiliate_name, email_alert_on, show_avail_coupon
                        )
                        send_coupons_by_sms(
                            request, total_coupon_codes, affiliate_name, sms_alert_on, show_avail_coupon
                        )
                    else:
                        utils.subscribe_send_email(request, email_id, name)
                        utils.subscribe_send_sms(mobile_no)
                    return render_to_response(
                        "fb/thankyou-%s.html" % affiliate_name,
                        {"email_id": email_id},
                        context_instance=RequestContext(request),
                    )

                if email_alert_on:
                    send_coupons_by_email(
                        request, total_coupon_codes, affiliate_name, email_alert_on, show_avail_coupon
                    )

                if sms_alert_on:
                    send_coupons_by_sms(request, total_coupon_codes, affiliate_name, sms_alert_on, show_avail_coupon)

                if affiliate_name != "esc":
                    _coupon.status = "inactive"
                    _coupon.save()
            else:
                errors.append("You have already subscribed for the deal.")
                already_subscribed = True
                is_valid = False

            if affiliate_name in ["vcomm", "affinity", "tyroo"]:
                return render_to_response(
                    "fb/subscribed.html",
                    {"affiliate_name": affiliate_name, "already_subscribed": already_subscribed},
                    context_instance=RequestContext(request),
                )

            if is_valid:
                return render_to_response(
                    html_page,
                    {
                        "affiliate_name": affiliate_name,
                        "coupon_codes": total_coupon_codes,
                        "already_subscribed": already_subscribed,
                    },
                    context_instance=RequestContext(request),
                )
    return render_to_response(
        welcome_html,
        {
            "form": form,
            "affiliate_logo": affiliate_logo,
            "affiliate_text": affiliate_text,
            "affiliate_name": affiliate_name,
            "do_post": do_post,
            "errors": errors,
            "show_avail_coupon": show_avail_coupon,
        },
        context_instance=RequestContext(request),
    )
Exemplo n.º 18
0
    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 = {}
        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 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)

        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_confirmed_order.email')
            ctxt_body = seller_body
            seller_sub['client_name'] = self.order.client.name
            c_body = Context(ctxt_body)
            t_sub = get_template('order/seller_confirmed_order_sub.email')
            ctxt_sub = seller_sub
            c_sub = Context(ctxt_sub)
            seller_emails = current_seller.get_confirmed_order_notification_email_addresses(
            )
            tmp_emails = seller_emails.split(',')[1:]
            seller_emails = ','.join(email for email in tmp_emails)
            if seller_emails:
                email = Email()
                email.body = t_body.render(c_body)
                email.subject = t_sub.render(c_sub)
                email.to = seller_emails
                email.bcc = "*****@*****.**"
                email._from = "Chaupaati Bazaar<*****@*****.**>"
                notifications.append(email)
            else:
                email = Email()
                email.body = t_body.render(c_body)
                email.subject = t_sub.render(c_sub)
                email.to = "*****@*****.**"
                email._from = "Chaupaati Bazaar<*****@*****.**>"
                notifications.append(email)

        return notifications
Exemplo n.º 19
0
    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
Exemplo n.º 20
0
    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
Exemplo n.º 21
0
    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
Exemplo n.º 22
0
Arquivo: fb.py Projeto: daasara/riba
def subscribe_email_link(request, alliance_name=None):
    form = FBRegisterForm()
    url = request.get_full_path()
    if not alliance_name:
        raise Http404
    else:
        affiliate_name = alliance_name.strip()
    try:
        affiliate_subscription = SubscriptionLink.objects.get(path='/'+affiliate_name)
    except:
        raise Http404
    affiliate = affiliate_subscription.affiliate
    affiliate_logo = affiliate.logo
    affiliate_text = affiliate.text
    newsletter = affiliate_subscription.newsletter
    do_post = True
    show_avail_coupon = affiliate.is_coupon_avail
    if affiliate_name == "afaqs":
        do_post = False
    errors = []
    welcome_html = 'fb/register_for_deals.html'
    special_offers = ['gift']
    if affiliate_name in special_offers:
        welcome_html = 'fb/register_for_special_offers.html'
    if request.method == 'POST':
        form = FBRegisterForm(request.POST)
        error=''
        already_subscribed = False
        if form.is_valid():
            f=form.cleaned_data
            email_id = f['email'].strip()
            mobile_no = f['mobile'].strip()
            name = f['name'].strip()
            email_user,phone_user,email_alert_on,sms_alert_on = get_user_by_email_or_mobile(email_id,mobile_no)
            html_page = 'fb/discount-%s.html' % affiliate_name

            is_valid = True
            _coupon = Voucher.objects.filter(affiliate= affiliate, status="active").order_by('id')
            text = 'your' 
            total_coupon_codes ={}
            if affiliate.is_coupon_avail:
                if _coupon:
                    _coupon = _coupon[0]
                    total_coupon_codes[affiliate_name] = _coupon.code
                else:
                    errors.append("Sorry!! Coupons are not available")
                    is_valid = False
                if affiliate_name == 'esc':
                    total_coupon_codes = assign_coupons(affiliate)
            if is_valid:
                if not email_user and not phone_user: #new user
                    user,profile = utils.get_or_create_user(email_id, email_id, None, name)

                    email = UserEmail.objects.get(user=profile,type='primary',email=email_id)
                    email_alert_on = email
                    phone = Phone(user=profile,type='primary',phone=mobile_no)
                    phone.save()
                    sms_alert_on = phone
                elif email_user and phone_user:
                    if phone_user == email_user:
                        is_valid = True
                    else:
                        errors.append('Email id and Phone are not registered for the same user.')
                        is_valid = False
                elif not email_user and phone_user: #user with phone number already exist, update his email address only
                    errors.append('Mobile number is already subscribed.')
                    is_valid = False
                elif not phone_user and email_user: #user with email already exist, update his phone number only
                    errors.append('Email address is already subscribed.')
                    is_valid = False
                
            if not is_valid:
                return render_to_response(welcome_html,
                    {
                        'form':form,
                        'affiliate_logo':affiliate_logo,
                        'affiliate_text':affiliate_text,
                        'affiliate_name':affiliate_name,
                        'do_post':do_post,
                        'errors':errors,
                    },context_instance = RequestContext(request))
            url = request.get_full_path()
            existing_subscription_email = DailySubscription.objects.filter(newsletter=newsletter,email_alert_on=email_alert_on,source = affiliate_name)
            existing_subscription_phone = DailySubscription.objects.filter(newsletter=newsletter,sms_alert_on=sms_alert_on,source = affiliate_name)
            if affiliate_name in ["vcomm",'affinity','tyroo']:
                existing_subscription_email = DailySubscription.objects.filter(email_alert_on=email_alert_on)
                existing_subscription_phone = None
            if not existing_subscription_email and not existing_subscription_phone:
                subscribe = DailySubscription()
                subscribe.newsletter = newsletter
                subscribe.sms_alert_on = sms_alert_on
                subscribe.email_alert_on = email_alert_on
                subscribe.source = affiliate_name
                subscribe.save()

                if request.POST.get("selected_affiliates","") == "selected_affiliates":

                    t_body = get_template('notifications/users/affiliates_afaqs.email')
                    email_body = {}
                    email_body['request'] = request
                    email_body['name'] = name
                    c_body = Context(email_body)
                    t_subject = get_template('notifications/users/subscribe_sub.email')
                    email_from = {}
                    email_subject = {}
                    c_subject = Context(email_subject)
                    mail_obj = EmailAddress()
                    if is_future_ecom(request.client.client):
                        mail_obj.isHtml = True
                    mail_obj._from = request.client.client.promotions_email
                    mail_obj.body = t_body.render(c_body)
                    mail_obj.subject = t_subject.render(c_subject)
                    u_emails = ""
                    email = str(email_id)
                    u_emails = email.strip(',')
                    mail_obj.to = u_emails
                    mail_obj.send()

                    utils.subscribe_send_sms(mobile_no)
                    return HttpResponseRedirect("/")
                
                if not affiliate.is_coupon_avail:
                    if affiliate_name in special_offers:
                        send_coupons_by_email(request, total_coupon_codes, affiliate_name, email_alert_on, show_avail_coupon)
                        send_coupons_by_sms(request, total_coupon_codes, affiliate_name, sms_alert_on, show_avail_coupon)
                    else:
                        utils.subscribe_send_email(request,email_id, name)
                        utils.subscribe_send_sms(mobile_no)
                    return render_to_response('fb/thankyou-%s.html' % affiliate_name,{'email_id':email_id},context_instance = RequestContext(request))
                    
                if email_alert_on:
                    send_coupons_by_email(request, total_coupon_codes, affiliate_name, email_alert_on, show_avail_coupon)

                if sms_alert_on:
                    send_coupons_by_sms(request, total_coupon_codes, affiliate_name, sms_alert_on, show_avail_coupon)

                if affiliate_name != 'esc': 
                    _coupon.status = "inactive"
                    _coupon.save()
            else:
                errors.append("You have already subscribed for the deal.")
                already_subscribed = True
                is_valid = False

            if affiliate_name in ["vcomm",'affinity','tyroo']:
                return render_to_response('fb/subscribed.html',
                    {'affiliate_name':affiliate_name,'already_subscribed':already_subscribed},
                    context_instance = RequestContext(request))
    
            if is_valid: 
                return render_to_response(html_page,
                    {'affiliate_name':affiliate_name,'coupon_codes':total_coupon_codes, 'already_subscribed':already_subscribed},
                    context_instance = RequestContext(request))
    return render_to_response(welcome_html,
        {
            'form':form,
            'affiliate_logo':affiliate_logo,
            'affiliate_text':affiliate_text,
            'affiliate_name':affiliate_name,
            'do_post':do_post,
            'errors':errors,
            'show_avail_coupon':show_avail_coupon,
        },
        context_instance = RequestContext(request))