def remove_subtype_from_type(*args, **kwargs): _type, subtype = _add_or_remove(**kwargs) if not _type.check_presence(subtype): raise SteakhouseException('That subtype not found in this type') _type.remove_subtype(subtype)
def add_subtype_to_type(*args, **kwargs): _type, subtype = _add_or_remove(**kwargs) if _type.check_presence(subtype): raise SteakhouseException('That subtype already in this type') _type.add_subtype(subtype)
def remove_product_from_subtype(*args, **kwargs): subtype, product = _add_or_remove(**kwargs) if not subtype.check_presence(product): raise SteakhouseException('That product not found in this subtype') subtype.remove_product(product)
def add_product_to_subtype(*args, **kwargs): subtype, product = _add_or_remove(**kwargs) if subtype.check_presence(product): raise SteakhouseException('That product already in this subtype') subtype.add_product(product)
def update_type(*args, **kwargs): item_id = kwargs['id'] data = kwargs['data'] if not data: raise SteakhouseException(f'Empty data to update') _type = get_model_by_id_or_raise(Type, item_id) _type.update(**data)
def update_product(*args, **kwargs): item_id = kwargs['id'] data = kwargs['data'] if not data: raise SteakhouseException(f'Empty data to update') product = get_model_by_id_or_raise(Product, item_id) product.update(**data)