|
|
|
|
@@ -7,7 +7,7 @@ from .utils import _serialize_order, _serialize_calendar_entry
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def render_orders_page(ctx, orders, page, total_pages, search, search_count, url_for_fn, qs_fn):
|
|
|
|
|
from shared.sx.helpers import render_to_sx, render_to_sx_with_env, search_desktop_sx, search_mobile_sx, full_page_sx
|
|
|
|
|
from shared.sx.helpers import sx_call, render_to_sx_with_env, search_desktop_sx, search_mobile_sx, full_page_sx
|
|
|
|
|
from shared.utils import route_prefix
|
|
|
|
|
ctx["search"] = search
|
|
|
|
|
ctx["search_count"] = search_count
|
|
|
|
|
@@ -15,18 +15,18 @@ async def render_orders_page(ctx, orders, page, total_pages, search, search_coun
|
|
|
|
|
list_url = pfx + url_for_fn("orders.list_orders")
|
|
|
|
|
detail_url_prefix = pfx + url_for_fn("orders.order.order_detail", order_id=0).rsplit("0/", 1)[0]
|
|
|
|
|
order_dicts = [_serialize_order(o) for o in orders]
|
|
|
|
|
content = await render_to_sx("orders-list-content", orders=order_dicts,
|
|
|
|
|
content = sx_call("orders-list-content", orders=order_dicts,
|
|
|
|
|
page=page, total_pages=total_pages, rows_url=list_url, detail_url_prefix=detail_url_prefix)
|
|
|
|
|
header_rows = await render_to_sx_with_env("cart-orders-layout-full", {},
|
|
|
|
|
list_url=list_url,
|
|
|
|
|
)
|
|
|
|
|
filt = await render_to_sx("order-list-header", search_mobile=SxExpr(await search_mobile_sx(ctx)))
|
|
|
|
|
filt = sx_call("order-list-header", search_mobile=SxExpr(await search_mobile_sx(ctx)))
|
|
|
|
|
return await full_page_sx(ctx, header_rows=header_rows, filter=filt,
|
|
|
|
|
aside=await search_desktop_sx(ctx), content=content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def render_orders_rows(ctx, orders, page, total_pages, url_for_fn, qs_fn):
|
|
|
|
|
from shared.sx.helpers import render_to_sx
|
|
|
|
|
def render_orders_rows(ctx, orders, page, total_pages, url_for_fn, qs_fn):
|
|
|
|
|
from shared.sx.helpers import sx_call
|
|
|
|
|
from shared.utils import route_prefix
|
|
|
|
|
pfx = route_prefix()
|
|
|
|
|
list_url = pfx + url_for_fn("orders.list_orders")
|
|
|
|
|
@@ -34,22 +34,22 @@ async def render_orders_rows(ctx, orders, page, total_pages, url_for_fn, qs_fn):
|
|
|
|
|
order_dicts = [_serialize_order(o) for o in orders]
|
|
|
|
|
parts = []
|
|
|
|
|
for od in order_dicts:
|
|
|
|
|
parts.append(await render_to_sx("order-row-pair", order=od, detail_url_prefix=detail_url_prefix))
|
|
|
|
|
parts.append(sx_call("order-row-pair", order=od, detail_url_prefix=detail_url_prefix))
|
|
|
|
|
next_scroll = ""
|
|
|
|
|
if page < total_pages:
|
|
|
|
|
next_url = list_url + qs_fn(page=page + 1)
|
|
|
|
|
next_scroll = await render_to_sx("infinite-scroll", url=next_url, page=page,
|
|
|
|
|
next_scroll = sx_call("infinite-scroll", url=next_url, page=page,
|
|
|
|
|
total_pages=total_pages, id_prefix="orders", colspan=5)
|
|
|
|
|
else:
|
|
|
|
|
next_scroll = await render_to_sx("order-end-row")
|
|
|
|
|
return await render_to_sx("cart-orders-rows",
|
|
|
|
|
next_scroll = sx_call("order-end-row")
|
|
|
|
|
return sx_call("cart-orders-rows",
|
|
|
|
|
rows=SxExpr("(<> " + " ".join(parts) + ")"),
|
|
|
|
|
next_scroll=SxExpr(next_scroll),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def render_orders_oob(ctx, orders, page, total_pages, search, search_count, url_for_fn, qs_fn):
|
|
|
|
|
from shared.sx.helpers import render_to_sx, render_to_sx_with_env, search_desktop_sx, search_mobile_sx, oob_page_sx
|
|
|
|
|
from shared.sx.helpers import sx_call, render_to_sx_with_env, search_desktop_sx, search_mobile_sx, oob_page_sx
|
|
|
|
|
from shared.utils import route_prefix
|
|
|
|
|
ctx["search"] = search
|
|
|
|
|
ctx["search_count"] = search_count
|
|
|
|
|
@@ -57,17 +57,17 @@ async def render_orders_oob(ctx, orders, page, total_pages, search, search_count
|
|
|
|
|
list_url = pfx + url_for_fn("orders.list_orders")
|
|
|
|
|
detail_url_prefix = pfx + url_for_fn("orders.order.order_detail", order_id=0).rsplit("0/", 1)[0]
|
|
|
|
|
order_dicts = [_serialize_order(o) for o in orders]
|
|
|
|
|
content = await render_to_sx("orders-list-content", orders=order_dicts,
|
|
|
|
|
content = sx_call("orders-list-content", orders=order_dicts,
|
|
|
|
|
page=page, total_pages=total_pages, rows_url=list_url, detail_url_prefix=detail_url_prefix)
|
|
|
|
|
oobs = await render_to_sx_with_env("cart-orders-layout-oob", {},
|
|
|
|
|
list_url=list_url,
|
|
|
|
|
)
|
|
|
|
|
filt = await render_to_sx("order-list-header", search_mobile=SxExpr(await search_mobile_sx(ctx)))
|
|
|
|
|
filt = sx_call("order-list-header", search_mobile=SxExpr(await search_mobile_sx(ctx)))
|
|
|
|
|
return await oob_page_sx(oobs=oobs, filter=filt, aside=await search_desktop_sx(ctx), content=content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def render_order_page(ctx, order, calendar_entries, url_for_fn):
|
|
|
|
|
from shared.sx.helpers import render_to_sx, render_to_sx_with_env, full_page_sx
|
|
|
|
|
from shared.sx.helpers import sx_call, render_to_sx_with_env, full_page_sx
|
|
|
|
|
from shared.utils import route_prefix
|
|
|
|
|
from shared.browser.app.csrf import generate_csrf_token
|
|
|
|
|
pfx = route_prefix()
|
|
|
|
|
@@ -77,8 +77,8 @@ async def render_order_page(ctx, order, calendar_entries, url_for_fn):
|
|
|
|
|
pay_url = pfx + url_for_fn("orders.order.order_pay", order_id=order.id)
|
|
|
|
|
order_data = _serialize_order(order)
|
|
|
|
|
cal_data = [_serialize_calendar_entry(e) for e in (calendar_entries or [])]
|
|
|
|
|
main = await render_to_sx("order-detail-content", order=order_data, calendar_entries=cal_data)
|
|
|
|
|
filt = await render_to_sx("order-detail-filter-content", order=order_data,
|
|
|
|
|
main = sx_call("order-detail-content", order=order_data, calendar_entries=cal_data)
|
|
|
|
|
filt = sx_call("order-detail-filter-content", order=order_data,
|
|
|
|
|
list_url=list_url, recheck_url=recheck_url, pay_url=pay_url, csrf=generate_csrf_token())
|
|
|
|
|
header_rows = await render_to_sx_with_env("cart-order-detail-layout-full", {},
|
|
|
|
|
list_url=list_url, detail_url=detail_url,
|
|
|
|
|
@@ -88,7 +88,7 @@ async def render_order_page(ctx, order, calendar_entries, url_for_fn):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def render_order_oob(ctx, order, calendar_entries, url_for_fn):
|
|
|
|
|
from shared.sx.helpers import render_to_sx, render_to_sx_with_env, oob_page_sx
|
|
|
|
|
from shared.sx.helpers import sx_call, render_to_sx_with_env, oob_page_sx
|
|
|
|
|
from shared.utils import route_prefix
|
|
|
|
|
from shared.browser.app.csrf import generate_csrf_token
|
|
|
|
|
pfx = route_prefix()
|
|
|
|
|
@@ -98,8 +98,8 @@ async def render_order_oob(ctx, order, calendar_entries, url_for_fn):
|
|
|
|
|
pay_url = pfx + url_for_fn("orders.order.order_pay", order_id=order.id)
|
|
|
|
|
order_data = _serialize_order(order)
|
|
|
|
|
cal_data = [_serialize_calendar_entry(e) for e in (calendar_entries or [])]
|
|
|
|
|
main = await render_to_sx("order-detail-content", order=order_data, calendar_entries=cal_data)
|
|
|
|
|
filt = await render_to_sx("order-detail-filter-content", order=order_data,
|
|
|
|
|
main = sx_call("order-detail-content", order=order_data, calendar_entries=cal_data)
|
|
|
|
|
filt = sx_call("order-detail-filter-content", order=order_data,
|
|
|
|
|
list_url=list_url, recheck_url=recheck_url, pay_url=pay_url, csrf=generate_csrf_token())
|
|
|
|
|
oobs = await render_to_sx_with_env("cart-order-detail-layout-oob", {},
|
|
|
|
|
detail_url=detail_url,
|
|
|
|
|
@@ -109,19 +109,19 @@ async def render_order_oob(ctx, order, calendar_entries, url_for_fn):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def render_checkout_error_page(ctx, error=None, order=None):
|
|
|
|
|
from shared.sx.helpers import render_to_sx, render_to_sx_with_env, full_page_sx
|
|
|
|
|
from shared.sx.helpers import sx_call, render_to_sx_with_env, full_page_sx
|
|
|
|
|
from shared.infrastructure.urls import cart_url
|
|
|
|
|
err_msg = error or "Unexpected error while creating the hosted checkout session."
|
|
|
|
|
order_sx = await render_to_sx("checkout-error-order-id", oid=f"#{order.id}") if order else None
|
|
|
|
|
order_sx = sx_call("checkout-error-order-id", oid=f"#{order.id}") if order else None
|
|
|
|
|
hdr = await render_to_sx_with_env("layout-root-full", {})
|
|
|
|
|
filt = await render_to_sx("checkout-error-header")
|
|
|
|
|
content = await render_to_sx("checkout-error-content", msg=err_msg,
|
|
|
|
|
filt = sx_call("checkout-error-header")
|
|
|
|
|
content = sx_call("checkout-error-content", msg=err_msg,
|
|
|
|
|
order=SxExpr(order_sx) if order_sx else None, back_url=cart_url("/"))
|
|
|
|
|
return await full_page_sx(ctx, header_rows=hdr, filter=filt, content=content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def render_cart_payments_panel(ctx):
|
|
|
|
|
from shared.sx.helpers import render_to_sx
|
|
|
|
|
def render_cart_payments_panel(ctx):
|
|
|
|
|
from shared.sx.helpers import sx_call
|
|
|
|
|
page_config = ctx.get("page_config")
|
|
|
|
|
pc_data = None
|
|
|
|
|
if page_config:
|
|
|
|
|
@@ -130,4 +130,4 @@ async def render_cart_payments_panel(ctx):
|
|
|
|
|
"sumup_merchant_code": getattr(page_config, "sumup_merchant_code", None) or "",
|
|
|
|
|
"sumup_checkout_prefix": getattr(page_config, "sumup_checkout_prefix", None) or "",
|
|
|
|
|
}
|
|
|
|
|
return await render_to_sx("cart-payments-content", page_config=pc_data)
|
|
|
|
|
return sx_call("cart-payments-content", page_config=pc_data)
|
|
|
|
|
|