Пример #1
0
def clientes():
    ##### AGREGADO POR PEKE
    error = chequeoerror()
    if error:
        return render_template('error.html', error=error)


##### AGREGADO POR PEKE
    if 'username' not in session:
        return redirect(url_for('ingresar'))

    if request.method == "POST":
        filtro = request.form['nombrecliente']
        if len(filtro) < 3:
            return render_template('clienbus.html', error=1)

        listadoclientes = filtrar("CLIENTE", filtro)

        if len(listadoclientes) == 0:
            return render_template('clienbus.html',
                                   clie=listadoclientes,
                                   lista=0)

        elif len(listadoclientes) == 1:
            return redirect(url_for('clientabla', filtro=listadoclientes[0]))

        return render_template('clienbus.html', clie=listadoclientes, lista=1)
Пример #2
0
def ingresar():
    ##### AGREGADO POR PEKE
    error = chequeoerror()
    if error:
        return render_template('error.html', error=error)


##### AGREGADO POR PEKE

    formulario = LoginForm()
    if formulario.validate_on_submit():
        with open('usuarios') as archivo:
            archivo_csv = csv.reader(archivo)
            registro = next(archivo_csv)
            while registro:
                if formulario.usuario.data == registro[
                        0] and formulario.password.data == registro[1]:
                    flash('Bienvenido')
                    session['username'] = formulario.usuario.data

                    ##### AGREGADO POR SEBASTIAN #####
                    cant = 10
                    tablafinal, tablaorden = ultventfun()
                    return render_template('ingresado.html',
                                           usuario=formulario.usuario.data,
                                           titulo=tablaorden,
                                           tabla=tablafinal[-cant:])
            ##### AGREGADO POR SEBASTIAN #####

                registro = next(archivo_csv, None)
            else:
                flash('Revisá nombre de usuario y contraseña')
                return redirect(url_for('ingresar'))
    return render_template('login.html', formulario=formulario)
Пример #3
0
def index():
    ##### AGREGADO POR PEKE
    error = chequeoerror()
    if error:
        return render_template('error.html', error=error)


##### AGREGADO POR PEKE

    return render_template('index.html', fecha_actual=datetime.utcnow())
Пример #4
0
def prodbus():
    ##### AGREGADO POR PEKE
    error = chequeoerror()
    if error:
        return render_template('error.html', error=error)


##### AGREGADO POR PEKE
    if 'username' not in session:
        return redirect(url_for('ingresar'))

    return render_template('prodbus.html')
Пример #5
0
def prodmas():
    ##### AGREGADO POR PEKE
    error = chequeoerror()
    if error:
        return render_template('error.html', error=error)


##### AGREGADO POR PEKE
    if 'username' not in session:
        return redirect(url_for('ingresar'))

    ordenado = mejores("PRODUCTO")
    cant = 10
    return render_template("prodmas.html", lista=ordenado[0:cant], cant=cant)
Пример #6
0
def ultvent():
    ##### AGREGADO POR PEKE
    error = chequeoerror()
    if error:
        return render_template('error.html', error=error)


##### AGREGADO POR PEKE
    if 'username' not in session:
        return redirect(url_for('ingresar'))

    cant = 20
    tablafinal, tablaorden = ultventfun()

    return render_template('ultvent.html',
                           titulo=tablaorden,
                           tabla=tablafinal[-cant:])
Пример #7
0
def prodtabla(filtro):
    ##### AGREGADO POR PEKE
    error = chequeoerror()
    if error:
        return render_template('error.html', error=error)


##### AGREGADO POR PEKE
    if 'username' not in session:
        return redirect(url_for('ingresar'))

    tablafinal, tablaorden, cant, nombre = mostrar("PRODUCTO", filtro)

    return render_template("prodtabla.html",
                           producto=nombre,
                           tabla=tablafinal,
                           titulo=tablaorden,
                           cant=cant)
Пример #8
0
def clientabla(filtro):
    ##### AGREGADO POR PEKE
    error = chequeoerror()
    if error:
        return render_template('error.html', error=error)


##### AGREGADO POR PEKE
    if 'username' not in session:
        return redirect(url_for('ingresar'))

    tablafinal, tablaorden, cant, nombre = mostrar("CLIENTE", filtro)

    return render_template("clientabla.html",
                           cliente=nombre,
                           tabla=tablafinal,
                           titulo=tablaorden,
                           gasto=cant)
Пример #9
0
def registrar():
    ##### AGREGADO POR PEKE
    error = chequeoerror()
    if error:
        return render_template('error.html', error=error)


##### AGREGADO POR PEKE

    formulario = RegistrarForm()
    if formulario.validate_on_submit():
        if formulario.password.data == formulario.password_check.data:
            with open('usuarios', 'a+') as archivo:
                archivo_csv = csv.writer(archivo)
                registro = [formulario.usuario.data, formulario.password.data]
                archivo_csv.writerow(registro)
            flash('Usuario creado correctamente')
            return redirect(url_for('ingresar'))
        else:
            flash('Las passwords no matchean')
    return render_template('registrar.html', form=formulario)
Пример #10
0
def productos():
    ##### AGREGADO POR PEKE
    error = chequeoerror()
    if error:
        return render_template('error.html', error=error)


##### AGREGADO POR PEKE
    if 'username' not in session:
        return redirect(url_for('index'))

    if request.method == "POST":
        filtro = request.form['nombreprod']
        if len(filtro) < 3:
            return render_template('prodbus.html', error=1)

        listadoprod = filtrar("PRODUCTO", filtro)
        if len(listadoprod) == 0:
            return render_template('prodbus.html', prod=listadoprod, lista=0)

        elif len(listadoprod) == 1:
            return redirect(url_for('prodtabla', filtro=listadoprod[0]))

        return render_template('prodbus.html', producto=listadoprod, lista=1)