Esempio n. 1
0
def error(code, message):
    return render_template('error.html',
                           page={"page": "none"},
                           code=code,
                           message=message,
                           info=get_info(),
                           title="Error " + str(code))
Esempio n. 2
0
def usuario_info():
    logged = garanteed_logged()
    if logged is None:
        info = get_info()
        msg = "La contraseña se ha actualizado correctamente"
        mode = "default"
        if request.method == "POST":
            response, code = api.usermod()
            if code != 200:
                msg = response.get_json()['message']
                mode = "error"
            else:
                mode = "update"

        context = {
            "page": {
                "page": 'own_user',
                "mode": mode
            },
            "info": info,
            "title": session['username'],
            "message": msg
        }
        return render_template('usuario.html', **context)
    else:
        return logged
Esempio n. 3
0
def sobre():
    context = {
        "page": {
            "page": 'about'
        },
        "info": get_info(),
        "title": "Acerca de"
    }
    return render_template('sobre.html', **context)
Esempio n. 4
0
def home():
    context = {"page": {"page": 'home'}, "info": get_info(), "title": "Inicio"}
    if context['info']['login']:
        mod_request()
        response, code = api.beds()
        if code != 200:
            return error(code, response.get_json()['message'])
        context['beds'] = response.get_json()["beds"]
        for b in context['beds']:
            mod_request({"bedname": b["bed_name"]})
            b['namespace'] = api.bed()[0].get_json()['namespace']
    return render_template('home.html', **context)
Esempio n. 5
0
def usuarios():
    context = {
        "page": {
            "page": 'admin_users'
        },
        "info": get_info(),
        "title": "Administrar usuarios"
    }
    response, code = api.users()
    if code != 200:
        return error(code, response.get_json()['message'])
    context["users"] = response.get_json()['users']
    return render_template('usuarios.html', **context)
Esempio n. 6
0
def cama(bedname):
    mod_request({"bedname": bedname})
    response, code = api.bed()
    if code != 200:
        return error(code, response.get_json()['message'])
    namespace = response.get_json()['namespace']
    context = {
        'page': {
            'page': 'bed',
            'bedname': bedname,
            'namespace': namespace
        },
        'info': get_info(),
        "title": bedname
    }
    return render_template('cama.html', **context)
Esempio n. 7
0
def camas():
    context = {
        "page": {
            "page": 'admin_beds'
        },
        "info": get_info(),
        "title": "Administrar camas"
    }
    response, code = api.beds()
    if code != 200:
        return error(code, response.get_json()['message'])

    # Lista de camas
    context['beds'] = response.get_json()["beds"]
    response, code = api.users()
    # Lista de usuarios
    context['users'] = response.get_json()["users"]
    # Lista de permisos
    response, code = api.bedperm()
    context['perm'] = response.get_json()["permission"]
    return render_template('camas.html', **context)
Esempio n. 8
0
def login():
    context = {
        "page": {
            "page": 'login',
            "bad": False
        },
        "info": get_info(),
        "title": "Iniciar Sesión"
    }
    if request.method == "POST":
        response, code = api.auth()
        if code == 200:
            response_json = response.get_json()
            session['token'] = response_json['token']
            session['role'] = response_json['role']
            session['username'] = response_json['username']
            return redirect(url_for("home"))
        context["page"]['nick'] = request.form['user']
        context["page"]['bad'] = True
        return render_template('auth/login.html', **context)
    else:
        return render_template('auth/login.html', **context)