Browse Source

Se pueden crear repostajes

politica
Celestino Rey 1 year ago
parent
commit
b8b6a22c0d
11 changed files with 29 additions and 33 deletions
  1. +8
    -4
      RepostajesPy/servicios/repostajes/paginas.py
  2. +1
    -1
      RepostajesPy/servicios/repostajes/templates/_branding.html
  3. +1
    -1
      RepostajesPy/servicios/repostajes/templates/_head.html
  4. +1
    -1
      RepostajesPy/servicios/repostajes/templates/_navegacion.html
  5. +11
    -10
      RepostajesPy/servicios/repostajes/templates/add_repostaje.html
  6. +1
    -1
      RepostajesPy/servicios/repostajes/templates/edit_vehiculo.html
  7. +2
    -2
      RepostajesPy/servicios/repostajes/templates/index.html
  8. +1
    -1
      RepostajesPy/servicios/repostajes/templates/repostajes.html
  9. +0
    -9
      RepostajesPy/servicios/repostajes/templates/song.html
  10. +1
    -1
      RepostajesPy/servicios/repostajes/templates/vehiculo.html
  11. +2
    -2
      RepostajesPy/servicios/repostajes/templates/vehiculoscard.html

+ 8
- 4
RepostajesPy/servicios/repostajes/paginas.py View File

@ -2,7 +2,7 @@ from flask import Blueprint, render_template, request, redirect, url_for, curren
from werkzeug.utils import secure_filename
from flask_login import login_user, logout_user, login_required
from sqlalchemy import desc
import datetime
import os
from .models import db, Repostajes, Vehiculos
@ -51,20 +51,24 @@ def repostaje(repostaje_id):
@login_required
def add_repostaje():
if request.method == 'POST':
fecha = request.form['fecha']
fecha = datetime.date.fromisoformat(request.form['fecha'])
vehiculo_id = request.form['vehiculo_id']
kms = request.form['kms']
litros = request.form['litros']
importe = request.form['importe']
descuento = 0
precioxlitro = int(importe) / int(litros)
new_repostaje = Repostajes(fecha=fecha, vehiculo_id=vehiculo_id, kms=kms, litros=litros, importe=importe)
new_repostaje = Repostajes(fecha=fecha, vehiculo_id=vehiculo_id, kms=kms, litros=litros, importe=importe, descuento=descuento, precioxlitro=precioxlitro)
db.session.add(new_repostaje)
db.session.commit()
return redirect(url_for('paginas.vehiculo', vehiculo_id=vehiculo_id))
vehiculos = Vehiculos.query.all()
for coche in vehiculos:
print("add_repostaje: ", coche.matricula)
return render_template('add_repostaje.html', vehiculos=vehiculos)
@bp.route('/edit_repostaje/<int:repostaje_id>', methods=['GET', 'POST'])


+ 1
- 1
RepostajesPy/servicios/repostajes/templates/_branding.html View File

@ -1,4 +1,4 @@
<div class="app-branding">
<a class="app-logo" href="{{ url_for('paginas.index') }}"><img class="logo-icon me-2" src="{{ url_for('static', filename='images/reymota-logo.svg') }}" alt="logo"><span class="logo-text">LETRAS</span></a>
<a class="app-logo" href="{{ url_for('paginas.index') }}"><img class="logo-icon me-2" src="{{ url_for('static', filename='images/reymota-logo.svg') }}" alt="logo"><span class="logo-text">REPOSTAJES</span></a>
</div><!--//app-branding-->

+ 1
- 1
RepostajesPy/servicios/repostajes/templates/_head.html View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Lyrics - Letras de canciones</title>
<title>Repostajes de vehículos particulares</title>
<!-- Meta -->
<meta charset="utf-8">


+ 1
- 1
RepostajesPy/servicios/repostajes/templates/_navegacion.html View File

@ -1,7 +1,7 @@
<nav class="navbar is-dark" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<img src="{{ url_for('static', filename='bruce.jpeg') }}" class="image is-48x48"/>
<a class="navbar-item" href="/">Letras de canciones</a>
<a class="navbar-item" href="/">Repostajes de vehículos</a>
<div class="navbar-burger" role="button" data-target="navMenu">
<span></span>


+ 11
- 10
RepostajesPy/servicios/repostajes/templates/add_repostaje.html View File

@ -13,8 +13,8 @@
<div class="text mb-3">
<label for="vehiculo_id">Vehículo:</label>
<select class="form-control" id="vehiculo_id" name="vehiculo_id" required>
{% for vehiculo in vehículos %}
<option value="{{ vehiculo.id }}" data-matricula="{{ vehiculo.matricula }}">{{ vehiculo.matricula }}</option>
{% for vehiculo in vehiculos %}
<option value="{{ vehiculo.id }}">{{ vehiculo.matricula }}</option>
{% endfor %}
</select>
</div>
@ -39,19 +39,20 @@
</div>
</form>
</div>
<!--
<script>
function updateAuthor() {
var repostajeSelect = document.getElementById("repostaje_id");
var selectedrepostaje = repostajeSelect.options[repostajeSelect.selectedIndex];
var artist = selectedrepostaje.getAttribute("data-artist");
document.getElementById("author").value = artist;
function updateVehiculo() {
var vehiculoSelect = document.getElementById("vehiculo_id");
var selectedVehiculo = vehiculoSelect.options[vehiculoSelect.selectedIndex];
var matricula = selectedVehiculo.getAttribute("data-matricula");
document.getElementById("vehiculo").value = artist;
}
// Initialize the author field with the artist of the first repostaje
// Initialize the vehiculo field with the artist of the first repostaje
document.addEventListener('DOMContentLoaded', function() {
updateAuthor();
updateVehiculo();
});
</script>
-->
</div>
{% endblock %}

+ 1
- 1
RepostajesPy/servicios/repostajes/templates/edit_vehiculo.html View File

@ -3,7 +3,7 @@
{% block content %}
<div class="column is-4 is-offset-4">
<h3>Editar Álbum</h3>
<h3>Editar vehículo</h3>
<div class="box">
<form method="POST" enctype="multipart/form-data" action="{{ url_for('paginas.edit_vehiculo', vehiculo_id=vehiculo.id) }}">


+ 2
- 2
RepostajesPy/servicios/repostajes/templates/index.html View File

@ -9,11 +9,11 @@
<div class="app-card alert alert-dismissible shadow-sm mb-4 border-left-decoration" role="alert">
<div class="inner">
<div class="app-card-body p-3 p-lg-4">
<h3 class="mb-3">¡Bienvenido a la colección de letras de canciones!</h3>
<h3 class="mb-3">¡Bienvenido al registro de repostajes de mis vehículos!</h3>
<div class="row gx-5 gy-3">
<div class="col-12 col-lg-9">
<div>Pensado inicialmente para guardar las letras de las canciones de Bruce Springsteen.</div>
<div>Pensado para tener información del consumo de los coches.</div>
</div><!--//col-->
</div><!--//row-->
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>


+ 1
- 1
RepostajesPy/servicios/repostajes/templates/repostajes.html View File

@ -11,7 +11,7 @@
<nav id="orders-table-tab" class="orders-table-tab app-nav-tabs nav shadow-sm flex-column flex-sm-row mb-4">
<a class="flex-sm-fill text-sm-center nav-link active" id="repostajes-tab" data-bs-toggle="tab" href="#repostajes" role="tab" aria-controls="repostajes" aria-selected="true">Letras</a>
<a class="flex-sm-fill text-sm-center nav-link active" id="repostajes-tab" data-bs-toggle="tab" href="#repostajes" role="tab" aria-controls="repostajes" aria-selected="true">Repostajes</a>
</nav>


+ 0
- 9
RepostajesPy/servicios/repostajes/templates/song.html View File

@ -34,13 +34,4 @@
<pre>{{ song.lyrics }}</pre>
</div><!--//app-card-body-->
</div><!--//app-card-->
<!--
<h2>{{ song.title }}</h2>
<p><strong>Autor:</strong> {{ song.author }}</p>
<p><strong>Año:</strong> {{ song.album.year }}</p>
<p><strong>Álbum:</strong> {{ song.album.name }}</p>
<pre>{{ song.lyrics }}</pre>
</div>
-->
{% endblock %}

+ 1
- 1
RepostajesPy/servicios/repostajes/templates/vehiculo.html View File

@ -55,7 +55,7 @@
</tbody>
</table>
{% else %}
<p>No se han encontrado vehículos con ese criterio</p>
<p>No se han encontrado repostajes para este vehículo</p>
{% endif %}
</div>
</div>


+ 2
- 2
RepostajesPy/servicios/repostajes/templates/vehiculoscard.html View File

@ -5,14 +5,14 @@
<div class="row g-3 mb-4 align-items-center justify-content-between">
<div class="col-auto">
<h1 class="app-page-title mb-0">Álbumes</h1>
<h1 class="app-page-title mb-0">Vehículos</h1>
</div>
</div><!--//row-->
<div class="col-auto">
<div class="page-utilities">
<div class="row g-4 justify-content-start justify-content-md-end align-items-center">
<div class="col-auto">
<a class="btn app-btn-primary" href="{{ url_for('paginas.add_vehiculo') }}">Añadir álbum</a>
<a class="btn app-btn-primary" href="{{ url_for('paginas.add_vehiculo') }}">Añadir vehículo</a>
</div>
<div class="col-auto">


Loading…
Cancel
Save