def customer_product_description_ajax(request): if request.is_ajax(): offer_item_id = sint(request.GET.get("offer_item", 0)) offer_item = get_object_or_404(OfferItem, id=offer_item_id) permanence = offer_item.permanence permanence_ok_or_404(permanence) if PERMANENCE_OPENED <= permanence.status <= PERMANENCE_SEND: try: result = offer_item.cache_part_e result = html_box_content(offer_item, request.user, result) if result is None or result == EMPTY_STRING: result = "%s" % _("There is no more product's information") except TranslationDoesNotExist: result = "%s" % _("There is no more product's information") else: result = "%s" % _("There is no more product's information") return HttpResponse(result) raise Http404
def customer_product_description_ajax(request): if request.is_ajax(): offer_item_id = sint(request.GET.get('offer_item', 0)) offer_item = get_object_or_404(OfferItem, id=offer_item_id) permanence = offer_item.permanence permanence_ok_or_404(permanence) if PERMANENCE_OPENED <= permanence.status <= PERMANENCE_SEND: offer_item.long_name = offer_item.product.long_name result = html_box_content( offer_item, request.user, render_to_string('repanier/cache_part_e.html', { 'offer': offer_item, 'MEDIA_URL': settings.MEDIA_URL })) if result is None or result == EMPTY_STRING: result = "%s" % _("There is no more product's information") else: result = "%s" % _("There is no more product's information") return HttpResponse(result) raise Http404
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 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"] = None if self.is_anonymous and \ not REPANIER_SETTINGS_NOTIFICATION.notification_is_public else \ REPANIER_SETTINGS_NOTIFICATION.safe_translation_getter('notification', any_language=True) 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) context['is_basket'] = "yes" if self.is_basket else 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 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 get_context_data(self, **kwargs): context = super(OrderView, self).get_context_data(**kwargs) context['permanence'] = self.permanence if self.permanence.status == PERMANENCE_OPENED: context['display_all_product_button'] = "Ok" context['delivery_id'] = self.delivery_id from repanier.apps import REPANIER_SETTINGS_DISPLAY_PRODUCER_ON_ORDER_FORM if REPANIER_SETTINGS_DISPLAY_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 # use of str() to avoid "12 345" when rendering the template context['producer_id'] = str(self.producer_id) if self.producer_id == 'all': departementforcustomer_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: departementforcustomer_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['departementforcustomer_set'] = departementforcustomer_set # use of str() to avoid "12 345" when rendering the template context['departementforcustomer_id'] = str(self.departementforcustomer_id) context['box_set'] = OfferItem.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['box_id'] = str(self.box_id) context['box'] = self.is_box if self.is_box: html = EMPTY_STRING offer_item = get_object_or_404(OfferItem, id=self.box_id) context['box_description']=html_box_content(offer_item, self.user, html) context['basket'] = self.basket context['like'] = self.like context['staff_order'] = Staff.objects.filter( is_reply_to_order_email=True) \ .only("customer_responsible__long_basket_name", "customer_responsible__phone1", "user__email") \ .order_by('?').first() context['communication'] = self.communication context['q'] = self.q context['is_anonymous'] = self.is_anonymous context['may_order'] = self.may_order return context