Exemplo n.º 1
0
def support_email(request):
    from store_admin.forms import EmailContactForm
    from preferences.models import EmailNotificationHistory
    from django.template.defaultfilters import striptags
    from subscriptions.models import FeaturePayment
    shop = request.shop

    if request.method == "POST":
        txn_id = request.POST.get('txn_id', None)
        payment = FeaturePayment.objects.filter(transaction_id=txn_id,
                                                shop=shop).count()
        if not payment:
            request.flash[
                'message'] = "Your payment is not registered in our system."
            request.flash['severity'] = "error"
            return HttpResponseRedirect(reverse("support"))

        form = EmailContactForm(request.POST)
        if form.is_valid():
            marketplace = request.shop.marketplace
            logging.critical(form.cleaned_data)
            to = marketplace.contact_email
            user_email = form.cleaned_data['email']
            user_question = form.cleaned_data['question']
            user_name = form.cleaned_data['name']

            subject = "Email Support Requested"
            the_message = "%s has request email support from %s <%s>. \n\nUser Email: %s\n\nUser Question: %s" % (
                user_name, shop.name_shop(), shop.default_dns, user_email,
                striptags(user_question))

            mail = EmailMessage(
                subject=subject,
                body=the_message,
                from_email=settings.EMAIL_FROM,
                to=[to],
                headers={
                    'X-SMTPAPI': '{\"category\": \"Email Support Requested\"}'
                })
            mail.send(fail_silently=True)
            #            send_mail(subject, the_message, shop.admin.email, [to], fail_silently=True)

            notification_history = EmailNotificationHistory(
                shop=shop,
                type_notification='CB',
                datetime=datetime.datetime.now(),
                to=to,
                subject=subject,
                body=the_message)
            notification_history.save()

            request.flash['message'] = "Support request sent..."
            request.flash['severity'] = "success"
            return HttpResponseRedirect(reverse("support"))
    else:
        form = EmailContactForm()
    return render_to_response('store_admin/support/email.html', {'form': form},
                              RequestContext(request))
Exemplo n.º 2
0
def support_email(request):
    from store_admin.forms import EmailContactForm
    from preferences.models import EmailNotificationHistory
    from django.template.defaultfilters import striptags
    from subscriptions.models import FeaturePayment
    shop = request.shop
            
    if request.method == "POST":
        txn_id = request.POST.get('txn_id', None)
        payment = FeaturePayment.objects.filter(transaction_id=txn_id, shop=shop).count()
        if not payment:
            request.flash['message'] = "Your payment is not registered in our system."
            request.flash['severity'] = "error"
            return HttpResponseRedirect(reverse("support"))
        
        form = EmailContactForm(request.POST)        
        if form.is_valid():
            marketplace = request.shop.marketplace
            logging.critical(form.cleaned_data)
            to = marketplace.contact_email
            user_email = form.cleaned_data['email']
            user_question = form.cleaned_data['question']
            user_name = form.cleaned_data['name']
            
            subject = "Email Support Requested"
            the_message = "%s has request email support from %s <%s>. \n\nUser Email: %s\n\nUser Question: %s" % (user_name, shop.name_shop(), shop.default_dns, user_email, striptags(user_question))
            
            mail = EmailMessage(subject=subject,
                                body=the_message,
                                from_email=settings.EMAIL_FROM,
                                to=[to],
                                headers={'X-SMTPAPI': '{\"category\": \"Email Support Requested\"}'})
            mail.send(fail_silently=True)
#            send_mail(subject, the_message, shop.admin.email, [to], fail_silently=True)

            notification_history = EmailNotificationHistory(shop=shop,
                                                            type_notification='CB',
                                                            datetime=datetime.datetime.now(),
                                                            to=to,
                                                            subject=subject,
                                                            body=the_message)
            notification_history.save()

            request.flash['message'] = "Support request sent..."
            request.flash['severity'] = "success"
            return HttpResponseRedirect(reverse("support"))                    
    else:
        form = EmailContactForm()    
    return render_to_response('store_admin/support/email.html',
                              {'form': form},
                              RequestContext(request))
Exemplo n.º 3
0
def support_email(request):
    from store_admin.forms import EmailContactForm
    from django.template.defaultfilters import striptags
    from subscriptions.models import FeaturePayment
    shop = request.shop
            
    if request.method == "POST":
        txn_id = request.POST.get('txn_id', None)
        payment = FeaturePayment.objects.filter(transaction_id=txn_id, shop=shop).count()
        if not payment:
            request.flash['message'] = "Your payment is not registered in our system."
            request.flash['severity'] = "error"
            return HttpResponseRedirect(reverse("support"))
        
        form = EmailContactForm(request.POST)        
        if form.is_valid():
            marketplace = request.shop.marketplace
            logging.critical(form.cleaned_data)
            to = marketplace.contact_email
            user_email = form.cleaned_data['email']
            user_question = form.cleaned_data['question']
            user_name = form.cleaned_data['name']
            
            subject = "Email Support Requested"
            
            the_message = "%s has request email support from %s <%s>. \n\nUser Email: %s\n\nUser Question: %s" % (user_name, shop.name_shop(), shop.default_dns, user_email, striptags(user_question))
            
            send_mail(subject, the_message, shop.admin.email, [to], fail_silently=True)
            
            request.flash['message'] = "Support request sent..."
            request.flash['severity'] = "success"
            return HttpResponseRedirect(reverse("support"))                    
    else:
        form = EmailContactForm()    
    return render_to_response('store_admin/support/email.html',
                              {'form': form},
                              RequestContext(request))