def set_hoster_status_in_user_data(app_user, can_order=None): # type: (users.User, bool) -> None if not isinstance(can_order, bool): can_order = all(o.status == NodeOrderStatus.CANCELED for o in NodeOrder.list_by_user(app_user)) user_data = {'hoster': {'can_order': can_order}} api_key = get_rogerthat_api_key() email, app_id = get_app_user_tuple(app_user) current_user_data = system.get_user_data(api_key, email.email(), app_id, ['hoster']) if current_user_data != user_data: system.put_user_data(api_key, email.email(), app_id, user_data)
def get_node_id_for_user(app_user): for order in NodeOrder.list_by_user(app_user): if order.status in (NodeOrderStatus.SENT, NodeOrderStatus.ARRIVED): node_id = get_node_id_from_odoo(order.odoo_sale_order_id) if node_id: return node_id
def get_nodes_for_user(app_user): nodes = [] for order in NodeOrder.list_by_user(app_user): if order.status in (NodeOrderStatus.SENT, NodeOrderStatus.ARRIVED): nodes.extend(get_nodes_from_odoo(order.odoo_sale_order_id)) return nodes