Example #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))
Example #2
0
File: fb.py Project: 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()
Example #3
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()
 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
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()
Example #6
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