def send_order_status(req, order): """ Send order status to order email. This function call calculate on order and create sha """ cfg = Object() cfg.addresses_country = req.cfg.addresses_country cfg.addresses_region = req.cfg.addresses_region cfg.eshop_currency = req.cfg.eshop_currency order.calculate() # calculate summary order.sha = sha1(str(order.create_date)).hexdigest() try: # TODO: use lang from cart when order was create req.smtp.send_email_alternative( morias_template(req, 'mail/eshop/order_subject.jinja', order=order).encode('utf-8'), # subject order.email, morias_template(req, 'mail/eshop/order.jinja', order=order, cfg=cfg).encode('utf-8'), # body morias_template(req, 'mail/eshop/order.html', order=order, cfg=cfg).encode('utf-8'), # body logger=req.log_info) except Exception as e: req.log_error('Mailing order[%d] error: %s' % (order.id, str(e)), state.LOG_ERR)
def admin_orders_mod(req, id): check_login(req) check_right(req, module_right) order = Order(id) if order.get(req) is None: raise SERVER_RETURN(state.HTTP_NOT_FOUND) cfg = Object() cfg.addresses_country = req.cfg.addresses_country cfg.addresses_region = req.cfg.addresses_region cfg.eshop_currency = req.cfg.eshop_currency order.calculate() return generate_page(req, "admin/eshop/orders_mod.html", token=create_token(req), order=order, cfg=cfg)
def eshop_cart_address(req, cart=None, error=None): do_check_mgc(req) cart = cart or ShoppingCart(req) # get method returns HTML Form cfg = Object() cfg.addresses_country = req.cfg.addresses_country cfg.addresses_region = req.cfg.addresses_region cfg.eshop_currency = req.cfg.eshop_currency # all defined transportation (for universal use): for key, val in req.cfg.__dict__.items(): if key.startswith('eshop_transportation_'): cfg.__dict__[key[6:]] = val elif key.startswith('eshop_payment_'): cfg.__dict__[key[6:]] = val # GET method only view shopping cart - no store was needed return generate_page(req, "eshop/shopping_address.html", token=create_token(req), cfg=cfg, cart=cart, error=error)
def user_orders_detail(req, id): sha = req.args.getfirst('sha', '', str) if not sha and not req.login: raise SERVER_RETURN(state.HTTP_FORBIDDEN) order = Order(id) if order.get(req) is None: raise SERVER_RETURN(state.HTTP_NOT_FOUND) order.sha = sha1(str(order.create_date)).hexdigest() if (sha and sha != order.sha): raise SERVER_RETURN(state.HTTP_FORBIDDEN) # if sha is set, you can see to order if (not sha and req.login and order.client_id != req.login.id): raise SERVER_RETURN(state.HTTP_FORBIDDEN) cfg = Object() cfg.addresses_country = req.cfg.addresses_country cfg.addresses_region = req.cfg.addresses_region cfg.eshop_currency = req.cfg.eshop_currency order.calculate() return generate_page(req, "eshop/orders_detail.html", order=order, sha=sha, cfg=cfg)