예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
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)