def get(self, request, order_id, receipt_code): order_id = int(order_id) order_confirmed = request.session.pop('order_confirmed', None) try: order = Order.objects.prefetch_related('billing_address', 'shipping_address', 'payment_method', 'currency', 'items').get(id=order_id, receipt_code=receipt_code) except Order.DoesNotExist: raise Http404() if order_confirmed: # Sending order confirmation email to user's billing email address context = Context( {'order': order, 'user': request.user, 'SITE_NAME': settings.SITE_NAME, 'DOMAIN': settings.DOMAIN}) msg_subject = get_template("sales/email/order_confirmation_subject.txt").render(context) context = Context({'order': order, 'user': request.user, 'SITE_NAME': settings.SITE_NAME, 'DOMAIN': settings.DOMAIN}) msg_text = get_template("sales/email/order_confirmation.html").render(context) to_email = '%s <%s>' % (order.billing_address.get_name(), order.billing_address.email) send_mail(msg_subject, msg_text, [to_email], True) self.order_id = order_id self.receipt_code = receipt_code return super(CheckoutReceiptView, self).get(request, order=order, order_confirmed=order_confirmed)
def post(self, request): error = None success = None email = request.POST.get('email', None) if email: email = email.strip() try: user = User.objects.get_reset_code(email) # Sending password reset link email to user context = Context({ 'user': user, 'SITE_NAME': self.get_config('SITE_NAME'), 'DOMAIN': self.get_config('DOMAIN') }) msg_subject = get_template( "accounts/email/password_reset_subject.txt").render( context) context = Context({ 'user': user, 'SITE_NAME': self.get_config('SITE_NAME'), 'DOMAIN': self.get_config('DOMAIN') }) msg_text = get_template( "accounts/email/password_reset.html").render(context) to_email = '%s <%s>' % (user.get_full_name(), user.email) send_mail(msg_subject, msg_text, [to_email], True) success = 'Password reset intructions has been sent to your email address.' except DoorsaleError as e: error = e.message return self.get(request, error=error, success=success)
def post(self, request): error = None try: cart_id = request.session['cart_id'] payment_method = request.session['payment_method'] po_number = request.session.get('po_number', None) billing_address_id = request.session[CheckoutBillingView.session_address_key] shipping_address_id = request.session[CheckoutShippingView.session_address_key] if payment_method == PaymentMethod.CREDIT_CARD: raise DoorsaleError('Payment method not supported: %s' % PaymentMethod.ALL_METHODS[payment_method]) if request.user.is_authenticated(): user = request.user username = str(user) else: user = None username = str(request.user) currency_code = self.request.session.get('default_currency', self.primary_currency.code) order = Order.objects.place(cart_id, billing_address_id, shipping_address_id, payment_method, po_number, currency_code, user, username) del request.session['cart_id'] del request.session['payment_method'] del request.session['billing_address'] del request.session['shipping_address'] request.session['order_confirmed'] = True # Sending order confirmation email to user's billing email address msg_subject = get_template("sales/email/order_confirmation_subject.txt").render(Context({'order': order, 'user': request.user, 'SITE_NAME': settings.SITE_NAME, 'DOMAIN': settings.DOMAIN })) msg_text = get_template("sales/email/order_confirmation.html").render(Context({'order': order, 'user': request.user, 'SITE_NAME': settings.SITE_NAME, 'DOMAIN': settings.DOMAIN })) to_email = '%s <%s>' % (order.billing_address.get_name(), order.billing_address.email) send_mail(msg_subject, msg_text, [to_email], True) return HttpResponseRedirect(reverse('sales_checkout_receipt', args=[order.id, order.receipt_code])) except DoorsaleError as e: error = e.message return self.get(request, error=error)
def get(self, request, order_id, receipt_code): order_id = int(order_id) order_confirmed = request.session.pop("order_confirmed", None) try: order = Order.objects.prefetch_related( "billing_address", "shipping_address", "payment_method", "currency", "items" ).get(id=order_id, receipt_code=receipt_code) except Order.DoesNotExist: raise Http404() if order_confirmed: # Sending order confirmation email to user's billing email address context = Context( { "order": order, "user": request.user, "SITE_NAME": self.get_config("SITE_NAME"), "DOMAIN": self.get_config("DOMAIN"), } ) msg_subject = get_template("sales/email/order_confirmation_subject.txt").render(context) context = Context( { "order": order, "user": request.user, "SITE_NAME": self.get_config("SITE_NAME"), "DOMAIN": self.get_config("SITE_NAME"), } ) msg_text = get_template("sales/email/order_confirmation.html").render(context) to_email = "%s <%s>" % (order.billing_address.get_name(), order.billing_address.email) send_mail(msg_subject, msg_text, [to_email], True) self.order_id = order_id self.receipt_code = receipt_code return super(CheckoutReceiptView, self).get(request, order=order, order_confirmed=order_confirmed)
def post(self, request): error = None success = None email = request.POST.get('email', None) if email: email = email.strip() try: user = User.objects.get_reset_code(email) # Sending password reset link email to user context = Context({'user': user, 'SITE_NAME': settings.SITE_NAME, 'DOMAIN': settings.DOMAIN}) msg_subject = get_template("accounts/email/password_reset_subject.txt").render(context) context = Context({'user': user, 'SITE_NAME': settings.SITE_NAME, 'DOMAIN': settings.DOMAIN}) msg_text = get_template("accounts/email/password_reset.html").render(context) to_email = '%s <%s>' % (user.get_full_name(), user.email) send_mail(msg_subject, msg_text, [to_email], True) success = 'Password reset intructions has been sent to your email address.' except DoorsaleError as e: error = e.message return self.get(request, error=error, success=success)
def post(self, request): error = None try: cart_id = request.session['cart_id'] payment_method = request.session['payment_method'] po_number = request.session.get('po_number', None) billing_address_id = request.session[ CheckoutBillingView.session_address_key] shipping_address_id = request.session[ CheckoutShippingView.session_address_key] if payment_method == PaymentMethod.CREDIT_CARD: raise DoorsaleError('Payment method not supported: %s' % PaymentMethod.ALL_METHODS[payment_method]) if request.user.is_authenticated(): user = request.user username = str(user) else: user = None username = str(request.user) currency_code = self.request.session.get( 'default_currency', self.primary_currency.code) order = Order.objects.place(cart_id, billing_address_id, shipping_address_id, payment_method, po_number, currency_code, user, username) del request.session['cart_id'] del request.session['payment_method'] del request.session['billing_address'] del request.session['shipping_address'] request.session['order_confirmed'] = True # Sending order confirmation email to user's billing email address msg_subject = get_template( "sales/email/order_confirmation_subject.txt").render( Context({ 'order': order, 'user': request.user, 'SITE_NAME': settings.SITE_NAME, 'DOMAIN': settings.DOMAIN })) msg_text = get_template( "sales/email/order_confirmation.html").render( Context({ 'order': order, 'user': request.user, 'SITE_NAME': settings.SITE_NAME, 'DOMAIN': settings.DOMAIN })) to_email = '%s <%s>' % (order.billing_address.get_name(), order.billing_address.email) send_mail(msg_subject, msg_text, [to_email], True) return HttpResponseRedirect( reverse('sales_checkout_receipt', args=[order.id, order.receipt_code])) except DoorsaleError as e: error = e.message return self.get(request, error=error)