def btn_confirm_order_ajax(request): if not request.is_ajax(): raise Http404 user = request.user customer = Customer.objects.filter( user_id=user.id, may_order=True).order_by('?').first() if customer is None: raise Http404 translation.activate(customer.language) permanence_id = sint(request.GET.get('permanence', 0)) permanence = Permanence.objects.filter(id=permanence_id).order_by('?').first() permanence_ok_or_404(permanence) customer_invoice = CustomerInvoice.objects.filter( permanence_id=permanence_id, customer_id=customer.id, is_order_confirm_send=False, is_group=False, ).order_by('?').first() if customer_invoice is None: raise Http404 filename = "{}-{}.xlsx".format( _("Order"), permanence ) export_order_2_1_customer(customer, filename, permanence) customer_invoice.confirm_order() customer_invoice.save() json_dict = my_basket(customer_invoice.is_order_confirm_send, customer_invoice.get_total_price_with_tax()) if customer_invoice.delivery is not None: status = customer_invoice.delivery.status else: status = customer_invoice.status basket_message = get_html_basket_message( customer, permanence, status ) json_dict.update(customer_invoice.get_html_my_order_confirmation( permanence=permanence, is_basket=True, basket_message=basket_message )) return JsonResponse(json_dict)
def btn_confirm_order_ajax(request): if not request.is_ajax(): raise Http404 user = request.user customer = Customer.objects.filter(user_id=user.id, may_order=True).order_by('?').first() if customer is None: raise Http404 translation.activate(customer.language) permanence_id = sint(request.GET.get('permanence', 0)) permanence = Permanence.objects.filter( id=permanence_id).order_by('?').first() if permanence is None: raise Http404 customer_invoice = CustomerInvoice.objects.filter( permanence_id=permanence_id, customer_id=customer.id, is_order_confirm_send=False, is_group=False, ).order_by('?').first() if customer_invoice is None: raise Http404 filename = "{0}-{1}.xlsx".format(_("Order"), permanence) export_order_2_1_customer(customer, filename, permanence) customer_invoice.confirm_order() customer_invoice.save() json_dict = my_basket(customer_invoice.is_order_confirm_send, customer_invoice.get_total_price_with_tax()) if customer_invoice.delivery is not None: status = customer_invoice.delivery.status else: status = customer_invoice.status basket_message = get_html_basket_message(customer, permanence, status) json_dict.update( customer_invoice.get_html_my_order_confirmation( permanence=permanence, is_basket=True, basket_message=basket_message)) return JsonResponse(json_dict)
def order_ajax(request): if not request.is_ajax(): raise Http404 user = request.user customer = Customer.objects.filter( user_id=user.id, may_order=True ).order_by('?').first() if customer is None: raise Http404 offer_item_id = sint(request.GET.get('offer_item', 0)) value_id = sint(request.GET.get('value', 0)) is_basket = sboolean(request.GET.get('is_basket', False)) qs = CustomerInvoice.objects.filter( permanence__offeritem=offer_item_id, customer_id=customer.id, status=PERMANENCE_OPENED).order_by('?') json_dict = {} if qs.exists(): qs = ProducerInvoice.objects.filter( permanence__offeritem=offer_item_id, producer__offeritem=offer_item_id, status=PERMANENCE_OPENED ).order_by('?') if qs.exists(): purchase, updated = create_or_update_one_cart_item( customer=customer, offer_item_id=offer_item_id, value_id=value_id, batch_job=False, comment=EMPTY_STRING ) offer_item = OfferItemWoReceiver.objects.filter( id=offer_item_id ).order_by('?').first() if purchase is None: json_dict["#offer_item{}".format(offer_item.id)] = get_html_selected_value(offer_item, DECIMAL_ZERO, is_open=True) else: json_dict["#offer_item{}".format(offer_item.id)] = get_html_selected_value(offer_item, purchase.quantity_ordered, is_open=True) if updated and offer_item.is_box: # update the content for content in BoxContent.objects.filter( box=offer_item.product_id ).only( "product_id" ).order_by('?'): box_offer_item = OfferItemWoReceiver.objects.filter( product_id=content.product_id, permanence_id=offer_item.permanence_id ).order_by('?').first() if box_offer_item is not None: # Select one purchase purchase = PurchaseWoReceiver.objects.filter( customer_id=customer.id, offer_item_id=box_offer_item.id, is_box_content=False ).order_by('?').only('quantity_ordered').first() if purchase is not None: json_dict["#offer_item{}".format(box_offer_item.id)] = get_html_selected_value( box_offer_item, purchase.quantity_ordered, is_open=True ) box_purchase = PurchaseWoReceiver.objects.filter( customer_id=customer.id, offer_item_id=box_offer_item.id, is_box_content=True ).order_by('?').only('quantity_ordered').first() if box_purchase is not None: json_dict["#box_offer_item{}".format(box_offer_item.id)] = get_html_selected_box_value( box_offer_item, box_purchase.quantity_ordered ) if settings.REPANIER_SETTINGS_SHOW_PRODUCER_ON_ORDER_FORM: producer_invoice = ProducerInvoice.objects.filter( producer_id=offer_item.producer_id, permanence_id=offer_item.permanence_id ).only("total_price_with_tax").order_by('?').first() json_dict.update(producer_invoice.get_order_json()) customer_invoice = CustomerInvoice.objects.filter( permanence_id=offer_item.permanence_id, customer_id=customer.id ).order_by('?').first() invoice_confirm_status_is_changed = customer_invoice.cancel_confirm_order() if settings.REPANIER_SETTINGS_CUSTOMER_MUST_CONFIRM_ORDER and invoice_confirm_status_is_changed: template_name = get_repanier_template_name("communication_confirm_order.html") html = render_to_string(template_name) json_dict["#communicationModal"] = mark_safe(html) customer_invoice.save() json_dict.update( my_basket(customer_invoice.is_order_confirm_send, customer_invoice.get_total_price_with_tax())) permanence = Permanence.objects.filter( id=offer_item.permanence_id ).order_by('?').first() if is_basket: basket_message = get_html_basket_message(customer, permanence, PERMANENCE_OPENED) else: basket_message = EMPTY_STRING json_dict.update(customer_invoice.get_html_my_order_confirmation( permanence=permanence, is_basket=is_basket, basket_message=basket_message )) return JsonResponse(json_dict)
def order_init_ajax(request): if not request.is_ajax(): raise Http404 permanence_id = sint(request.GET.get('pe', 0)) permanence = Permanence.objects.filter( id=permanence_id).order_by('?').first() permanence_ok_or_404(permanence) user = request.user customer = Customer.objects.filter(user_id=user.id, may_order=True).only( "id", "vat_id", "short_basket_name", "email2", "delivery_point", "balance", "date_balance", "may_order").order_by('?').first() if customer is None: raise Http404 customer_invoice = CustomerInvoice.objects.filter( permanence_id=permanence.id, customer_id=customer.id).order_by('?').first() if customer_invoice is None: customer_invoice = CustomerInvoice.objects.create( permanence_id=permanence.id, customer_id=customer.id, status=permanence.status, customer_charged_id=customer.id, ) customer_invoice.set_delivery(delivery=None) customer_invoice.save() if customer_invoice is None: raise Http404 basket = sboolean(request.GET.get('ba', False)) if customer_invoice.delivery is not None: status = customer_invoice.delivery.status else: status = customer_invoice.status if status <= PERMANENCE_OPENED: basket_message = get_html_basket_message(customer, permanence, status) else: if customer_invoice.delivery is not None: basket_message = EMPTY_STRING else: basket_message = "{}".format(_('The orders are closed.')) json_dict = customer_invoice.get_html_my_order_confirmation( permanence=permanence, is_basket=basket, basket_message=basket_message) if customer.may_order: if settings.REPANIER_SETTINGS_SHOW_PRODUCER_ON_ORDER_FORM: for producer_invoice in ProducerInvoice.objects.filter( permanence_id=permanence.id).only("total_price_with_tax", "status").order_by('?'): json_dict.update(producer_invoice.get_order_json()) communication = sboolean(request.GET.get('co', False)) if communication: now = timezone.now() permanence_boards = PermanenceBoard.objects.filter( customer_id=customer.id, permanence_date__gte=now, permanence__status__lte=PERMANENCE_WAIT_FOR_INVOICED).order_by( "permanence_date")[:2] from repanier.apps import REPANIER_SETTINGS_MAX_WEEK_WO_PARTICIPATION if REPANIER_SETTINGS_MAX_WEEK_WO_PARTICIPATION > DECIMAL_ZERO or len( permanence_boards) > 0: if len(permanence_boards) == 0: count_activity = PermanenceBoard.objects.filter( customer_id=customer.id, permanence_date__lt=now, permanence_date__gte=now - datetime.timedelta(days=float( REPANIER_SETTINGS_MAX_WEEK_WO_PARTICIPATION) * 7)).count() else: count_activity = None html = render_to_string( 'repanier/communication_permanence_board.html', { 'permanence_boards': permanence_boards, 'count_activity': count_activity }) json_dict["#communicationModal"] = mark_safe(html) json_dict.update( my_basket(customer_invoice.is_order_confirm_send, customer_invoice.get_total_price_with_tax())) return JsonResponse(json_dict)
def get_context_data(self, **kwargs): from repanier.apps import ( REPANIER_SETTINGS_DISPLAY_ANONYMOUS_ORDER_FORM, REPANIER_SETTINGS_CONFIG, REPANIER_SETTINGS_NOTIFICATION, ) context = super(OrderView, self).get_context_data(**kwargs) context["first_page"] = self.first_page context["permanence"] = self.permanence context["permanence_id"] = self.permanence.id context["all_dates"] = self.all_dates context["date_id"] = self.date_id context["date_Selected"] = self.date_selected context[ "notification"] = REPANIER_SETTINGS_NOTIFICATION.get_notification_display( ) if self.first_page: if settings.REPANIER_SETTINGS_SHOW_PRODUCER_ON_ORDER_FORM: producer_set = Producer.objects.filter( permanence=self.permanence.id).only( "id", "short_profile_name") else: producer_set = None context["producer_set"] = producer_set if self.producer_id == "all": department_set = (LUT_DepartmentForCustomer.objects.filter( offeritem__permanence_id=self.permanence.id, offeritem__is_active=True, offeritem__is_box=False, ).order_by("tree_id", "lft").distinct("id", "tree_id", "lft")) else: department_set = (LUT_DepartmentForCustomer.objects.filter( offeritem__producer_id=self.producer_id, offeritem__permanence_id=self.permanence.id, offeritem__is_active=True, offeritem__is_box=False, ).order_by("tree_id", "lft").distinct("id", "tree_id", "lft")) context["department_set"] = department_set context["box_set"] = OfferItemWoReceiver.objects.filter( permanence_id=self.permanence.id, is_box=True, is_active=True, may_order=True, translations__language_code=translation.get_language(), ).order_by("customer_unit_price", "unit_deposit", "translations__long_name") context["staff_order"] = Staff.get_or_create_order_responsible() if self.is_anonymous: context[ "how_to_register"] = REPANIER_SETTINGS_CONFIG.safe_translation_getter( "how_to_register", any_language=True, default=EMPTY_STRING) else: context["how_to_register"] = EMPTY_STRING # use of str() to avoid "12 345" when rendering the template context["producer_id"] = str(self.producer_id) # use of str() to avoid "12 345" when rendering the template context["department_id"] = str(self.department_id) context["box_id"] = str(self.box_id) context["is_box"] = "yes" if self.is_box else EMPTY_STRING if self.is_box: offer_item = get_object_or_404(OfferItemWoReceiver, id=self.box_id) context["box_description"] = html_box_content( offer_item, self.user) if self.is_basket: context["is_basket"] = "yes" context["is_select_view"] = EMPTY_STRING context["is_basket_view"] = "active" customer = (Customer.objects.filter( user_id=self.user.id, may_order=True).order_by("?").first()) if customer is None: raise Http404 translation.activate(customer.language) customer_invoice = (CustomerInvoice.objects.filter( permanence_id=self.permanence.id, customer_id=customer.id).order_by("?").first()) if customer_invoice is None: customer_invoice = CustomerInvoice.objects.create( permanence_id=self.permanence.id, customer_id=customer.id, status=self.permanence.status, customer_charged_id=customer.id, ) customer_invoice.set_order_delivery(delivery=None) customer_invoice.calculate_order_price() customer_invoice.save() if customer_invoice.delivery is not None: status = customer_invoice.delivery.status else: status = customer_invoice.status basket_message = get_html_basket_message(customer, self.permanence, status) html = customer_invoice.get_html_my_order_confirmation( permanence=self.permanence, is_basket=True, basket_message=basket_message, ) context["span_btn_confirm_order"] = html["#span_btn_confirm_order"] else: context["is_basket"] = EMPTY_STRING context["is_select_view"] = "active" context["is_basket_view"] = EMPTY_STRING context["is_like"] = "yes" if self.is_like else EMPTY_STRING context["communication"] = self.communication context["q"] = self.q context["may_order"] = self.may_order context[ "display_anonymous_order_form"] = REPANIER_SETTINGS_DISPLAY_ANONYMOUS_ORDER_FORM return context
def order_init_ajax(request): if not request.is_ajax(): raise Http404 permanence_id = sint(request.GET.get('pe', 0)) permanence = Permanence.objects.filter(id=permanence_id).order_by('?').first() permanence_ok_or_404(permanence) user = request.user customer = Customer.objects.filter( user_id=user.id, may_order=True ).only( "id", "vat_id", "short_basket_name", "email2", "delivery_point", "balance", "date_balance", "may_order" ).order_by('?').first() if customer is None: raise Http404 customer_invoice = CustomerInvoice.objects.filter( permanence_id=permanence.id, customer_id=customer.id ).order_by('?').first() if customer_invoice is None: customer_invoice = CustomerInvoice.objects.create( permanence_id=permanence.id, customer_id=customer.id, status=permanence.status, customer_charged_id=customer.id, ) customer_invoice.set_order_delivery(delivery=None) customer_invoice.calculate_order_price() customer_invoice.save() if customer_invoice is None: raise Http404 basket = sboolean(request.GET.get('ba', False)) if customer_invoice.delivery is not None: status = customer_invoice.delivery.status else: status = customer_invoice.status if status <= PERMANENCE_OPENED: basket_message = get_html_basket_message(customer, permanence, status) else: if customer_invoice.delivery is not None: basket_message = EMPTY_STRING else: basket_message = "{}".format( _('The orders are closed.') ) if settings.REPANIER_SETTINGS_TEMPLATE == "bs3": json_dict = customer_invoice.get_html_my_order_confirmation( permanence=permanence, is_basket=basket, basket_message=basket_message ) else: json_dict = {} if customer.may_order: if settings.REPANIER_SETTINGS_SHOW_PRODUCER_ON_ORDER_FORM: for producer_invoice in ProducerInvoice.objects.filter( permanence_id=permanence.id ).only( "total_price_with_tax", "status" ).order_by('?'): json_dict.update(producer_invoice.get_order_json()) communication = sboolean(request.GET.get('co', False)) if communication: now = timezone.now() permanence_boards = PermanenceBoard.objects.filter( customer_id=customer.id, permanence_date__gte=now, permanence__status__lte=PERMANENCE_WAIT_FOR_INVOICED ).order_by("permanence_date")[:2] from repanier.apps import REPANIER_SETTINGS_MAX_WEEK_WO_PARTICIPATION if REPANIER_SETTINGS_MAX_WEEK_WO_PARTICIPATION > DECIMAL_ZERO or len(permanence_boards) > 0: if len(permanence_boards) == 0: count_activity = PermanenceBoard.objects.filter( customer_id=customer.id, permanence_date__lt=now, permanence_date__gte=now - datetime.timedelta( days=float(REPANIER_SETTINGS_MAX_WEEK_WO_PARTICIPATION) * 7 ) ).count() else: count_activity = None template_name = get_repanier_template_name("communication_permanence_board.html") html = render_to_string( template_name, {'permanence_boards': permanence_boards, 'count_activity': count_activity} ) json_dict["#communicationModal"] = mark_safe(html) json_dict.update(my_basket(customer_invoice.is_order_confirm_send, customer_invoice.get_total_price_with_tax())) return JsonResponse(json_dict)
def get_context_data(self, **kwargs): from repanier.apps import REPANIER_SETTINGS_DISPLAY_ANONYMOUS_ORDER_FORM, REPANIER_SETTINGS_CONFIG, \ REPANIER_SETTINGS_NOTIFICATION context = super(OrderView, self).get_context_data(**kwargs) context['first_page'] = self.first_page context['permanence'] = self.permanence context['permanence_id'] = self.permanence.id context["all_dates"] = self.all_dates context["date_id"] = self.date_id context["date_Selected"] = self.date_selected context["notification"] = REPANIER_SETTINGS_NOTIFICATION.get_notification_display() if self.first_page: if settings.REPANIER_SETTINGS_SHOW_PRODUCER_ON_ORDER_FORM: producer_set = Producer.objects.filter(permanence=self.permanence.id).only("id", "short_profile_name") else: producer_set = None context['producer_set'] = producer_set if self.producer_id == 'all': department_set = LUT_DepartmentForCustomer.objects.filter( offeritem__permanence_id=self.permanence.id, offeritem__is_active=True, offeritem__is_box=False) \ .order_by("tree_id", "lft") \ .distinct("id", "tree_id", "lft") else: department_set = LUT_DepartmentForCustomer.objects.filter( offeritem__producer_id=self.producer_id, offeritem__permanence_id=self.permanence.id, offeritem__is_active=True, offeritem__is_box=False) \ .order_by("tree_id", "lft") \ .distinct("id", "tree_id", "lft") context['department_set'] = department_set context['box_set'] = OfferItemWoReceiver.objects.filter( permanence_id=self.permanence.id, is_box=True, is_active=True, may_order=True, translations__language_code=translation.get_language() ).order_by( 'customer_unit_price', 'unit_deposit', 'translations__long_name', ) context['staff_order'] = Staff.get_or_create_order_responsible() if self.is_anonymous: context['how_to_register'] = REPANIER_SETTINGS_CONFIG.safe_translation_getter( 'how_to_register', any_language=True, default=EMPTY_STRING) else: context['how_to_register'] = EMPTY_STRING # use of str() to avoid "12 345" when rendering the template context['producer_id'] = str(self.producer_id) # use of str() to avoid "12 345" when rendering the template context['department_id'] = str(self.department_id) context['box_id'] = str(self.box_id) context['is_box'] = "yes" if self.is_box else EMPTY_STRING if self.is_box: offer_item = get_object_or_404(OfferItemWoReceiver, id=self.box_id) context['box_description'] = html_box_content(offer_item, self.user) if self.is_basket: context['is_basket'] = "yes" context['is_select_view'] = EMPTY_STRING context['is_basket_view'] = 'active' customer = Customer.objects.filter( user_id=self.user.id, may_order=True).order_by('?').first() if customer is None: raise Http404 translation.activate(customer.language) customer_invoice = CustomerInvoice.objects.filter( permanence_id=self.permanence.id, customer_id=customer.id ).order_by('?').first() if customer_invoice is None: raise Http404 if customer_invoice.delivery is not None: status = customer_invoice.delivery.status else: status = customer_invoice.status basket_message = get_html_basket_message( customer, self.permanence, status ) html = customer_invoice.get_html_my_order_confirmation( permanence=self.permanence, is_basket=True, basket_message=basket_message ) context['span_btn_confirm_order'] = html['#span_btn_confirm_order'] else: context['is_basket'] = EMPTY_STRING context['is_select_view'] = 'active' context['is_basket_view'] = EMPTY_STRING context['is_like'] = "yes" if self.is_like else EMPTY_STRING context['communication'] = self.communication context['q'] = self.q context['may_order'] = self.may_order context['display_anonymous_order_form'] = REPANIER_SETTINGS_DISPLAY_ANONYMOUS_ORDER_FORM return context
def delivery_ajax(request): if not request.is_ajax(): raise Http404 user = request.user permanence_id = sint(request.GET.get('permanence', 0)) permanence = Permanence.objects.filter( id=permanence_id ).only("id", "status").order_by('?').first() if permanence is None: raise Http404 customer = Customer.objects.filter( user_id=user.id, may_order=True ).order_by('?').first() if customer is None: raise Http404 customer_invoice = CustomerInvoice.objects.filter( customer_id=customer.id, permanence_id=permanence_id ).order_by('?').first() if customer_invoice is None: raise Http404 json_dict = {} if customer_invoice.status == PERMANENCE_OPENED: delivery_id = sint(request.GET.get('delivery', 0)) if customer.delivery_point is not None: qs = DeliveryBoard.objects.filter( Q( id=delivery_id, permanence_id=permanence_id, delivery_point_id=customer.delivery_point_id, # delivery_point__closed_group=True, -> This is always the case # when delivery_point_id == customer.delivery_point_id status=PERMANENCE_OPENED ) | Q( id=delivery_id, permanence_id=permanence_id, delivery_point__customer_responsible__isnull=True, status=PERMANENCE_OPENED ) ).order_by('?') else: qs = DeliveryBoard.objects.filter( id=delivery_id, permanence_id=permanence_id, delivery_point__customer_responsible__isnull=True, status=PERMANENCE_OPENED ).order_by('?') delivery = qs.first() if delivery is None: raise Http404 if customer_invoice.delivery != delivery: customer_invoice.set_order_delivery(delivery) customer_invoice.calculate_order_price() invoice_confirm_status_is_changed = customer_invoice.cancel_confirm_order() customer_invoice.save() if settings.REPANIER_SETTINGS_CUSTOMER_MUST_CONFIRM_ORDER and invoice_confirm_status_is_changed: html = render_to_string(template_communication_confirm_order) json_dict["#communicationModal"] = mark_safe(html) json_dict.update( my_basket(customer_invoice.is_order_confirm_send, customer_invoice.get_total_price_with_tax())) is_basket = sboolean(request.GET.get('is_basket', False)) if customer_invoice.delivery is not None: status = customer_invoice.delivery.status else: status = customer_invoice.status basket_message = get_html_basket_message( customer, permanence, status ) json_dict.update(customer_invoice.get_html_my_order_confirmation( permanence=permanence, is_basket=is_basket, basket_message=basket_message )) return JsonResponse(json_dict)
def order_ajax(request): """ Add a selected offer item to a customer order (i.e. update the customer's invoice and the producer's invoice) """ if not request.is_ajax(): raise Http404 user = request.user customer = Customer.objects.filter( user_id=user.id, may_order=True ).first() if customer is None: raise Http404 offer_item_id = sint(request.GET.get('offer_item', 0)) value_id = sint(request.GET.get('value', 0)) is_basket = sboolean(request.GET.get('is_basket', False)) qs = CustomerInvoice.objects.filter( permanence__offeritem=offer_item_id, customer_id=customer.id, status=PERMANENCE_OPENED) json_dict = {} if qs.exists(): qs = ProducerInvoice.objects.filter( permanence__offeritem=offer_item_id, producer__offeritem=offer_item_id, status=PERMANENCE_OPENED ) if qs.exists(): purchase, updated = create_or_update_one_cart_item( customer=customer, offer_item_id=offer_item_id, value_id=value_id, batch_job=False, comment=EMPTY_STRING ) offer_item = OfferItemWoReceiver.objects.filter( id=offer_item_id ).first() if purchase is None: json_dict["#offer_item{}".format(offer_item.id)] = get_html_selected_value(offer_item, DECIMAL_ZERO, is_open=True) else: json_dict["#offer_item{}".format(offer_item.id)] = get_html_selected_value(offer_item, purchase.quantity_ordered, is_open=True) if updated and offer_item.is_box: # update the content for content in BoxContent.objects.filter( box=offer_item.product_id ).only( "product_id" ): box_offer_item = OfferItemWoReceiver.objects.filter( product_id=content.product_id, permanence_id=offer_item.permanence_id ).first() if box_offer_item is not None: # Select one purchase purchase = PurchaseWoReceiver.objects.filter( customer_id=customer.id, offer_item_id=box_offer_item.id, is_box_content=False ).only('quantity_ordered').first() if purchase is not None: json_dict["#offer_item{}".format(box_offer_item.id)] = get_html_selected_value( box_offer_item, purchase.quantity_ordered, is_open=True ) box_purchase = PurchaseWoReceiver.objects.filter( customer_id=customer.id, offer_item_id=box_offer_item.id, is_box_content=True ).only('quantity_ordered').first() if box_purchase is not None: json_dict["#box_offer_item{}".format(box_offer_item.id)] = get_html_selected_box_value( box_offer_item, box_purchase.quantity_ordered ) if settings.REPANIER_SETTINGS_SHOW_PRODUCER_ON_ORDER_FORM: producer_invoice = ProducerInvoice.objects.filter( producer_id=offer_item.producer_id, permanence_id=offer_item.permanence_id ).only("total_price_with_tax").first() json_dict.update(producer_invoice.get_order_json()) customer_invoice = CustomerInvoice.objects.filter( permanence_id=offer_item.permanence_id, customer_id=customer.id ).first() invoice_confirm_status_is_changed = customer_invoice.cancel_confirm_order() if invoice_confirm_status_is_changed: if settings.REPANIER_SETTINGS_CUSTOMER_MUST_CONFIRM_ORDER: template_name = get_repanier_template_name("communication_confirm_order.html") html = render_to_string(template_name) json_dict["#communicationModal"] = mark_safe(html) customer_invoice.save() json_dict.update( my_basket(customer_invoice.is_order_confirm_send, customer_invoice.get_total_price_with_tax())) permanence = Permanence.objects.filter( id=offer_item.permanence_id ).first() if is_basket: basket_message = get_html_basket_message(customer, permanence, PERMANENCE_OPENED) else: basket_message = EMPTY_STRING json_dict.update(customer_invoice.get_html_my_order_confirmation( permanence=permanence, is_basket=is_basket, basket_message=basket_message )) return JsonResponse(json_dict)