Browse Source

Facilidad de uso y decoraciones

politica
Celestino Rey 1 year ago
parent
commit
9d5a91f164
12 changed files with 59 additions and 45 deletions
  1. +0
    -0
      Padel/exit
  2. +2
    -0
      Padel/padel/README.md
  3. +1
    -1
      Padel/padel/auth.py
  4. +1
    -1
      Padel/padel/paginas.py
  5. +1
    -2
      Padel/padel/reservas.py
  6. +22
    -12
      Padel/padel/templates/_navegacion.html
  7. +4
    -4
      Padel/padel/templates/autorizacion/index.html
  8. +2
    -2
      Padel/padel/templates/autorizacion/login.html
  9. +2
    -3
      Padel/padel/templates/base.html
  10. +1
    -1
      Padel/padel/templates/paginas/inicio.html
  11. +15
    -11
      Padel/padel/templates/reservas/misreservas.html
  12. +8
    -8
      Padel/padel/templates/reservas/reservar.html

+ 0
- 0
Padel/exit View File


+ 2
- 0
Padel/padel/README.md View File

@ -0,0 +1,2 @@
# fuente
https://www.digitalocean.com/community/tutorials/how-to-add-authentication-to-your-app-with-flask-login

+ 1
- 1
Padel/padel/auth.py View File

@ -22,7 +22,7 @@ def login_post():
# check if the user actually exists
# take the user-supplied password, hash it, and compare it to the hashed password in the database
if not user or not check_password_hash(user.password, password):
flash('Please check your login details and try again.')
flash('Por favor, comprueba los datos de registro y vuelve a intentarlo.')
return redirect(url_for('auth.login')) # if the user doesn't exist or password is wrong, reload the page
# if the above check passes, then we know the user has the right credentials


+ 1
- 1
Padel/padel/paginas.py View File

@ -7,7 +7,7 @@ bp = Blueprint("paginas", __name__)
@bp.route("/")
def inicio():
return render_template("paginas/inicio.html")
return render_template("autorizacion/index.html")
@bp.route("/acerca")
def acerca():


+ 1
- 2
Padel/padel/reservas.py View File

@ -19,7 +19,7 @@ def misreservas():
reservas = db.execute(
# "SELECT id, nombre, fecha, hora FROM reservas WHERE fecha>=? AND fecha<=? ORDER BY fecha DESC", (hoy,pasado)
"SELECT id, nombre, fecha, hora FROM reservas ORDER BY fecha DESC"
"SELECT id, nombre, fecha, hora FROM reservas WHERE nombre=? ORDER BY fecha DESC", (current_user.name,)
).fetchall()
return render_template("reservas/misreservas.html", reservas=reservas, name=current_user.name)
@ -28,7 +28,6 @@ def misreservas():
@login_required
def inserta(diaelegido):
if request.method == "POST":
nombre = request.form["nombre"] or "Anónimo"
fecha = diaelegido
hora = request.form["hora"]


+ 22
- 12
Padel/padel/templates/_navegacion.html View File

@ -3,18 +3,28 @@
<div class="container">
<div id="navbarMenuHeroA" class="navbar-menu">
<div class="navbar-end">
<a href="{{ url_for('paginas.inicio') }}" class="navbar-item">
Inicio
</a>
<a href="{{ url_for('paginas.acerca') }}" class="navbar-item">
Acerca de...
</a>
<a href="{{ url_for('reservas.misreservas') }}" class="navbar-item">
Mis reservas
</a>
<a href="{{ url_for('reservas.eligedia') }}" class="navbar-item">
Reservar
</a>
{% if current_user.is_authenticated %}
<!--
<a href="{{ url_for('paginas.inicio') }}" class="navbar-item">
Inicio
</a>
<a href="{{ url_for('paginas.acerca') }}" class="navbar-item">
Acerca de...
</a>
-->
<a href="{{ url_for('reservas.misreservas') }}" class="navbar-item">
Mis reservas
</a>
<a href="{{ url_for('reservas.eligedia') }}" class="navbar-item">
Reservar
</a>
<a href="{{ url_for('auth.logout') }}" class="navbar-item">Salir</a>
{% else %}
<a href="{{ url_for('auth.index') }}" class="navbar-item">Inicio</a>
<a href="{{ url_for('auth.login') }}" class="navbar-item">Entrar</a>
<a href="{{ url_for('auth.signup') }}" class="navbar-item">Registrarse</a>
{% endif %}
</div>
</div>
</div>


+ 4
- 4
Padel/padel/templates/autorizacion/index.html View File

@ -1,10 +1,10 @@
{% extends "base.html" %}
{% block content %}
<h1 class="title">
Flask Login Example
<h1 class="title is-1">
Pista de padel Devesa Park
</h1>
<h2 class="subtitle">
Easy authentication and authorization in Flask.
<h2 class="subtitle is-1">
Reservas de padel.
</h2>
{% endblock %}

+ 2
- 2
Padel/padel/templates/autorizacion/login.html View File

@ -26,10 +26,10 @@
<div class="field">
<label class="checkbox">
<input type="checkbox">
Remember me
Recuerdame
</label>
</div>
<button class="button is-block is-info is-large is-fullwidth">Login</button>
<button class="button is-block is-info is-large is-fullwidth">Entrar</button>
</form>
</div>
</div>

+ 2
- 3
Padel/padel/templates/base.html View File

@ -18,17 +18,16 @@
<body>
<section class="hero is-primary is-fullheight">
{% include("_navegacion.html") %}
<header>
{% block header %}{% endblock header %}
</header>
<main>
<div class="hero-body">
<div class="container has-text-centered">
{% block content %}
{% endblock %}
</div>
</div> </main>
</div>
<script src="" async defer></script>
</section>
</body>

+ 1
- 1
Padel/padel/templates/paginas/inicio.html View File

@ -1,7 +1,7 @@
{% extends 'base.html' %}
{% block header %}
<h2>{% block title %}Inicio{% endblock title %}</h2>
<h2 class="subtitle is-1">Inicio</h2>
{% endblock header %}
{% block content %}


+ 15
- 11
Padel/padel/templates/reservas/misreservas.html View File

@ -1,20 +1,24 @@
{% extends 'base.html' %}
{% block header %}
<h1 class="title">
Welcome, {{ name }}!
</h1>
<h2>{% block title %}Reservas de padel{% endblock title %}</h2>
<section class="hero is-primary">
<div class="hero-body">
<p class="title"> ¡Bienvenido, {{ name }}!</p>
</div>
<div class="hero-body">
<p class="subtitle"> Estas son tus reservas de padel</p>
</div>
</section>
{% endblock header %}
{% block content %}
<table id="tablareservas" border = 1>
<table class="table" id="tablareservas" border = 1>
<thead>
<td id="columnid">ID</td>
<td id="columnnombre">Nombre</td>
<td>Fecha</td>
<td>Hora</td>
<td>Eliminar</td>
<th id="columnid">ID</th>
<th id="columnnombre">Nombre</th>
<th>Fecha</th>
<th>Hora</th>
<th></th>
</thead>
{% for reserva in reservas %}
@ -25,7 +29,7 @@
<td>{{ reserva.hora }}</td>
<td>
<form class="form-eliminar" action="{{ url_for('reservas.eliminar_reserva', id=reserva.id) }}" method="post" style="display: inline;">
<button type="submit" class="eliminar-btn">Eliminar</button>
<button type="submit" class="button is-danger is-small">Eliminar</button>
</form>
</td>
</tr>


+ 8
- 8
Padel/padel/templates/reservas/reservar.html View File

@ -6,21 +6,21 @@
{% block content %}
<form action="/inserta/{{ diaelegido }}" method="post">
<div class="form-group">
<!--
<div class="field">
<label for="nombre">Nombre:</label>
<input type="text" id="nombre" name="nombre" required class="form-control"><br>
</div>
<div class="form-group">
-->
<div class="field">
<!-- <label for="fecha">Fecha:</label>
<input type="date" id="fecha" name="fecha" required class="form-control" min="{{ diaelegido }}", max="{{ diaelegido }}", value={{ diaelegido }}""><br> -->
<p>Fecha de la reserva: {{ diaelegido }} </p>
<textarea class="textarea" rows="1">Fecha de la reserva: {{ diaelegido }} </textarea>
</div>
<div class="form-group">
<div class="field">
<label for="hora">Hora:</label>
<input type="time" id="hora" name="hora" required class="form-control" list="horas-permitidas"><br>
<input class="input" type="time" id="hora" name="hora" required class="form-control" list="horas-permitidas"><br>
</div>
<datalist id="horas-permitidas">
<option value="08:00"></option>
@ -35,7 +35,7 @@
<option value="17:00"></option>
</datalist>
<div class="form-group">
<button type="submit" class="submit-btn">Reservar</button>
<button type="submit" class="button is-medium">Reservar</button>
</div>
</form>


Loading…
Cancel
Save