fix cart app

remotes/origin/HEAD
Max Yakovenko 8 years ago
parent b07079b1e8
commit b8600fe84c
  1. 4
      cart/forms.py
  2. 5
      cart/tasks.py

@ -162,7 +162,7 @@ class CartCheckoutForm(RequestNotifiable, forms.ModelForm):
'order_id': self.instance.id, 'order_id': self.instance.id,
'site_url': request.build_absolute_uri(), 'site_url': request.build_absolute_uri(),
} }
return send_user_order_notification.delay(context=context) return send_user_order_notification(context=context)
def send_order_request(self, request): def send_order_request(self, request):
context = { context = {
@ -175,7 +175,7 @@ class CartCheckoutForm(RequestNotifiable, forms.ModelForm):
'send_at_date': self.instance.create_at, 'send_at_date': self.instance.create_at,
} }
return send_admin_order_notification.delay(context=context) return send_admin_order_notification(context=context)
class Meta: class Meta:
model = Order model = Order

@ -9,13 +9,12 @@ from django.core.mail import EmailMessage, EmailMultiAlternatives
from cart.models import Order from cart.models import Order
@celery.task() @celery.task()
def send_user_order_notification(context): def send_user_order_notification(context):
""" """
Sending Email of order creating Sending Email of order creating
""" """
order = Order.active.get(pk=context['order_id']) order = Order.objects.get(pk=context['order_id'])
verb_price = pytils.numeral.in_words(round(order.total_price)) verb_price = pytils.numeral.in_words(round(order.total_price))
verb_cur = pytils.numeral.choose_plural(round(order.total_price), ("рубль", "рубля", "рублей")) verb_cur = pytils.numeral.choose_plural(round(order.total_price), ("рубль", "рубля", "рублей"))
subject = 'Заказ № {}'.format(order.id) subject = 'Заказ № {}'.format(order.id)
@ -26,7 +25,7 @@ def send_user_order_notification(context):
# html = render_to_string('orders:AdminOrderPDF', args=[order_id]) # html = render_to_string('orders:AdminOrderPDF', args=[order_id])
html = render_to_string('orders/pdf.html', {**settings.PAY_REQUISITES, 'order': order, html = render_to_string('cart/order_invoice.html', {**settings.PAY_REQUISITES, 'order': order,
'verb_cur': verb_cur, 'verb_price': verb_price}) 'verb_cur': verb_cur, 'verb_price': verb_price})
rendered_html = html.encode(encoding="UTF-8") rendered_html = html.encode(encoding="UTF-8")
out = BytesIO() out = BytesIO()

Loading…
Cancel
Save