Ejemplo n.º 1
0
def update_rest_img(imagem, current_user):
    rest = get_actual_rest(current_user)
    try:
        update_rest_from_db(False, False, False, imagem, rest)
        return "ok"
    except Exception:
        return "Algo deu errado, tente novamente."
Ejemplo n.º 2
0
def show_menu_by_day(day, current_user):
    rest = get_actual_rest(current_user)
    week_day = datetime.today().weekday()
    weekday_num = {
        0: "Segunda-Feira",
        1: "Terça-Feira",
        2: "Quarta-Feira",
        3: "Quinta-Feira",
        4: "Sexta-Feira",
        5: "Sábado",
        6: "Domingo"
    }
    weekday = {
        "Monday": "Segunda-Feira",
        "Tuesday": "Terça-Feira",
        "Wednesday": "Quarta-Feira",
        "Thursday": "Quinta-Feira",
        "Friday": "Sexta-Feira",
        "Saturday": "Sábado",
        "Sunday": "Domingo"
    }
    try:
        if not day:
            default_cards = query_card_default_by_day(weekday_num[week_day],
                                                      rest)
            all_cards = change_datetime(query_all_menus(current_user))
            return default_cards + all_cards
        _day = strftime("%A", strptime(day, "%m/%d/%Y"))
        weekday_filter = query_card_default_by_day(weekday[_day], rest)
        return weekday_filter + change_datetime(
            query_menus_by_day(day, current_user))
    except Exception:
        abort(400)
Ejemplo n.º 3
0
def insert_default_card(dia, tipo, item, preco, user):
    availabe_days = {
        "monday": "Segunda-Feira",
        "tuesday": "Terça-Feira",
        "wednesday": "Quarta-Feira",
        "thursday": "Quinta-Feira",
        "friday": "Sexta-Feira",
        "saturday": "Sábado",
        "sunday": "Domingo"
    }

    availabe_types = {
        "acomp": "Acompanhamento",
        "add": "Adicional",
        "drink": "Bebida",
        "snack": "Lanche",
        "pizza": "Pizza",
        "main_plate": "Prato Principal",
        "other": "Outro",
        "deserve": "Sobremesa"
    }
    try:
        default_card_insert(availabe_days[dia], availabe_types[tipo], item,
                            preco, get_actual_rest(user))
        return "ok"
    except Exception:
        return "error"
Ejemplo n.º 4
0
def insert_new_marmita(size, price, current_user):
    rest = get_actual_rest(current_user)
    try:
        marmita = TamanhosPrecos(tamanho=size, preco=float(price), rest=rest)
        db.session.add(marmita)
        db.session.commit()
        return "Marmita Criada com sucesso!"
    except Exception:
        return "Erro"
Ejemplo n.º 5
0
def update_rest(phone, hora_aber, hora_fech, current_user):
    rest = get_actual_rest(current_user)
    db_hora_aber = datetime.strptime(hora_aber, "%H:%M").time()
    db_hora_fech = datetime.strptime(hora_fech, "%H:%M").time()
    try:
        update_rest_from_db(phone, db_hora_aber, db_hora_fech, None, rest)
        return "ok"
    except Exception:
        return "Algo deu errado, tente novamente."
Ejemplo n.º 6
0
def insert_menu(item, kind, day, preco, current_user):
    new_day = datetime.strptime(day, "%m/%d/%Y").date()
    try:
        rest = get_actual_rest(current_user)
        card = Cardapio(dia=new_day,
                        prato=item,
                        tipo=kind,
                        preco=preco,
                        rest=rest)
        db.session.add(card)
        db.session.commit()
        return 'Cardápio Inserido com sucesso!'
    except Exception:
        db.session.rollback()
        db.session.remove()
        raise
Ejemplo n.º 7
0
def query_all_marmitas(current_user):
    rest = get_actual_rest(current_user)
    return TamanhosPrecos.query.filter_by(rest=rest).all()
Ejemplo n.º 8
0
def query_marmita_by_size(size, current_user):
    rest = get_actual_rest(current_user)
    return TamanhosPrecos.query.filter_by(tamanho=size). \
        filter_by(rest=rest).all()
Ejemplo n.º 9
0
def query_menus_by_day(day, current_user):
    rest = get_actual_rest(current_user)
    return Cardapio.query.filter_by(rest=rest).filter(Cardapio.dia == day). \
        order_by(Cardapio.dia).limit(50).all()
Ejemplo n.º 10
0
def query_all_menus(current_user):
    rest = get_actual_rest(current_user)
    return Cardapio.query.filter_by(rest=rest).order_by(Cardapio.dia). \
        limit(50).all()
Ejemplo n.º 11
0
def show_clients_account(current_user):
    rest = get_actual_rest(current_user)
    account = query_all_account_in_rest(rest)
    return account
Ejemplo n.º 12
0
def show_requests_to_rest(current_user):
    rest = get_actual_rest(current_user)
    date = datetime.now().date()
    requests = query_requests_by_rest(rest, date)
    return requests
Ejemplo n.º 13
0
def show_default_menus(user):
    return query_all_menus(get_actual_rest(user))