Exemplo n.º 1
0
    def get(self, usuario_id, tabla_fecha):
        #print(str(datetime.strptime('30-08-2015', '%d-%m-%Y')))
        fecha = datetime.strptime(tabla_fecha, '%d-%m-%Y')
        week_of_year = int(fecha.strftime("%U"))

        f1 = Tabla.id_usuario
        f2 = Tabla.semana_del_anio
        f3 = Tabla.anio
        tabla = Tabla.query.filter(f1 == usuario_id, f2 == week_of_year,
                                   f3 == fecha.year).first()
        if tabla is not None:
            lista_eventos = Evento.query.filter(
                Evento.id_tabla == tabla.id_tabla).all()

            # if (lista_eventos is None) or (lista_eventos.count(Evento.id_evento)==0):
            #     content = { 'table': marshal(tabla, tables_fields) }
            #     return formatOutput(2001,content)
            # else:
            content = {
                'table':
                marshal(tabla, tables_fields),
                'events':
                list(map(lambda t: marshal(t, events_fields), lista_eventos))
            }
            return formatOutput(2000, content)

        else:
            return formatOutput(2002)
Exemplo n.º 2
0
 def get(self, usuario_id):
     usuario = Usuario.query.filter_by(id_usuario=usuario_id).first()
     if usuario is not None:
         content = { 'user': marshal(usuario, users_fields) }
         return formatOutput(1001,content)
     else:
         return formatOutput(1002)
Exemplo n.º 3
0
    def post(self):
        args = self.reqparse.parse_args()
        id_usuario = args['id_usuario']
        descripcion = args['descripcion']
        fecha = args['fecha']

        fecha = datetime.strptime(fecha, '%d-%m-%Y')
        week_of_year = int(fecha.strftime("%U"))

        usuario = Usuario.query.filter(
            Usuario.id_usuario == id_usuario).first()

        if usuario is None:
            return formatOutput(2004)
        else:
            f1 = Tabla.id_usuario
            f2 = Tabla.semana_del_anio
            f3 = Tabla.anio
            f4 = Tabla.borrado
            tabla = Tabla.query.filter(f1 == id_usuario, f2 == week_of_year,
                                       f3 == fecha.year, f4 == False).first()
            if tabla is None:
                nueva_tabla = Tabla(descripcion, week_of_year, fecha.year,
                                    usuario)
                db.session.add(nueva_tabla)
                db.session.commit()
                return formatOutput(2005), 201
            else:
                return formatOutput(2006)
Exemplo n.º 4
0
 def post(self):
     args = self.reqparse.parse_args()
     f1 = Tabla.id_tabla
     f2 = Tabla.borrado
     tabla = Tabla.query.filter(f1 == args['id_tabla'], f2 == False).first()
     if tabla is None:
         return formatOutput(3003)
     else:
         fecha = args['fecha']
         privacidad = args['privacidad']
         color = args['color']
         comienza = args['comienza']
         finaliza = args['finaliza']
         titulo = args['titulo']
         descripcion = args['descripcion']
         timediff_h = args['timediff_h']
         timediff_inmins = args['timediff_inmins']
         timediff_m = args['timediff_m']
         nuevo_evento = Evento(tabla, fecha, privacidad, color, comienza,
                               finaliza, titulo, descripcion, timediff_h,
                               timediff_inmins, timediff_m)
         if args['url_imagen'] is not None:
             nuevo_evento.url_imagen = args['url_imagen']
         if args['direccion'] is not None:
             nuevo_evento.direccion = args['direccion']
         if args['latitud'] is not None:
             nuevo_evento.latitud = args['latitud']
         if args['longitud'] is not None:
             nuevo_evento.longitud = args['longitud']
         if args['lugar'] is not None:
             nuevo_evento.lugar = args['lugar']
         db.session.add(nuevo_evento)
         db.session.commit()
         return formatOutput(3004), 201
Exemplo n.º 5
0
 def get(self, evento_id):
     evento = Evento.query.filter_by(id_evento=evento_id).first()
     if evento is not None:
         content = { 'event': marshal(evento, events_fields) }
         return formatOutput(3000,content)
     else:
         return formatOutput(3001)
Exemplo n.º 6
0
    def post(self):
        args = self.reqparse.parse_args()
        id_usuario = args['id_usuario']
        descripcion = args['descripcion'];
        fecha = args['fecha'];

        fecha = datetime.strptime(fecha, '%d-%m-%Y')
        week_of_year = int(fecha.strftime("%U"))

        usuario = Usuario.query.filter(Usuario.id_usuario==id_usuario).first()

        if usuario is None:
            return formatOutput(2004)
        else:
            f1 = Tabla.id_usuario
            f2 = Tabla.semana_del_anio
            f3 = Tabla.anio
            f4 = Tabla.borrado
            tabla = Tabla.query.filter(f1==id_usuario,f2==week_of_year, f3==fecha.year, f4==False).first()
            if tabla is None:
                nueva_tabla = Tabla(descripcion, week_of_year, fecha.year, usuario)
                db.session.add(nueva_tabla)
                db.session.commit()
                return formatOutput(2005), 201
            else:
                return formatOutput(2006)
Exemplo n.º 7
0
 def post(self):
     args = self.reqparse.parse_args()
     f1 = Tabla.id_tabla
     f2 = Tabla.borrado
     tabla = Tabla.query.filter(f1==args['id_tabla'],f2==False).first()
     if tabla is None:
         return formatOutput(3003)
     else:
         fecha = args['fecha']
         privacidad = args['privacidad']
         color = args['color']
         comienza = args['comienza']
         finaliza = args['finaliza']
         titulo = args['titulo']
         descripcion = args['descripcion']
         timediff_h = args['timediff_h']
         timediff_inmins = args['timediff_inmins']
         timediff_m = args['timediff_m']
         nuevo_evento = Evento(tabla, fecha, privacidad, color, comienza, finaliza, titulo, descripcion, timediff_h, timediff_inmins, timediff_m)
         if args['url_imagen'] is not None:
             nuevo_evento.url_imagen = args['url_imagen']
         if args['direccion'] is not None:
             nuevo_evento.direccion = args['direccion']
         if args['latitud'] is not None:
             nuevo_evento.latitud = args['latitud']
         if args['longitud'] is not None:
             nuevo_evento.longitud = args['longitud']
         if args['lugar'] is not None:
             nuevo_evento.lugar = args['lugar']
         db.session.add(nuevo_evento)
         db.session.commit()
         return formatOutput(3004), 201
Exemplo n.º 8
0
 def get(self, evento_id):
     evento = Evento.query.filter_by(id_evento=evento_id).first()
     if evento is not None:
         content = {'event': marshal(evento, events_fields)}
         return formatOutput(3000, content)
     else:
         return formatOutput(3001)
Exemplo n.º 9
0
 def get(self, usuario_id):
     usuario = Usuario.query.filter_by(id_usuario=usuario_id).first()
     if usuario is not None:
         content = {'user': marshal(usuario, users_fields)}
         return formatOutput(1001, content)
     else:
         return formatOutput(1002)
Exemplo n.º 10
0
 def get(self):
     lista_tablas = Tabla.query.all()
     content = {
         'tables':
         list(map(lambda t: marshal(t, tables_fields), lista_tablas))
     }
     return formatOutput(2003, content)
Exemplo n.º 11
0
 def get(self):
     lista_usuarios = Usuario.query.all()
     content = {
         'users':
         list(map(lambda t: marshal(t, users_fields), lista_usuarios))
     }
     return formatOutput(1000, content)
Exemplo n.º 12
0
 def get(self):
     lista_eventos = Evento.query.all()
     content = {
         'events':
         list(map(lambda t: marshal(t, events_fields), lista_eventos))
     }
     return formatOutput(3002, content)
Exemplo n.º 13
0
 def post(self):
     args = self.reqparse.parse_args()
     email = args['email']
     password = args['password'];
     nuevo_usuario = Usuario(email,password)
     db.session.add(nuevo_usuario)
     db.session.commit()
     return formatOutput(1003), 201
Exemplo n.º 14
0
 def post(self):
     args = self.reqparse.parse_args()
     email = args['email']
     password = args['password']
     nuevo_usuario = Usuario(email, password)
     db.session.add(nuevo_usuario)
     db.session.commit()
     return formatOutput(1003), 201
Exemplo n.º 15
0
    def put(self, tabla_id):
        args = self.reqparse.parse_args()
        tabla = Tabla.query.filter_by(id_tabla=tabla_id).first()
        if tabla is None:
            return formatOutput(2007)
        else:

            if args['descripcion'] is not None:
                tabla.descripcion = args['descripcion']

            if args['borrado'] is not None:
                tabla.borrado = args['borrado']

            if args['estado'] is not None:
                tabla.estado = args['estado']

            tabla.actualizado_en = datetime.utcnow()

            db.session.add(tabla)
            db.session.commit()
            return formatOutput(2008)
Exemplo n.º 16
0
    def put(self, tabla_id):
        args = self.reqparse.parse_args()
        tabla = Tabla.query.filter_by(id_tabla=tabla_id).first()
        if tabla is None:
            return formatOutput(2007)
        else:

            if args['descripcion'] is not None:
                tabla.descripcion = args['descripcion']

            if args['borrado'] is not None:
                tabla.borrado = args['borrado']

            if args['estado'] is not None:
                tabla.estado = args['estado']

            tabla.actualizado_en = datetime.utcnow()

            db.session.add(tabla)
            db.session.commit()
            return formatOutput(2008)
Exemplo n.º 17
0
    def get(self, usuario_id, tabla_fecha):
        #print(str(datetime.strptime('30-08-2015', '%d-%m-%Y')))
        fecha = datetime.strptime(tabla_fecha, '%d-%m-%Y')
        week_of_year = int(fecha.strftime("%U"))

        f1 = Tabla.id_usuario
        f2 = Tabla.semana_del_anio
        f3 = Tabla.anio
        tabla = Tabla.query.filter(f1==usuario_id,f2==week_of_year, f3==fecha.year).first()
        if tabla is not None:
            lista_eventos = Evento.query.filter(Evento.id_tabla==tabla.id_tabla).all()
            
            # if (lista_eventos is None) or (lista_eventos.count(Evento.id_evento)==0):
            #     content = { 'table': marshal(tabla, tables_fields) }
            #     return formatOutput(2001,content)
            # else:
            content =   { 
                            'table' : marshal(tabla, tables_fields),
                            'events': list(map(lambda t: marshal(t, events_fields), lista_eventos))
                        }
            return formatOutput(2000, content)

        else:
            return formatOutput(2002)
Exemplo n.º 18
0
 def get(self):
     lista_tablas = Tabla.query.all()
     content = { 'tables': list(map(lambda t: marshal(t, tables_fields), lista_tablas)) }
     return formatOutput(2003,content)
Exemplo n.º 19
0
 def get(self):
     lista_eventos = Evento.query.all()
     content = { 'events': list(map(lambda t: marshal(t, events_fields), lista_eventos)) }
     return formatOutput(3002,content)
Exemplo n.º 20
0
 def get(self):
     lista_usuarios = Usuario.query.all()
     content = { 'users': list(map(lambda t: marshal(t, users_fields), lista_usuarios)) }
     return formatOutput(1000,content)