def AdicionarPedidoReserva(self, reserva): id_sala = reserva.id_sala id_usuario = reserva.id_usuario data = reserva.data horario = reserva.horario sala = Api().selectOneSala(id_sala) # print("sala - ",sala) if (sala == None): return 1 if (Api().insertPedidoReservaUser(id_sala, id_usuario, data, horario)): return 2 else: return 3
def ListarSalas(self): salas = ListaSala() for x in Api().selectAllSalas(): (ident, nome, bloco) = x sala = salas.list.add() sala.id_sala = ident sala.nome = nome sala.bloco = bloco return salas
def ListarPedidoReservasAdmin(self): reservas = ListaReserva() for x in Api().selectAllPedidoReservas(): (ident, id_usuario, data, horario, id_sala, nome, bloco) = x r = reservas.reservas.add() r.id = ident r.id_sala = id_sala r.id_usuario = id_usuario r.data = data r.horario = horario return reservas
def ListarHistorico(self, id_usuario): reservas = ListaReserva() for x in Api().selectAllReservasUser(id_usuario): (ident, data, horario, id_sala, nome, bloco) = x if (dt.strptime(data, "%d/%m/%Y") < dt.today()): r = reservas.reservas.add() r.id = ident r.id_sala = id_sala r.id_usuario = id_usuario r.data = data r.horario = horario return reservas
def CancelarPedidoReserva(self, reserva): return Api().cancelarPedidoReserva(reserva.id)
def AceitarPedidoReserva(self, reserva): return Api().aceitarPedidoReserva(reserva.id)
def CancelarReservaUser(self, reserva): return Api().cancelarReservaUser(reserva.id, reserva.id_usuario)
def VerPedidoReserva(self, reserva): return Api().selectOnePedidoReservaUser(reserva.id, reserva.id_usuario)
import os from util.util import Printer from util.rsr import Rsr from util.api import Api from flask import Flask, jsonify, render_template, request from flask_cors import CORS app = Flask(__name__) CORS(app) ### Workspace Setup printer = Printer() rsr = Rsr() get_data = Api() @app.route('/api/<endpoint>/<param>/<val>', methods=['GET']) def api(endpoint, param, val): response = rsr.api(endpoint, param, val)['results'] return jsonify(response) @app.route('/api/live/<endpoint>/<param>/<val>', methods=['GET']) def live(endpoint, param, val): response = rsr.live(endpoint, param, val)['results'] return jsonify(response) @app.route('/api/datatables/<rsr_id>', methods=['GET', 'POST'])
def AuthAdmin(self, usuario, senha): return Api().existsAdmin(usuario, senha)
def CreateAdmin(self, usuario, senha): return Api().insertAdmin(usuario, senha)
def CreateUser(self, nome, usuario, senha, cpf, matricula, curso): return Api().insertUsuario(nome, usuario, senha, cpf, matricula, curso)
def Auth(self, nome, senha): return Api().existsUsuario(nome, senha)