diff --git a/flask_crud/app.py b/RepostajesPy/app.py similarity index 100% rename from flask_crud/app.py rename to RepostajesPy/app.py diff --git a/flask_crud/auth.py b/RepostajesPy/auth.py similarity index 100% rename from flask_crud/auth.py rename to RepostajesPy/auth.py diff --git a/flask_crud/forms.py b/RepostajesPy/forms.py similarity index 100% rename from flask_crud/forms.py rename to RepostajesPy/forms.py diff --git a/flask_crud/initdb.sh b/RepostajesPy/initdb.sh similarity index 100% rename from flask_crud/initdb.sh rename to RepostajesPy/initdb.sh diff --git a/flask_crud/instance/students.db b/RepostajesPy/instance/students.db similarity index 100% rename from flask_crud/instance/students.db rename to RepostajesPy/instance/students.db diff --git a/flask_crud/migrations/README b/RepostajesPy/migrations/README similarity index 100% rename from flask_crud/migrations/README rename to RepostajesPy/migrations/README diff --git a/flask_crud/migrations/alembic.ini b/RepostajesPy/migrations/alembic.ini similarity index 100% rename from flask_crud/migrations/alembic.ini rename to RepostajesPy/migrations/alembic.ini diff --git a/flask_crud/migrations/env.py b/RepostajesPy/migrations/env.py similarity index 100% rename from flask_crud/migrations/env.py rename to RepostajesPy/migrations/env.py diff --git a/flask_crud/migrations/script.py.mako b/RepostajesPy/migrations/script.py.mako similarity index 100% rename from flask_crud/migrations/script.py.mako rename to RepostajesPy/migrations/script.py.mako diff --git a/flask_crud/migrations/versions/8eb4774e3960_initial_migration.py b/RepostajesPy/migrations/versions/8eb4774e3960_initial_migration.py similarity index 100% rename from flask_crud/migrations/versions/8eb4774e3960_initial_migration.py rename to RepostajesPy/migrations/versions/8eb4774e3960_initial_migration.py diff --git a/flask_crud/migrations/versions/9f932e36f8fb_initial_migration.py b/RepostajesPy/migrations/versions/9f932e36f8fb_initial_migration.py similarity index 100% rename from flask_crud/migrations/versions/9f932e36f8fb_initial_migration.py rename to RepostajesPy/migrations/versions/9f932e36f8fb_initial_migration.py diff --git a/flask_crud/migrations/versions/aa6e7ede1321_initial_migration.py b/RepostajesPy/migrations/versions/aa6e7ede1321_initial_migration.py similarity index 100% rename from flask_crud/migrations/versions/aa6e7ede1321_initial_migration.py rename to RepostajesPy/migrations/versions/aa6e7ede1321_initial_migration.py diff --git a/flask_crud/models.py b/RepostajesPy/models.py similarity index 100% rename from flask_crud/models.py rename to RepostajesPy/models.py diff --git a/RepostajesPy/project/__init__.py b/RepostajesPy/project/__init__.py deleted file mode 100644 index f3af90b..0000000 --- a/RepostajesPy/project/__init__.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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 deleted file mode 100644 index 8f714e3..0000000 --- a/RepostajesPy/project/auth.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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 deleted file mode 100644 index 3b278d4..0000000 --- a/RepostajesPy/project/main.py +++ /dev/null @@ -1,34 +0,0 @@ -# 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 deleted file mode 100644 index baaeb79..0000000 --- a/RepostajesPy/project/models.py +++ /dev/null @@ -1,28 +0,0 @@ -# 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 deleted file mode 100644 index 032260a..0000000 --- a/RepostajesPy/project/templates/base.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - 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 deleted file mode 100644 index af298cb..0000000 --- a/RepostajesPy/project/templates/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - -{% 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 deleted file mode 100644 index cf510e2..0000000 --- a/RepostajesPy/project/templates/listado.html +++ /dev/null @@ -1,12 +0,0 @@ - - -{% 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 deleted file mode 100644 index f78f4e7..0000000 --- a/RepostajesPy/project/templates/login.html +++ /dev/null @@ -1,38 +0,0 @@ - - -{% 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 deleted file mode 100644 index c2c49fd..0000000 --- a/RepostajesPy/project/templates/profile.html +++ /dev/null @@ -1,9 +0,0 @@ - - -{% extends "base.html" %} - -{% block content %} -

- Welcome, {{ name }}! -

-{% endblock %} \ No newline at end of file diff --git a/RepostajesPy/repostajes.sql b/RepostajesPy/repostajes.sql index d7ddc57..2105132 100644 --- a/RepostajesPy/repostajes.sql +++ b/RepostajesPy/repostajes.sql @@ -84,5 +84,5 @@ INSERT INTO `carburante` VALUES (248,'2024-05-21','1018KPD',96585,28.330,0.00,1. 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'); +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/RepostajesPy/templates/add_record.html similarity index 100% rename from flask_crud/templates/add_record.html rename to RepostajesPy/templates/add_record.html diff --git a/flask_crud/templates/base.html b/RepostajesPy/templates/base.html similarity index 100% rename from flask_crud/templates/base.html rename to RepostajesPy/templates/base.html diff --git a/flask_crud/templates/edit_record.html b/RepostajesPy/templates/edit_record.html similarity index 100% rename from flask_crud/templates/edit_record.html rename to RepostajesPy/templates/edit_record.html diff --git a/flask_crud/templates/index.html b/RepostajesPy/templates/index.html similarity index 100% rename from flask_crud/templates/index.html rename to RepostajesPy/templates/index.html diff --git a/flask_crud/templates/layout.html b/RepostajesPy/templates/layout.html similarity index 100% rename from flask_crud/templates/layout.html rename to RepostajesPy/templates/layout.html diff --git a/flask_crud/templates/login.html b/RepostajesPy/templates/login.html similarity index 100% rename from flask_crud/templates/login.html rename to RepostajesPy/templates/login.html diff --git a/RepostajesPy/project/templates/signup.html b/RepostajesPy/templates/signup.html similarity index 100% rename from RepostajesPy/project/templates/signup.html rename to RepostajesPy/templates/signup.html diff --git a/flask_crud/repostajes.sql b/flask_crud/repostajes.sql deleted file mode 100644 index 2105132..0000000 --- a/flask_crud/repostajes.sql +++ /dev/null @@ -1,88 +0,0 @@ -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/signup.html b/flask_crud/templates/signup.html deleted file mode 100644 index ce68a11..0000000 --- a/flask_crud/templates/signup.html +++ /dev/null @@ -1,39 +0,0 @@ - - -{% 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