From 99eb75f1ba8eed261b55b79b0bc7e0b42be70c33 Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Tue, 11 Jun 2024 09:11:02 +0200 Subject: [PATCH] Proyecto para migrar repostajes a python --- Mail/deployment.yaml | 0 Mail/repostajes 2024 05 30.sql | 87 ++++++++++++++ RepostajesPy/project/__init__.py | 42 +++++++ RepostajesPy/project/auth.py | 63 ++++++++++ RepostajesPy/project/main.py | 34 ++++++ RepostajesPy/project/models.py | 28 +++++ RepostajesPy/project/templates/base.html | 59 +++++++++ RepostajesPy/project/templates/index.html | 12 ++ RepostajesPy/project/templates/listado.html | 12 ++ RepostajesPy/project/templates/login.html | 38 ++++++ RepostajesPy/project/templates/profile.html | 9 ++ RepostajesPy/project/templates/signup.html | 39 ++++++ RepostajesPy/repostajes.sql | 88 ++++++++++++++ flask_crud/app.py | 69 +++++++++++ flask_crud/auth.py | 62 ++++++++++ flask_crud/forms.py | 21 ++++ flask_crud/initdb.sh | 4 + flask_crud/instance/students.db | Bin 0 -> 40960 bytes flask_crud/migrations/README | 1 + flask_crud/migrations/alembic.ini | 50 ++++++++ flask_crud/migrations/env.py | 113 ++++++++++++++++++ flask_crud/migrations/script.py.mako | 24 ++++ .../8eb4774e3960_initial_migration.py | 46 +++++++ .../9f932e36f8fb_initial_migration.py | 34 ++++++ .../aa6e7ede1321_initial_migration.py | 35 ++++++ flask_crud/models.py | 35 ++++++ flask_crud/repostajes.sql | 88 ++++++++++++++ flask_crud/templates/add_record.html | 27 +++++ flask_crud/templates/base.html | 59 +++++++++ flask_crud/templates/edit_record.html | 17 +++ flask_crud/templates/index.html | 35 ++++++ flask_crud/templates/layout.html | 12 ++ flask_crud/templates/login.html | 42 +++++++ flask_crud/templates/signup.html | 39 ++++++ 34 files changed, 1324 insertions(+) create mode 100644 Mail/deployment.yaml create mode 100644 Mail/repostajes 2024 05 30.sql create mode 100644 RepostajesPy/project/__init__.py create mode 100644 RepostajesPy/project/auth.py create mode 100644 RepostajesPy/project/main.py create mode 100644 RepostajesPy/project/models.py create mode 100644 RepostajesPy/project/templates/base.html create mode 100644 RepostajesPy/project/templates/index.html create mode 100644 RepostajesPy/project/templates/listado.html create mode 100644 RepostajesPy/project/templates/login.html create mode 100644 RepostajesPy/project/templates/profile.html create mode 100644 RepostajesPy/project/templates/signup.html create mode 100644 RepostajesPy/repostajes.sql create mode 100644 flask_crud/app.py create mode 100644 flask_crud/auth.py create mode 100644 flask_crud/forms.py create mode 100644 flask_crud/initdb.sh create mode 100644 flask_crud/instance/students.db create mode 100644 flask_crud/migrations/README create mode 100644 flask_crud/migrations/alembic.ini create mode 100644 flask_crud/migrations/env.py create mode 100644 flask_crud/migrations/script.py.mako create mode 100644 flask_crud/migrations/versions/8eb4774e3960_initial_migration.py create mode 100644 flask_crud/migrations/versions/9f932e36f8fb_initial_migration.py create mode 100644 flask_crud/migrations/versions/aa6e7ede1321_initial_migration.py create mode 100644 flask_crud/models.py create mode 100644 flask_crud/repostajes.sql create mode 100644 flask_crud/templates/add_record.html create mode 100644 flask_crud/templates/base.html create mode 100644 flask_crud/templates/edit_record.html create mode 100644 flask_crud/templates/index.html create mode 100644 flask_crud/templates/layout.html create mode 100644 flask_crud/templates/login.html create mode 100644 flask_crud/templates/signup.html diff --git a/Mail/deployment.yaml b/Mail/deployment.yaml new file mode 100644 index 0000000..e69de29 diff --git a/Mail/repostajes 2024 05 30.sql b/Mail/repostajes 2024 05 30.sql new file mode 100644 index 0000000..87948e1 --- /dev/null +++ b/Mail/repostajes 2024 05 30.sql @@ -0,0 +1,87 @@ +-- MySQL dump 10.13 Distrib 8.0.36, for Linux (x86_64) +-- +-- Host: localhost Database: automoviles +-- ------------------------------------------------------ +-- Server version 11.2.2-MariaDB-1:11.2.2+maria~ubu2204 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `carburante` +-- + +DROP TABLE IF EXISTS `carburante`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `carburante` ( + `identificador` int(11) NOT NULL AUTO_INCREMENT, + `fecha` date DEFAULT NULL, + `vehiculo` text DEFAULT NULL, + `kms` int(11) DEFAULT NULL, + `litros` decimal(10,3) DEFAULT NULL, + `descuento` decimal(10,2) DEFAULT NULL, + `precioxlitro` decimal(10,3) DEFAULT NULL, + `importe` decimal(10,2) DEFAULT NULL, + PRIMARY KEY (`identificador`) +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `carburante` +-- + +LOCK TABLES `carburante` WRITE; +/*!40000 ALTER TABLE `carburante` DISABLE KEYS */; +INSERT INTO `carburante` VALUES (1,'2021-12-14','1018KPD',52731,0.000,0.00,0.000,0.00),(2,'2021-12-23','1018KPD',53162,52.800,0.00,1.280,67.32),(3,'2021-12-31','1018KPD',54122,49.990,0.00,1.280,63.74),(4,'2022-01-22','1018KPD',54946,49.140,0.00,1.270,62.65),(5,'2022-02-09','1018KPD',55908,49.240,0.00,1.320,65.24),(6,'2022-03-03','1018KPD',56909,48.610,0.00,1.380,67.03),(7,'2022-03-18','1018KPD',57542,30.060,0.00,1.750,52.54),(8,'2022-04-10','1018KPD',58497,46.630,0.00,1.500,69.98),(9,'2022-05-12','1018KPD',59447,47.140,0.00,1.530,72.11),(10,'2022-05-19','1018KPD',60414,48.570,0.00,1.640,79.81),(11,'2022-06-09','1018KPD',61147,36.200,0.00,1.720,62.12),(12,'2022-06-25','1018KPD',62116,49.170,0.00,1.840,90.29),(16,'2022-09-14','1018KPD',66359,53.240,0.00,1.590,84.83),(17,'2022-09-23','1018KPD',67107,37.260,0.00,1.490,55.48),(19,'2023-01-24','1018KPD',71790,43.040,2.12,1.590,70.54),(21,'2022-12-03','1018KPD',70061,46.380,2.04,1.420,68.13),(22,'2022-12-26','1018KPD',70919,44.580,1.85,1.34 +0,61.68),(23,'2023-03-05','1018KPD',73711,47.850,0.00,1.490,71.20),(24,'2023-03-25','1018KPD',74749,49.840,0.00,1.450,72.17),(25,'2023-02-19','1018KPD',72763,49.380,2.34,1.530,77.97),(27,'2023-05-06','1018KPD',76434,32.280,0.00,1.370,44.09),(28,'2023-05-22','1018KPD',77366,45.040,0.00,1.300,58.46),(45,'2022-07-09','1018KPD',63129,47.030,0.00,1.690,79.38),(46,'2022-08-12','1018KPD',64088,43.730,0.00,1.500,65.55),(47,'2022-08-22','1018KPD',65185,52.780,0.00,1.490,78.80),(50,'2022-10-12','1018KPD',68204,52.040,2.51,1.560,83.73),(51,'2022-11-11','1018KPD',69158,45.280,2.37,1.690,78.91),(61,'2023-06-10','1018KPD',78170,41.090,0.00,1.320,54.16),(62,'2023-06-19','1018KPD',79038,40.780,1.95,1.430,60.11),(151,'2022-06-28','7630LYR',219,9.880,0.00,1.920,18.96),(152,'2022-06-28','7630LYR',236,27.360,0.00,1.880,51.33),(153,'2022-07-14','7630LYR',904,32.240,0.00,1.720,55.58),(154,'2022-07-26','7630LYR',1433,30.490,0.00,1.590,48.43),(155,'2022-08-21','7630LYR',2030,32.920,0.00,1.420,46.72),(156,' +2022-09-26','7630LYR',2627,23.920,0.00,1.390,33.16),(157,'2022-10-18','7630LYR',3169,22.970,0.00,1.430,32.74),(158,'2022-11-09','7630LYR',3791,29.600,0.00,1.410,41.88),(159,'2022-11-27','7630LYR',4363,28.800,1.20,1.350,38.80),(160,'2022-12-22','7630LYR',4851,26.740,1.06,1.280,34.18),(161,'2023-01-12','7630LYR',5291,23.520,1.09,1.500,35.34),(162,'2023-02-01','7630LYR',5702,27.360,1.28,1.520,41.52),(163,'2023-02-20','7630LYR',6141,24.090,1.13,1.520,36.67),(164,'2023-03-15','7630LYR',6631,25.520,1.21,1.530,38.96),(165,'2023-04-17','7630LYR',7325,29.400,1.47,1.620,47.62),(166,'2023-05-28','7630LYR',8413,24.160,1.17,1.560,37.70),(167,'2023-06-25','7630LYR',8956,26.380,1.30,1.590,41.94),(168,'2023-07-10','7630LYR',9471,29.040,1.35,1.497,43.49),(176,'2023-07-14','1018KPD',79875,40.560,1.74,1.407,56.26),(177,'2023-07-22','1018KPD',80806,46.290,1.95,1.371,63.05),(178,'2023-07-25','7630LYR',10043,24.850,1.40,1.622,40.32),(182,'2023-08-07','1018KPD',81695,44.390,0.00,1.439,63.88),(201,'2023-08 +-09','7630LYR',10582,26.490,1.39,1.696,44.94),(202,'2023-08-23','7630LYR',11050,24.050,1.22,1.638,39.40),(203,'2023-08-27','1018KPD',82715,50.400,0.00,1.529,77.06),(204,'2023-09-14','7630LYR',11508,21.440,1.14,1.726,37.00),(205,'2023-09-19','1018KPD',83709,48.350,0.00,1.598,77.26),(206,'2023-09-27','1018KPD',84171,23.010,0.00,1.558,35.85),(207,'2023-10-10','1018KPD',85104,48.000,0.00,1.509,72.43),(212,'2023-10-15','7630LYR',12006,25.090,1.25,1.609,40.37),(213,'2023-10-27','1018KPD',86021,46.770,0.00,1.499,70.11),(214,'2023-11-04','7630LYR',12427,25.640,1.17,1.474,37.78),(215,'2023-11-11','1018KPD',86757,39.580,1.71,1.398,55.33),(216,'2023-11-20','7630LYR',12933,26.160,0.00,1.529,40.00),(217,'2023-11-23','1018KPD',87503,42.410,1.75,1.331,56.45),(218,'2023-12-04','1018KPD',88256,41.190,0.00,1.399,57.62),(219,'2023-12-17','1018KPD',88964,41.200,1.66,1.305,53.78),(220,'2024-01-06','7630LYR',13414,30.720,1.34,1.411,43.36),(222,'2024-01-07','1018KPD',89802,47.770,1.91,1.293,61.75),(223,'2 +024-01-22','7630LYR',13903,25.080,0.00,1.479,37.09),(224,'2024-01-27','1018KPD',90723,45.250,0.00,1.334,60.37),(226,'2024-02-11','7630LYR',14365,28.450,0.00,1.454,41.37),(233,'2024-02-12','1018KPD',91672,48.310,0.00,1.449,70.00),(235,'2024-02-27','1018KPD',92489,41.990,0.00,1.379,57.91),(236,'2024-02-29','7630LYR',14857,23.960,1.12,1.517,36.35),(237,'2024-03-18','7630LYR',15287,13.000,0.00,1.538,20.00),(239,'2024-03-19','1018KPD',93327,43.850,0.00,1.374,60.25),(240,'2024-03-25','7630LYR',15537,19.240,0.00,1.559,30.00),(241,'2024-04-06','7630LYR',15935,29.390,0.00,1.479,43.48),(242,'2024-04-08','1018KPD',94167,41.110,0.00,1.374,56.49),(243,'2024-04-22','7630LYR',16465,25.920,0.00,1.569,40.66),(244,'2024-04-29','1018KPD',95042,43.630,0.00,1.445,63.03),(247,'2024-05-13','7630LYR',16963,26.800,0.00,1.549,41.51),(248,'2024-05-21','1018KPD',96585,28.330,0.00,1.399,39.63),(249,'2024-05-27','1018KPD',97597,49.480,0.00,1.373,67.96); +/*!40000 ALTER TABLE `carburante` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `vehiculos` +-- + +DROP TABLE IF EXISTS `vehiculos`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `vehiculos` ( + `identificador` int(11) NOT NULL AUTO_INCREMENT, + `marca` text NOT NULL, + `modelo` text NOT NULL, + `matricula` text NOT NULL, + PRIMARY KEY (`identificador`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `vehiculos` +-- + +LOCK TABLES `vehiculos` WRITE; +/*!40000 ALTER TABLE `vehiculos` DISABLE KEYS */; +INSERT INTO `vehiculos` VALUES (2,'Toyota','Corolla','7630LYR'),(3,'BMW','318d','1018KPD'); +/*!40000 ALTER TABLE `vehiculos` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2024-05-30 19:20:57 \ No newline at end of file diff --git a/RepostajesPy/project/__init__.py b/RepostajesPy/project/__init__.py new file mode 100644 index 0000000..f3af90b --- /dev/null +++ b/RepostajesPy/project/__init__.py @@ -0,0 +1,42 @@ +# init.py + +from flask import Flask +from flask_sqlalchemy import SQLAlchemy +from flask_login import LoginManager +from . import models + +# init SQLAlchemy so we can use it later in our models +db = SQLAlchemy() + +def create_app(): + app = Flask(__name__) + + app.config['SECRET_KEY'] = '9OLWxND4o83j4K4iuopO' + app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite' + + db.init_app(app) + + with app.app_context(): + db.create_all() + + + login_manager = LoginManager() + login_manager.login_view = 'auth.login' + login_manager.init_app(app) + + from .models import User + + @login_manager.user_loader + def load_user(user_id): + # since the user_id is just the primary key of our user table, use it in the query for the user + return User.query.get(int(user_id)) + + # blueprint for auth routes in our app + from .auth import auth as auth_blueprint + app.register_blueprint(auth_blueprint) + + # blueprint for non-auth parts of app + from .main import main as main_blueprint + app.register_blueprint(main_blueprint) + + return app \ No newline at end of file diff --git a/RepostajesPy/project/auth.py b/RepostajesPy/project/auth.py new file mode 100644 index 0000000..8f714e3 --- /dev/null +++ b/RepostajesPy/project/auth.py @@ -0,0 +1,63 @@ +# auth.py + +from flask import Blueprint, render_template, redirect, url_for, request, flash +from werkzeug.security import generate_password_hash, check_password_hash +from flask_login import login_user, logout_user, login_required +from .models import User +from . import db + +auth = Blueprint('auth', __name__) + +@auth.route('/login') +def login(): + return render_template('login.html') + +@auth.route('/login', methods=['POST']) +def login_post(): + email = request.form.get('email') + password = request.form.get('password') + remember = True if request.form.get('remember') else False + + user = User.query.filter_by(email=email).first() + + # check if user actually exists + # take the user supplied password, hash it, and compare it to the hashed password in database + if not user or not check_password_hash(user.password, password): + flash('Please check your login details and try again.') + return redirect(url_for('auth.login')) # if 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 + login_user(user, remember=remember) + return redirect(url_for('main.profile')) + +@auth.route('/signup') +def signup(): + return render_template('signup.html') + +@auth.route('/signup', methods=['POST']) +def signup_post(): + + email = request.form.get('email') + name = request.form.get('name') + password = request.form.get('password') + + user = User.query.filter_by(email=email).first() # if this returns a user, then the email already exists in database + + if user: # if a user is found, we want to redirect back to signup page so user can try again + flash('Email address already exists') + return redirect(url_for('auth.signup')) + + # create new user with the form data. Hash the password so plaintext version isn't saved. + new_user = User(email=email, name=name, password=generate_password_hash(password, method='pbkdf2:sha256')) + + # add the new user to the database + db.session.add(new_user) + db.session.commit() + + return redirect(url_for('auth.login')) + +@auth.route('/logout') +@login_required +def logout(): + logout_user() + return redirect(url_for('main.index')) \ No newline at end of file diff --git a/RepostajesPy/project/main.py b/RepostajesPy/project/main.py new file mode 100644 index 0000000..3b278d4 --- /dev/null +++ b/RepostajesPy/project/main.py @@ -0,0 +1,34 @@ +# main.py + +from flask import Blueprint, render_template, redirect, url_for + +from flask_login import login_required, current_user +from .models import Carburante, db + + +main = Blueprint('main', __name__) + +@main.route('/') +def index(): + return render_template('index.html') + +@main.route('/profile') +@login_required +def profile(): + return render_template('profile.html', name=current_user.name) + +@main.route('/listado') +def listado(): + + + repostaje = db.get_or_404(Carburante, 1) + + # check if user actually exists + # take the user supplied password, hash it, and compare it to the hashed password in database + if not repostaje : + print("no encuentro nada") + return redirect(url_for('main.profile')) # if user doesn't exist or password is wrong, reload the page + + print("Datos: ", repostaje) + # if the above check passes, then we know the user has the right credentials + return redirect(url_for('main.listado')) \ No newline at end of file diff --git a/RepostajesPy/project/models.py b/RepostajesPy/project/models.py new file mode 100644 index 0000000..baaeb79 --- /dev/null +++ b/RepostajesPy/project/models.py @@ -0,0 +1,28 @@ +# models.py + +from flask_login import UserMixin +from flask_sqlalchemy import SQLAlchemy + +db = SQLAlchemy() + +class User(UserMixin, db.Model): + id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy + email = db.Column(db.String(100), unique=True) + password = db.Column(db.String(100)) + name = db.Column(db.String(1000)) + +class Carburante(db.Model): + identificador = db.Column(db.Integer, primary_key=True) + fecha = db.Column(db.Date()) + vehiculo = db.Column(db.String(20)) + kms = db.Column(db.Integer) + litros = db.Column(db.DECIMAL(10,3)) + descuento = db.Column(db.DECIMAL(10,2)) + precioxlitro = db.Column(db.DECIMAL(10,3)) + importe = db.Column(db.DECIMAL(10,2)) + +class Vehiculos(db.Model): + identificador = db.Column(db.Integer, primary_key=True) + marca = db.Column(db.String(20)) + modelo = db.Column(db.String(20)) + matricula = db.Column(db.String(20)) diff --git a/RepostajesPy/project/templates/base.html b/RepostajesPy/project/templates/base.html new file mode 100644 index 0000000..032260a --- /dev/null +++ b/RepostajesPy/project/templates/base.html @@ -0,0 +1,59 @@ + + + + + + + + + + Flask Auth Example + + + + +
+ +
+ +
+ +
+
+ {% block content %} + {% endblock %} +
+
+
+ + + \ No newline at end of file diff --git a/RepostajesPy/project/templates/index.html b/RepostajesPy/project/templates/index.html new file mode 100644 index 0000000..af298cb --- /dev/null +++ b/RepostajesPy/project/templates/index.html @@ -0,0 +1,12 @@ + + +{% extends "base.html" %} + +{% block content %} +

+ Flask Login Example +

+

+ Easy authentication and authorization in Flask. +

+{% endblock %} \ No newline at end of file diff --git a/RepostajesPy/project/templates/listado.html b/RepostajesPy/project/templates/listado.html new file mode 100644 index 0000000..cf510e2 --- /dev/null +++ b/RepostajesPy/project/templates/listado.html @@ -0,0 +1,12 @@ + + +{% extends "base.html" %} + +{% block content %} +

+ Welcome, {{ name }}! +

+

+ Aquí saldrá el listado +

+{% endblock %} \ No newline at end of file diff --git a/RepostajesPy/project/templates/login.html b/RepostajesPy/project/templates/login.html new file mode 100644 index 0000000..f78f4e7 --- /dev/null +++ b/RepostajesPy/project/templates/login.html @@ -0,0 +1,38 @@ + + +{% extends "base.html" %} + +{% block content %} +
+

Login

+
+ {% with messages = get_flashed_messages() %} + {% if messages %} +
+ {{ messages[0] }} +
+ {% endif %} + {% endwith %} +
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+ +
+
+
+{% endblock %} \ No newline at end of file diff --git a/RepostajesPy/project/templates/profile.html b/RepostajesPy/project/templates/profile.html new file mode 100644 index 0000000..c2c49fd --- /dev/null +++ b/RepostajesPy/project/templates/profile.html @@ -0,0 +1,9 @@ + + +{% extends "base.html" %} + +{% block content %} +

+ Welcome, {{ name }}! +

+{% endblock %} \ No newline at end of file diff --git a/RepostajesPy/project/templates/signup.html b/RepostajesPy/project/templates/signup.html new file mode 100644 index 0000000..ce68a11 --- /dev/null +++ b/RepostajesPy/project/templates/signup.html @@ -0,0 +1,39 @@ + + +{% extends "base.html" %} + +{% block content %} +
+

Sign Up

+
+ {% with messages = get_flashed_messages() %} + {% if messages %} +
+ {{ messages[0] }}. Go to login page. +
+ {% endif %} + {% endwith %} +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+
+{% endblock %} \ No newline at end of file diff --git a/RepostajesPy/repostajes.sql b/RepostajesPy/repostajes.sql new file mode 100644 index 0000000..d7ddc57 --- /dev/null +++ b/RepostajesPy/repostajes.sql @@ -0,0 +1,88 @@ +INSERT INTO `carburante` VALUES (1,'2021-12-14','1018KPD',52731,0.000,0.00,0.000,0.00); +INSERT INTO `carburante` VALUES (2,'2021-12-23','1018KPD',53162,52.800,0.00,1.280,67.32); +INSERT INTO `carburante` VALUES (3,'2021-12-31','1018KPD',54122,49.990,0.00,1.280,63.74); +INSERT INTO `carburante` VALUES (4,'2022-01-22','1018KPD',54946,49.140,0.00,1.270,62.65); +INSERT INTO `carburante` VALUES (5,'2022-02-09','1018KPD',55908,49.240,0.00,1.320,65.24); +INSERT INTO `carburante` VALUES (6,'2022-03-03','1018KPD',56909,48.610,0.00,1.380,67.03); +INSERT INTO `carburante` VALUES (7,'2022-03-18','1018KPD',57542,30.060,0.00,1.750,52.54); +INSERT INTO `carburante` VALUES (8,'2022-04-10','1018KPD',58497,46.630,0.00,1.500,69.98); +INSERT INTO `carburante` VALUES (9,'2022-05-12','1018KPD',59447,47.140,0.00,1.530,72.11); +INSERT INTO `carburante` VALUES (10,'2022-05-19','1018KPD',60414,48.570,0.00,1.640,79.81); +INSERT INTO `carburante` VALUES (11,'2022-06-09','1018KPD',61147,36.200,0.00,1.720,62.12); +INSERT INTO `carburante` VALUES (12,'2022-06-25','1018KPD',62116,49.170,0.00,1.840,90.29); +INSERT INTO `carburante` VALUES (16,'2022-09-14','1018KPD',66359,53.240,0.00,1.590,84.83); +INSERT INTO `carburante` VALUES (17,'2022-09-23','1018KPD',67107,37.260,0.00,1.490,55.48); +INSERT INTO `carburante` VALUES (19,'2023-01-24','1018KPD',71790,43.040,2.12,1.590,70.54); +INSERT INTO `carburante` VALUES (21,'2022-12-03','1018KPD',70061,46.380,2.04,1.420,68.13); +INSERT INTO `carburante` VALUES (22,'2022-12-26','1018KPD',70919,44.580,1.85,1.340,61.68); +INSERT INTO `carburante` VALUES (23,'2023-03-05','1018KPD',73711,47.850,0.00,1.490,71.20); +INSERT INTO `carburante` VALUES (24,'2023-03-25','1018KPD',74749,49.840,0.00,1.450,72.17); +INSERT INTO `carburante` VALUES (25,'2023-02-19','1018KPD',72763,49.380,2.34,1.530,77.97); +INSERT INTO `carburante` VALUES (27,'2023-05-06','1018KPD',76434,32.280,0.00,1.370,44.09); +INSERT INTO `carburante` VALUES (28,'2023-05-22','1018KPD',77366,45.040,0.00,1.300,58.46); +INSERT INTO `carburante` VALUES (45,'2022-07-09','1018KPD',63129,47.030,0.00,1.690,79.38); +INSERT INTO `carburante` VALUES (46,'2022-08-12','1018KPD',64088,43.730,0.00,1.500,65.55); +INSERT INTO `carburante` VALUES (47,'2022-08-22','1018KPD',65185,52.780,0.00,1.490,78.80); +INSERT INTO `carburante` VALUES (50,'2022-10-12','1018KPD',68204,52.040,2.51,1.560,83.73); +INSERT INTO `carburante` VALUES (51,'2022-11-11','1018KPD',69158,45.280,2.37,1.690,78.91); +INSERT INTO `carburante` VALUES (61,'2023-06-10','1018KPD',78170,41.090,0.00,1.320,54.16); +INSERT INTO `carburante` VALUES (62,'2023-06-19','1018KPD',79038,40.780,1.95,1.430,60.11); +INSERT INTO `carburante` VALUES (151,'2022-06-28','7630LYR',219,9.880,0.00,1.920,18.96); +INSERT INTO `carburante` VALUES (152,'2022-06-28','7630LYR',236,27.360,0.00,1.880,51.33); +INSERT INTO `carburante` VALUES (153,'2022-07-14','7630LYR',904,32.240,0.00,1.720,55.58); +INSERT INTO `carburante` VALUES (154,'2022-07-26','7630LYR',1433,30.490,0.00,1.590,48.43); +INSERT INTO `carburante` VALUES (155,'2022-08-21','7630LYR',2030,32.920,0.00,1.420,46.72); +INSERT INTO `carburante` VALUES (156,'2022-09-26','7630LYR',2627,23.920,0.00,1.390,33.16); +INSERT INTO `carburante` VALUES (157,'2022-10-18','7630LYR',3169,22.970,0.00,1.430,32.74); +INSERT INTO `carburante` VALUES (158,'2022-11-09','7630LYR',3791,29.600,0.00,1.410,41.88); +INSERT INTO `carburante` VALUES (159,'2022-11-27','7630LYR',4363,28.800,1.20,1.350,38.80); +INSERT INTO `carburante` VALUES (160,'2022-12-22','7630LYR',4851,26.740,1.06,1.280,34.18); +INSERT INTO `carburante` VALUES (161,'2023-01-12','7630LYR',5291,23.520,1.09,1.500,35.34); +INSERT INTO `carburante` VALUES (162,'2023-02-01','7630LYR',5702,27.360,1.28,1.520,41.52); +INSERT INTO `carburante` VALUES (163,'2023-02-20','7630LYR',6141,24.090,1.13,1.520,36.67); +INSERT INTO `carburante` VALUES (164,'2023-03-15','7630LYR',6631,25.520,1.21,1.530,38.96); +INSERT INTO `carburante` VALUES (165,'2023-04-17','7630LYR',7325,29.400,1.47,1.620,47.62); +INSERT INTO `carburante` VALUES (166,'2023-05-28','7630LYR',8413,24.160,1.17,1.560,37.70); +INSERT INTO `carburante` VALUES (167,'2023-06-25','7630LYR',8956,26.380,1.30,1.590,41.94); +INSERT INTO `carburante` VALUES (168,'2023-07-10','7630LYR',9471,29.040,1.35,1.497,43.49); +INSERT INTO `carburante` VALUES (176,'2023-07-14','1018KPD',79875,40.560,1.74,1.407,56.26); +INSERT INTO `carburante` VALUES (177,'2023-07-22','1018KPD',80806,46.290,1.95,1.371,63.05); +INSERT INTO `carburante` VALUES (178,'2023-07-25','7630LYR',10043,24.850,1.40,1.622,40.32); +INSERT INTO `carburante` VALUES (182,'2023-08-07','1018KPD',81695,44.390,0.00,1.439,63.88); +INSERT INTO `carburante` VALUES (201,'2023-08-09','7630LYR',10582,26.490,1.39,1.696,44.94); +INSERT INTO `carburante` VALUES (202,'2023-08-23','7630LYR',11050,24.050,1.22,1.638,39.40); +INSERT INTO `carburante` VALUES (203,'2023-08-27','1018KPD',82715,50.400,0.00,1.529,77.06); +INSERT INTO `carburante` VALUES (204,'2023-09-14','7630LYR',11508,21.440,1.14,1.726,37.00); +INSERT INTO `carburante` VALUES (205,'2023-09-19','1018KPD',83709,48.350,0.00,1.598,77.26); +INSERT INTO `carburante` VALUES (206,'2023-09-27','1018KPD',84171,23.010,0.00,1.558,35.85); +INSERT INTO `carburante` VALUES (207,'2023-10-10','1018KPD',85104,48.000,0.00,1.509,72.43); +INSERT INTO `carburante` VALUES (212,'2023-10-15','7630LYR',12006,25.090,1.25,1.609,40.37); +INSERT INTO `carburante` VALUES (213,'2023-10-27','1018KPD',86021,46.770,0.00,1.499,70.11); +INSERT INTO `carburante` VALUES (214,'2023-11-04','7630LYR',12427,25.640,1.17,1.474,37.78); +INSERT INTO `carburante` VALUES (215,'2023-11-11','1018KPD',86757,39.580,1.71,1.398,55.33); +INSERT INTO `carburante` VALUES (216,'2023-11-20','7630LYR',12933,26.160,0.00,1.529,40.00); +INSERT INTO `carburante` VALUES (217,'2023-11-23','1018KPD',87503,42.410,1.75,1.331,56.45); +INSERT INTO `carburante` VALUES (218,'2023-12-04','1018KPD',88256,41.190,0.00,1.399,57.62); +INSERT INTO `carburante` VALUES (219,'2023-12-17','1018KPD',88964,41.200,1.66,1.305,53.78); +INSERT INTO `carburante` VALUES (220,'2024-01-06','7630LYR',13414,30.720,1.34,1.411,43.36); +INSERT INTO `carburante` VALUES (222,'2024-01-07','1018KPD',89802,47.770,1.91,1.293,61.75); +INSERT INTO `carburante` VALUES (223,'2024-01-22','7630LYR',13903,25.080,0.00,1.479,37.09); +INSERT INTO `carburante` VALUES (224,'2024-01-27','1018KPD',90723,45.250,0.00,1.334,60.37); +INSERT INTO `carburante` VALUES (226,'2024-02-11','7630LYR',14365,28.450,0.00,1.454,41.37); +INSERT INTO `carburante` VALUES (233,'2024-02-12','1018KPD',91672,48.310,0.00,1.449,70.00); +INSERT INTO `carburante` VALUES (235,'2024-02-27','1018KPD',92489,41.990,0.00,1.379,57.91); +INSERT INTO `carburante` VALUES (236,'2024-02-29','7630LYR',14857,23.960,1.12,1.517,36.35); +INSERT INTO `carburante` VALUES (237,'2024-03-18','7630LYR',15287,13.000,0.00,1.538,20.00); +INSERT INTO `carburante` VALUES (239,'2024-03-19','1018KPD',93327,43.850,0.00,1.374,60.25); +INSERT INTO `carburante` VALUES (240,'2024-03-25','7630LYR',15537,19.240,0.00,1.559,30.00); +INSERT INTO `carburante` VALUES (241,'2024-04-06','7630LYR',15935,29.390,0.00,1.479,43.48); +INSERT INTO `carburante` VALUES (242,'2024-04-08','1018KPD',94167,41.110,0.00,1.374,56.49); +INSERT INTO `carburante` VALUES (243,'2024-04-22','7630LYR',16465,25.920,0.00,1.569,40.66); +INSERT INTO `carburante` VALUES (244,'2024-04-29','1018KPD',95042,43.630,0.00,1.445,63.03); +INSERT INTO `carburante` VALUES (247,'2024-05-13','7630LYR',16963,26.800,0.00,1.549,41.51); +INSERT INTO `carburante` VALUES (248,'2024-05-21','1018KPD',96585,28.330,0.00,1.399,39.63); +INSERT INTO `carburante` VALUES (249,'2024-05-27','1018KPD',97597,49.480,0.00,1.373,67.96); + + +/** INSERT INTO `vehiculos` VALUES INSERT INTO `carburante` VALUES (2,'Toyota','Corolla','7630LYR'); +(3,'BMW','318d','1018KPD'); diff --git a/flask_crud/app.py b/flask_crud/app.py new file mode 100644 index 0000000..03de27f --- /dev/null +++ b/flask_crud/app.py @@ -0,0 +1,69 @@ +from flask import Flask, render_template, redirect, url_for, request +from flask_sqlalchemy import SQLAlchemy +from flask_migrate import Migrate +from flask_login import LoginManager, login_required, current_user + +from models import db, Student, User, Carburante +from forms import RepostajeForm + +app = Flask(__name__) +app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///students.db' +app.config['SECRET_KEY'] = 'mysecret' + +db.init_app(app) +migrate = Migrate(app, db) + +login_manager = LoginManager() +login_manager.login_view = 'auth.login' +login_manager.init_app(app) + + +@login_manager.user_loader +def load_user(user_id): + # since the user_id is just the primary key of our user table, use it in the query for the user + return User.query.get(int(user_id)) + +# blueprint for auth routes in our app +from auth import auth as auth_blueprint +app.register_blueprint(auth_blueprint) + +@app.route('/') +def index(): + repostajes = Carburante.query.all() + return render_template('index.html', repostajes=repostajes) + +@app.route('/add', methods=['GET', 'POST']) +@login_required +def add_repostaje(): + form = RepostajeForm() + if form.validate_on_submit(): + precioxlitro = (form.importe.data - form.descuento.data) / form.litros.data + repostaje = Carburante(fecha=form.fecha.data, vehiculo=form.vehiculo.data, kms=form.kms.data, litros=form.litros.data, descuento=form.descuento.data, importe=form.importe.data, precioxlitro=precioxlitro) + db.session.add(repostaje) + db.session.commit() + return redirect(url_for('index')) + return render_template('add_record.html', form=form) + +@app.route('/edit/', methods=['GET', 'POST']) +@login_required +def edit_repostaje(identificador): + repostaje = Carburante.query.get_or_404(id) + form = RepostajeForm(obj=repostaje) + if form.validate_on_submit(): + repostaje.name = form.name.data + repostaje.age = form.age.data + repostaje.grade = form.grade.data + db.session.commit() + return redirect(url_for('index')) + return render_template('edit_record.html', form=form, repostaje=repostaje) + +@app.route('/delete/') +@login_required +def delete_repostaje(id): + repostaje = Carburante.query.get_or_404(id) + db.session.delete(repostaje) + db.session.commit() + return redirect(url_for('index')) + +if __name__ == '__main__': + app.run(debug=True) diff --git a/flask_crud/auth.py b/flask_crud/auth.py new file mode 100644 index 0000000..b38e5cf --- /dev/null +++ b/flask_crud/auth.py @@ -0,0 +1,62 @@ +# auth.py + +from flask import Blueprint, render_template, redirect, url_for, request, flash +from werkzeug.security import generate_password_hash, check_password_hash +from flask_login import login_user, logout_user, login_required +from models import User, db + +auth = Blueprint('auth', __name__) + +@auth.route('/login') +def login(): + return render_template('login.html') + +@auth.route('/login', methods=['POST']) +def login_post(): + email = request.form.get('email') + password = request.form.get('password') + remember = True if request.form.get('remember') else False + + user = User.query.filter_by(email=email).first() + + # check if user actually exists + # take the user supplied password, hash it, and compare it to the hashed password in database + if not user or not check_password_hash(user.password, password): + flash('Please check your login details and try again.') + return redirect(url_for('auth.login')) # if 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 + login_user(user, remember=remember) + return redirect(url_for('index')) + +@auth.route('/signup') +def signup(): + return render_template('signup.html') + +@auth.route('/signup', methods=['POST']) +def signup_post(): + + email = request.form.get('email') + name = request.form.get('name') + password = request.form.get('password') + + user = User.query.filter_by(email=email).first() # if this returns a user, then the email already exists in database + + if user: # if a user is found, we want to redirect back to signup page so user can try again + flash('Email address already exists') + return redirect(url_for('auth.signup')) + + # create new user with the form data. Hash the password so plaintext version isn't saved. + new_user = User(email=email, name=name, password=generate_password_hash(password, method='pbkdf2:sha256')) + + # add the new user to the database + db.session.add(new_user) + db.session.commit() + + return redirect(url_for('auth.login')) + +@auth.route('/logout') +@login_required +def logout(): + logout_user() + return redirect(url_for('index')) \ No newline at end of file diff --git a/flask_crud/forms.py b/flask_crud/forms.py new file mode 100644 index 0000000..529a9d8 --- /dev/null +++ b/flask_crud/forms.py @@ -0,0 +1,21 @@ +from flask_wtf import FlaskForm +from wtforms import StringField, IntegerField, SubmitField, DateField, BooleanField, DecimalField, fields +from wtforms.validators import DataRequired + +class FlexibleDecimalField(fields.DecimalField): + + def process_formdata(self, valuelist): + if valuelist: + valuelist[0] = valuelist[0].replace(",", ".") + return super(FlexibleDecimalField, self).process_formdata(valuelist) + + +class RepostajeForm(FlaskForm): + fecha = DateField('Fecha', validators=[DataRequired()]) + vehiculo = StringField('Vehículo', validators=[DataRequired()]) + kms = IntegerField('Kilómetros', validators=[DataRequired()]) + litros = FlexibleDecimalField('Litros', validators=[DataRequired()]) + descuento = BooleanField('Descuento') + importe = FlexibleDecimalField('Importe', validators=[DataRequired()]) + + submit = SubmitField('Crear') diff --git a/flask_crud/initdb.sh b/flask_crud/initdb.sh new file mode 100644 index 0000000..9ff8cd1 --- /dev/null +++ b/flask_crud/initdb.sh @@ -0,0 +1,4 @@ +export FLASK_APP=app.py +flask db init +flask db migrate -m "Initial migration." +flask db upgrade \ No newline at end of file diff --git a/flask_crud/instance/students.db b/flask_crud/instance/students.db new file mode 100644 index 0000000000000000000000000000000000000000..e05dd134927eeee29f9c06f1392a34434b8ad10a GIT binary patch literal 40960 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 literal 0 HcmV?d00001 diff --git a/flask_crud/migrations/README b/flask_crud/migrations/README new file mode 100644 index 0000000..0e04844 --- /dev/null +++ b/flask_crud/migrations/README @@ -0,0 +1 @@ +Single-database configuration for Flask. diff --git a/flask_crud/migrations/alembic.ini b/flask_crud/migrations/alembic.ini new file mode 100644 index 0000000..ec9d45c --- /dev/null +++ b/flask_crud/migrations/alembic.ini @@ -0,0 +1,50 @@ +# A generic, single database configuration. + +[alembic] +# template used to generate migration files +# file_template = %%(rev)s_%%(slug)s + +# set to 'true' to run the environment during +# the 'revision' command, regardless of autogenerate +# revision_environment = false + + +# Logging configuration +[loggers] +keys = root,sqlalchemy,alembic,flask_migrate + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console +qualname = + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine + +[logger_alembic] +level = INFO +handlers = +qualname = alembic + +[logger_flask_migrate] +level = INFO +handlers = +qualname = flask_migrate + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(levelname)-5.5s [%(name)s] %(message)s +datefmt = %H:%M:%S diff --git a/flask_crud/migrations/env.py b/flask_crud/migrations/env.py new file mode 100644 index 0000000..4c97092 --- /dev/null +++ b/flask_crud/migrations/env.py @@ -0,0 +1,113 @@ +import logging +from logging.config import fileConfig + +from flask import current_app + +from alembic import context + +# this is the Alembic Config object, which provides +# access to the values within the .ini file in use. +config = context.config + +# Interpret the config file for Python logging. +# This line sets up loggers basically. +fileConfig(config.config_file_name) +logger = logging.getLogger('alembic.env') + + +def get_engine(): + try: + # this works with Flask-SQLAlchemy<3 and Alchemical + return current_app.extensions['migrate'].db.get_engine() + except (TypeError, AttributeError): + # this works with Flask-SQLAlchemy>=3 + return current_app.extensions['migrate'].db.engine + + +def get_engine_url(): + try: + return get_engine().url.render_as_string(hide_password=False).replace( + '%', '%%') + except AttributeError: + return str(get_engine().url).replace('%', '%%') + + +# add your model's MetaData object here +# for 'autogenerate' support +# from myapp import mymodel +# target_metadata = mymodel.Base.metadata +config.set_main_option('sqlalchemy.url', get_engine_url()) +target_db = current_app.extensions['migrate'].db + +# other values from the config, defined by the needs of env.py, +# can be acquired: +# my_important_option = config.get_main_option("my_important_option") +# ... etc. + + +def get_metadata(): + if hasattr(target_db, 'metadatas'): + return target_db.metadatas[None] + return target_db.metadata + + +def run_migrations_offline(): + """Run migrations in 'offline' mode. + + This configures the context with just a URL + and not an Engine, though an Engine is acceptable + here as well. By skipping the Engine creation + we don't even need a DBAPI to be available. + + Calls to context.execute() here emit the given string to the + script output. + + """ + url = config.get_main_option("sqlalchemy.url") + context.configure( + url=url, target_metadata=get_metadata(), literal_binds=True + ) + + with context.begin_transaction(): + context.run_migrations() + + +def run_migrations_online(): + """Run migrations in 'online' mode. + + In this scenario we need to create an Engine + and associate a connection with the context. + + """ + + # this callback is used to prevent an auto-migration from being generated + # when there are no changes to the schema + # reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html + def process_revision_directives(context, revision, directives): + if getattr(config.cmd_opts, 'autogenerate', False): + script = directives[0] + if script.upgrade_ops.is_empty(): + directives[:] = [] + logger.info('No changes in schema detected.') + + conf_args = current_app.extensions['migrate'].configure_args + if conf_args.get("process_revision_directives") is None: + conf_args["process_revision_directives"] = process_revision_directives + + connectable = get_engine() + + with connectable.connect() as connection: + context.configure( + connection=connection, + target_metadata=get_metadata(), + **conf_args + ) + + with context.begin_transaction(): + context.run_migrations() + + +if context.is_offline_mode(): + run_migrations_offline() +else: + run_migrations_online() diff --git a/flask_crud/migrations/script.py.mako b/flask_crud/migrations/script.py.mako new file mode 100644 index 0000000..2c01563 --- /dev/null +++ b/flask_crud/migrations/script.py.mako @@ -0,0 +1,24 @@ +"""${message} + +Revision ID: ${up_revision} +Revises: ${down_revision | comma,n} +Create Date: ${create_date} + +""" +from alembic import op +import sqlalchemy as sa +${imports if imports else ""} + +# revision identifiers, used by Alembic. +revision = ${repr(up_revision)} +down_revision = ${repr(down_revision)} +branch_labels = ${repr(branch_labels)} +depends_on = ${repr(depends_on)} + + +def upgrade(): + ${upgrades if upgrades else "pass"} + + +def downgrade(): + ${downgrades if downgrades else "pass"} diff --git a/flask_crud/migrations/versions/8eb4774e3960_initial_migration.py b/flask_crud/migrations/versions/8eb4774e3960_initial_migration.py new file mode 100644 index 0000000..39d456e --- /dev/null +++ b/flask_crud/migrations/versions/8eb4774e3960_initial_migration.py @@ -0,0 +1,46 @@ +"""Initial migration. + +Revision ID: 8eb4774e3960 +Revises: aa6e7ede1321 +Create Date: 2024-06-10 15:30:29.774459 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '8eb4774e3960' +down_revision = 'aa6e7ede1321' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('carburante', + sa.Column('identificador', sa.Integer(), nullable=False), + sa.Column('fecha', sa.Date(), nullable=True), + sa.Column('vehiculo', sa.String(length=20), nullable=True), + sa.Column('kms', sa.Integer(), nullable=True), + sa.Column('litros', sa.DECIMAL(precision=10, scale=3), nullable=True), + sa.Column('descuento', sa.DECIMAL(precision=10, scale=2), nullable=True), + sa.Column('precioxlitro', sa.DECIMAL(precision=10, scale=3), nullable=True), + sa.Column('importe', sa.DECIMAL(precision=10, scale=2), nullable=True), + sa.PrimaryKeyConstraint('identificador') + ) + op.create_table('vehiculos', + sa.Column('identificador', sa.Integer(), nullable=False), + sa.Column('marca', sa.String(length=20), nullable=True), + sa.Column('modelo', sa.String(length=20), nullable=True), + sa.Column('matricula', sa.String(length=20), nullable=True), + sa.PrimaryKeyConstraint('identificador') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('vehiculos') + op.drop_table('carburante') + # ### end Alembic commands ### diff --git a/flask_crud/migrations/versions/9f932e36f8fb_initial_migration.py b/flask_crud/migrations/versions/9f932e36f8fb_initial_migration.py new file mode 100644 index 0000000..a8f0b26 --- /dev/null +++ b/flask_crud/migrations/versions/9f932e36f8fb_initial_migration.py @@ -0,0 +1,34 @@ +"""Initial migration. + +Revision ID: 9f932e36f8fb +Revises: +Create Date: 2024-06-10 14:54:57.602942 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '9f932e36f8fb' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('student', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=100), nullable=False), + sa.Column('age', sa.Integer(), nullable=False), + sa.Column('grade', sa.String(length=10), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('student') + # ### end Alembic commands ### diff --git a/flask_crud/migrations/versions/aa6e7ede1321_initial_migration.py b/flask_crud/migrations/versions/aa6e7ede1321_initial_migration.py new file mode 100644 index 0000000..543ce54 --- /dev/null +++ b/flask_crud/migrations/versions/aa6e7ede1321_initial_migration.py @@ -0,0 +1,35 @@ +"""Initial migration. + +Revision ID: aa6e7ede1321 +Revises: 9f932e36f8fb +Create Date: 2024-06-10 15:16:49.313757 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'aa6e7ede1321' +down_revision = '9f932e36f8fb' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('user', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('email', sa.String(length=100), nullable=True), + sa.Column('password', sa.String(length=100), nullable=True), + sa.Column('name', sa.String(length=1000), nullable=True), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('email') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('user') + # ### end Alembic commands ### diff --git a/flask_crud/models.py b/flask_crud/models.py new file mode 100644 index 0000000..6e5839f --- /dev/null +++ b/flask_crud/models.py @@ -0,0 +1,35 @@ +from flask_sqlalchemy import SQLAlchemy +from flask_login import UserMixin + +db = SQLAlchemy() + +class Student(db.Model): + id = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String(100), nullable=False) + age = db.Column(db.Integer, nullable=False) + grade = db.Column(db.String(10), nullable=False) + + def __repr__(self): + return f'' + +class User(UserMixin, db.Model): + id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy + email = db.Column(db.String(100), unique=True) + password = db.Column(db.String(100)) + name = db.Column(db.String(1000)) + +class Carburante(db.Model): + identificador = db.Column(db.Integer, primary_key=True) + fecha = db.Column(db.Date()) + vehiculo = db.Column(db.String(20)) + kms = db.Column(db.Integer) + litros = db.Column(db.DECIMAL(10,3)) + descuento = db.Column(db.DECIMAL(10,2)) + precioxlitro = db.Column(db.DECIMAL(10,3)) + importe = db.Column(db.DECIMAL(10,2)) + +class Vehiculos(db.Model): + identificador = db.Column(db.Integer, primary_key=True) + marca = db.Column(db.String(20)) + modelo = db.Column(db.String(20)) + matricula = db.Column(db.String(20)) diff --git a/flask_crud/repostajes.sql b/flask_crud/repostajes.sql new file mode 100644 index 0000000..2105132 --- /dev/null +++ b/flask_crud/repostajes.sql @@ -0,0 +1,88 @@ +INSERT INTO `carburante` VALUES (1,'2021-12-14','1018KPD',52731,0.000,0.00,0.000,0.00); +INSERT INTO `carburante` VALUES (2,'2021-12-23','1018KPD',53162,52.800,0.00,1.280,67.32); +INSERT INTO `carburante` VALUES (3,'2021-12-31','1018KPD',54122,49.990,0.00,1.280,63.74); +INSERT INTO `carburante` VALUES (4,'2022-01-22','1018KPD',54946,49.140,0.00,1.270,62.65); +INSERT INTO `carburante` VALUES (5,'2022-02-09','1018KPD',55908,49.240,0.00,1.320,65.24); +INSERT INTO `carburante` VALUES (6,'2022-03-03','1018KPD',56909,48.610,0.00,1.380,67.03); +INSERT INTO `carburante` VALUES (7,'2022-03-18','1018KPD',57542,30.060,0.00,1.750,52.54); +INSERT INTO `carburante` VALUES (8,'2022-04-10','1018KPD',58497,46.630,0.00,1.500,69.98); +INSERT INTO `carburante` VALUES (9,'2022-05-12','1018KPD',59447,47.140,0.00,1.530,72.11); +INSERT INTO `carburante` VALUES (10,'2022-05-19','1018KPD',60414,48.570,0.00,1.640,79.81); +INSERT INTO `carburante` VALUES (11,'2022-06-09','1018KPD',61147,36.200,0.00,1.720,62.12); +INSERT INTO `carburante` VALUES (12,'2022-06-25','1018KPD',62116,49.170,0.00,1.840,90.29); +INSERT INTO `carburante` VALUES (16,'2022-09-14','1018KPD',66359,53.240,0.00,1.590,84.83); +INSERT INTO `carburante` VALUES (17,'2022-09-23','1018KPD',67107,37.260,0.00,1.490,55.48); +INSERT INTO `carburante` VALUES (19,'2023-01-24','1018KPD',71790,43.040,2.12,1.590,70.54); +INSERT INTO `carburante` VALUES (21,'2022-12-03','1018KPD',70061,46.380,2.04,1.420,68.13); +INSERT INTO `carburante` VALUES (22,'2022-12-26','1018KPD',70919,44.580,1.85,1.340,61.68); +INSERT INTO `carburante` VALUES (23,'2023-03-05','1018KPD',73711,47.850,0.00,1.490,71.20); +INSERT INTO `carburante` VALUES (24,'2023-03-25','1018KPD',74749,49.840,0.00,1.450,72.17); +INSERT INTO `carburante` VALUES (25,'2023-02-19','1018KPD',72763,49.380,2.34,1.530,77.97); +INSERT INTO `carburante` VALUES (27,'2023-05-06','1018KPD',76434,32.280,0.00,1.370,44.09); +INSERT INTO `carburante` VALUES (28,'2023-05-22','1018KPD',77366,45.040,0.00,1.300,58.46); +INSERT INTO `carburante` VALUES (45,'2022-07-09','1018KPD',63129,47.030,0.00,1.690,79.38); +INSERT INTO `carburante` VALUES (46,'2022-08-12','1018KPD',64088,43.730,0.00,1.500,65.55); +INSERT INTO `carburante` VALUES (47,'2022-08-22','1018KPD',65185,52.780,0.00,1.490,78.80); +INSERT INTO `carburante` VALUES (50,'2022-10-12','1018KPD',68204,52.040,2.51,1.560,83.73); +INSERT INTO `carburante` VALUES (51,'2022-11-11','1018KPD',69158,45.280,2.37,1.690,78.91); +INSERT INTO `carburante` VALUES (61,'2023-06-10','1018KPD',78170,41.090,0.00,1.320,54.16); +INSERT INTO `carburante` VALUES (62,'2023-06-19','1018KPD',79038,40.780,1.95,1.430,60.11); +INSERT INTO `carburante` VALUES (151,'2022-06-28','7630LYR',219,9.880,0.00,1.920,18.96); +INSERT INTO `carburante` VALUES (152,'2022-06-28','7630LYR',236,27.360,0.00,1.880,51.33); +INSERT INTO `carburante` VALUES (153,'2022-07-14','7630LYR',904,32.240,0.00,1.720,55.58); +INSERT INTO `carburante` VALUES (154,'2022-07-26','7630LYR',1433,30.490,0.00,1.590,48.43); +INSERT INTO `carburante` VALUES (155,'2022-08-21','7630LYR',2030,32.920,0.00,1.420,46.72); +INSERT INTO `carburante` VALUES (156,'2022-09-26','7630LYR',2627,23.920,0.00,1.390,33.16); +INSERT INTO `carburante` VALUES (157,'2022-10-18','7630LYR',3169,22.970,0.00,1.430,32.74); +INSERT INTO `carburante` VALUES (158,'2022-11-09','7630LYR',3791,29.600,0.00,1.410,41.88); +INSERT INTO `carburante` VALUES (159,'2022-11-27','7630LYR',4363,28.800,1.20,1.350,38.80); +INSERT INTO `carburante` VALUES (160,'2022-12-22','7630LYR',4851,26.740,1.06,1.280,34.18); +INSERT INTO `carburante` VALUES (161,'2023-01-12','7630LYR',5291,23.520,1.09,1.500,35.34); +INSERT INTO `carburante` VALUES (162,'2023-02-01','7630LYR',5702,27.360,1.28,1.520,41.52); +INSERT INTO `carburante` VALUES (163,'2023-02-20','7630LYR',6141,24.090,1.13,1.520,36.67); +INSERT INTO `carburante` VALUES (164,'2023-03-15','7630LYR',6631,25.520,1.21,1.530,38.96); +INSERT INTO `carburante` VALUES (165,'2023-04-17','7630LYR',7325,29.400,1.47,1.620,47.62); +INSERT INTO `carburante` VALUES (166,'2023-05-28','7630LYR',8413,24.160,1.17,1.560,37.70); +INSERT INTO `carburante` VALUES (167,'2023-06-25','7630LYR',8956,26.380,1.30,1.590,41.94); +INSERT INTO `carburante` VALUES (168,'2023-07-10','7630LYR',9471,29.040,1.35,1.497,43.49); +INSERT INTO `carburante` VALUES (176,'2023-07-14','1018KPD',79875,40.560,1.74,1.407,56.26); +INSERT INTO `carburante` VALUES (177,'2023-07-22','1018KPD',80806,46.290,1.95,1.371,63.05); +INSERT INTO `carburante` VALUES (178,'2023-07-25','7630LYR',10043,24.850,1.40,1.622,40.32); +INSERT INTO `carburante` VALUES (182,'2023-08-07','1018KPD',81695,44.390,0.00,1.439,63.88); +INSERT INTO `carburante` VALUES (201,'2023-08-09','7630LYR',10582,26.490,1.39,1.696,44.94); +INSERT INTO `carburante` VALUES (202,'2023-08-23','7630LYR',11050,24.050,1.22,1.638,39.40); +INSERT INTO `carburante` VALUES (203,'2023-08-27','1018KPD',82715,50.400,0.00,1.529,77.06); +INSERT INTO `carburante` VALUES (204,'2023-09-14','7630LYR',11508,21.440,1.14,1.726,37.00); +INSERT INTO `carburante` VALUES (205,'2023-09-19','1018KPD',83709,48.350,0.00,1.598,77.26); +INSERT INTO `carburante` VALUES (206,'2023-09-27','1018KPD',84171,23.010,0.00,1.558,35.85); +INSERT INTO `carburante` VALUES (207,'2023-10-10','1018KPD',85104,48.000,0.00,1.509,72.43); +INSERT INTO `carburante` VALUES (212,'2023-10-15','7630LYR',12006,25.090,1.25,1.609,40.37); +INSERT INTO `carburante` VALUES (213,'2023-10-27','1018KPD',86021,46.770,0.00,1.499,70.11); +INSERT INTO `carburante` VALUES (214,'2023-11-04','7630LYR',12427,25.640,1.17,1.474,37.78); +INSERT INTO `carburante` VALUES (215,'2023-11-11','1018KPD',86757,39.580,1.71,1.398,55.33); +INSERT INTO `carburante` VALUES (216,'2023-11-20','7630LYR',12933,26.160,0.00,1.529,40.00); +INSERT INTO `carburante` VALUES (217,'2023-11-23','1018KPD',87503,42.410,1.75,1.331,56.45); +INSERT INTO `carburante` VALUES (218,'2023-12-04','1018KPD',88256,41.190,0.00,1.399,57.62); +INSERT INTO `carburante` VALUES (219,'2023-12-17','1018KPD',88964,41.200,1.66,1.305,53.78); +INSERT INTO `carburante` VALUES (220,'2024-01-06','7630LYR',13414,30.720,1.34,1.411,43.36); +INSERT INTO `carburante` VALUES (222,'2024-01-07','1018KPD',89802,47.770,1.91,1.293,61.75); +INSERT INTO `carburante` VALUES (223,'2024-01-22','7630LYR',13903,25.080,0.00,1.479,37.09); +INSERT INTO `carburante` VALUES (224,'2024-01-27','1018KPD',90723,45.250,0.00,1.334,60.37); +INSERT INTO `carburante` VALUES (226,'2024-02-11','7630LYR',14365,28.450,0.00,1.454,41.37); +INSERT INTO `carburante` VALUES (233,'2024-02-12','1018KPD',91672,48.310,0.00,1.449,70.00); +INSERT INTO `carburante` VALUES (235,'2024-02-27','1018KPD',92489,41.990,0.00,1.379,57.91); +INSERT INTO `carburante` VALUES (236,'2024-02-29','7630LYR',14857,23.960,1.12,1.517,36.35); +INSERT INTO `carburante` VALUES (237,'2024-03-18','7630LYR',15287,13.000,0.00,1.538,20.00); +INSERT INTO `carburante` VALUES (239,'2024-03-19','1018KPD',93327,43.850,0.00,1.374,60.25); +INSERT INTO `carburante` VALUES (240,'2024-03-25','7630LYR',15537,19.240,0.00,1.559,30.00); +INSERT INTO `carburante` VALUES (241,'2024-04-06','7630LYR',15935,29.390,0.00,1.479,43.48); +INSERT INTO `carburante` VALUES (242,'2024-04-08','1018KPD',94167,41.110,0.00,1.374,56.49); +INSERT INTO `carburante` VALUES (243,'2024-04-22','7630LYR',16465,25.920,0.00,1.569,40.66); +INSERT INTO `carburante` VALUES (244,'2024-04-29','1018KPD',95042,43.630,0.00,1.445,63.03); +INSERT INTO `carburante` VALUES (247,'2024-05-13','7630LYR',16963,26.800,0.00,1.549,41.51); +INSERT INTO `carburante` VALUES (248,'2024-05-21','1018KPD',96585,28.330,0.00,1.399,39.63); +INSERT INTO `carburante` VALUES (249,'2024-05-27','1018KPD',97597,49.480,0.00,1.373,67.96); + + +INSERT INTO `vehiculos` VALUES (2,'Toyota','Corolla','7630LYR'); +INSERT INTO `vehiculos` VALUES (3,'BMW','318d','1018KPD'); diff --git a/flask_crud/templates/add_record.html b/flask_crud/templates/add_record.html new file mode 100644 index 0000000..28ee470 --- /dev/null +++ b/flask_crud/templates/add_record.html @@ -0,0 +1,27 @@ +{% extends "layout.html" %} +{% block content %} +

Add Student

+
+ {{ form.hidden_tag() }} +
+ {{ form.fecha.label }} {{ form.fecha(class_="form-control") }} +
+
+ {{ form.vehiculo.label }} {{ form.vehiculo(class_="form-control") }} +
+
+ {{ form.kms.label }} {{ form.kms(class_="form-control") }} +
+
+ {{ form.litros.label }} {{ form.litros(class_="form-control") }} +
+
+ {{ form.descuento.label }} {{ form.descuento(class_="form-control") }} +
+ +
+ {{ form.importe.label }} {{ form.importe(class_="form-control") }} +
+ {{ form.submit(class_="btn btn-primary") }} +
+{% endblock %} diff --git a/flask_crud/templates/base.html b/flask_crud/templates/base.html new file mode 100644 index 0000000..c0210e9 --- /dev/null +++ b/flask_crud/templates/base.html @@ -0,0 +1,59 @@ + + + + + + + + + + Flask Auth Example + + + + +
+ +
+ +
+ +
+
+ {% block content %} + {% endblock %} +
+
+
+ + + \ No newline at end of file diff --git a/flask_crud/templates/edit_record.html b/flask_crud/templates/edit_record.html new file mode 100644 index 0000000..6c4a170 --- /dev/null +++ b/flask_crud/templates/edit_record.html @@ -0,0 +1,17 @@ +{% extends "layout.html" %} +{% block content %} +

Edit Student

+
+ {{ form.hidden_tag() }} +
+ {{ form.name.label }} {{ form.name(class_="form-control") }} +
+
+ {{ form.age.label }} {{ form.age(class_="form-control") }} +
+
+ {{ form.grade.label }} {{ form.grade(class_="form-control") }} +
+ {{ form.submit(class_="btn btn-primary") }} +
+{% endblock %} diff --git a/flask_crud/templates/index.html b/flask_crud/templates/index.html new file mode 100644 index 0000000..c2e4af9 --- /dev/null +++ b/flask_crud/templates/index.html @@ -0,0 +1,35 @@ +{% extends "layout.html" %} +{% block content %} +

Students List

+Add Student + + + + + + + + + + + + {% for repostajes in repostajess %} + + + + + + + + + + + + + {% endfor %} + +
IDNameAgeGradeActions
{{ repostajes.identificador }}{{ repostajes.fecha }}{{ repostajes.vehiculo }}{{ repostajes.kms }}{{ repostajes.litros }}{{ repostajes.descuento }}{{ repostajes.precioxlitro }}{{ repostajes.importe }} + Edit + Delete +
+{% endblock %} diff --git a/flask_crud/templates/layout.html b/flask_crud/templates/layout.html new file mode 100644 index 0000000..a030fe1 --- /dev/null +++ b/flask_crud/templates/layout.html @@ -0,0 +1,12 @@ + + + + Student CRUD + + + +
+ {% block content %}{% endblock %} +
+ + diff --git a/flask_crud/templates/login.html b/flask_crud/templates/login.html new file mode 100644 index 0000000..898e45a --- /dev/null +++ b/flask_crud/templates/login.html @@ -0,0 +1,42 @@ + + +{% extends "base.html" %} + +{% block content %} +
+

Login

+
+ {% with messages = get_flashed_messages() %} + {% if messages %} +
+ {{ messages[0] }} +
+ {% endif %} + {% endwith %} +
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+ + +
+ +
+
+{% endblock %} \ No newline at end of file diff --git a/flask_crud/templates/signup.html b/flask_crud/templates/signup.html new file mode 100644 index 0000000..ce68a11 --- /dev/null +++ b/flask_crud/templates/signup.html @@ -0,0 +1,39 @@ + + +{% extends "base.html" %} + +{% block content %} +
+

Sign Up

+
+ {% with messages = get_flashed_messages() %} + {% if messages %} +
+ {{ messages[0] }}. Go to login page. +
+ {% endif %} + {% endwith %} +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+
+{% endblock %} \ No newline at end of file