def order_add_shipping(request, order_id): order = Order.get_by_scheduler_id(order_id) if order.data.status != "pending_shipment": raise Http404( _("Order %(order_id)s is not pending_shipment") % {"order_id": order.min_id}) context = {"order": order} if request.method == "POST": form = OrderShippingForm(order=order, data=request.POST) if form.is_valid(): try: form.save() except Exception as exp: logger.error(exp) messages.error( request, _("Failed to record shipping informations.. (ref: %(err)s)" ) % {"err": exp}, ) else: messages.success(request, _("Order Shipping informations recorded!")) return redirect("order_detail", order_min_id=order.min_id) else: form = OrderShippingForm(order=order) context["form"] = form return render(request, "add_shipping.html", context)
def order_detail_scheduler_id(request, order_id): order = Order.get_by_scheduler_id(order_id) if order is None: raise Http404( "Order with Scheduler ID `{}` not found".format(order_id)) return redirect("order_detail", order_min_id=order.min_id)
def order_detail_scheduler_id(request, order_id): order = Order.get_by_scheduler_id(order_id) if order is None: raise Http404( _("Order with Scheduler ID `%(order_id)s` not found") % {"order_id": order_id}) return redirect("order_detail", order_min_id=order.min_id)
def recreate(request, order_id): order = Order.get_by_scheduler_id(order_id) if order is None: raise Http404( _("Order `%(order_id)s` does not exists") % {"order_id": order_id} ) try: new_order = order.recreate() except Exception as exc: logger.error(f"Unable to recreate order: {exc}") logger.exception(exc) messages.error( request, _("Unable to recreate order %(order_id)s: -- ref: %(err)s") % {"order_id": order_id, "err": exc}, ) else: messages.success( request, _("Successfuly recreated order: %(new_id)s (NEW)") % {"new_id": new_order.scheduler_id}, ) return redirect("all-orders")