From e721d12d8d2d105b28a55456477850db180df61e Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Tue, 2 Jul 2024 13:33:50 +0200 Subject: [PATCH] =?UTF-8?q?Con=20registro=20de=20usuario=20y=20login=20nec?= =?UTF-8?q?esario=20para=20a=C3=B1adir=20letras=20y=20=C3=A1lbumes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LyricsPy/K8S/lyrics-deployment.yaml | 2 +- LyricsPy/servicios/creaImagen.sh | 4 +-- LyricsPy/servicios/instance/songs.db | Bin 77824 -> 77824 bytes LyricsPy/servicios/lyrics/auth.py | 15 ++++---- LyricsPy/servicios/lyrics/models.py | 2 +- LyricsPy/servicios/lyrics/paginas.py | 9 ----- .../lyrics/templates/_navegacion.html | 5 ++- LyricsPy/servicios/lyrics/templates/base.html | 12 +------ .../servicios/lyrics/templates/login.html | 2 +- .../servicios/lyrics/templates/search.html | 32 ------------------ .../servicios/lyrics/templates/signup.html | 10 ++---- 11 files changed, 19 insertions(+), 74 deletions(-) delete mode 100644 LyricsPy/servicios/lyrics/templates/search.html diff --git a/LyricsPy/K8S/lyrics-deployment.yaml b/LyricsPy/K8S/lyrics-deployment.yaml index f1800b6..e39831f 100644 --- a/LyricsPy/K8S/lyrics-deployment.yaml +++ b/LyricsPy/K8S/lyrics-deployment.yaml @@ -36,7 +36,7 @@ spec: - --bind - 0.0.0.0:5000 - lyrics:create_app() - image: creylopez/lyrics:4.0 + image: creylopez/lyrics:5.0 name: lyrics ports: - containerPort: 5000 diff --git a/LyricsPy/servicios/creaImagen.sh b/LyricsPy/servicios/creaImagen.sh index 997af28..a50c2a2 100644 --- a/LyricsPy/servicios/creaImagen.sh +++ b/LyricsPy/servicios/creaImagen.sh @@ -1,3 +1,3 @@ -docker build --no-cache -t creylopez/lyrics:4.0 . -docker push creylopez/lyrics:4.0 +docker build --no-cache -t creylopez/lyrics:5.0 . +docker push creylopez/lyrics:5.0 diff --git a/LyricsPy/servicios/instance/songs.db b/LyricsPy/servicios/instance/songs.db index 669ec3f995006dd5f39d7582c6dfa3e5237978e7..dd49ec5b7cc54a6182d3934901f078a40730dfab 100644 GIT binary patch delta 185 zcmZp8z|!!5Wr8%L;Y1l{M#IL0tqF`v_}LiwyBPSpwhIa{Ht^S%FtRepH%2BGrB>$T z7o=7dBxR?h8Cex)BpR8TS(zDtfQrAXNv>I#S3rY}a#AW6 a0|Nsi|7Qk%#?K&kyyWNQVV38FI|2ayeKo=W delta 50 wcmZp8z|!!5Wr8%L!9*EnMuWzLtqF`v_?Z|4whJmSKH{G^L4u8o0SFL$0DyN5$N&HU diff --git a/LyricsPy/servicios/lyrics/auth.py b/LyricsPy/servicios/lyrics/auth.py index 8d45151..c586d5f 100644 --- a/LyricsPy/servicios/lyrics/auth.py +++ b/LyricsPy/servicios/lyrics/auth.py @@ -13,11 +13,11 @@ def login(): @bp.route('/login', methods=['POST']) def login_post(): - email = request.form.get('email') + username = request.form.get('username') password = request.form.get('password') remember = True if request.form.get('remember') else False - user = User.query.filter_by(email=email).first() + user = User.query.filter_by(username=username).first() # check if the user actually exists # take the user-supplied password, hash it, and compare it to the hashed password in the database @@ -28,7 +28,7 @@ def login_post(): # if the above check passes, then we know the user has the right credentials login_user(user, remember=remember) - return redirect(url_for('reservas.misreservas')) + return redirect(url_for('paginas.index')) @bp.route('/signup') def signup(): @@ -36,18 +36,17 @@ def signup(): @bp.route('/signup', methods=['POST']) def signup_post(): - email = request.form.get('email') - name = request.form.get('name') + username = request.form.get('username') 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 + user = User.query.filter_by(username=username).first() # if this returns a user, then the user 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('La dirección de correo ya existe') return redirect(url_for('auth.signup')) # create a new user with the form data. Hash the password so the plaintext version isn't saved. - new_user = User(email=email, name=name, password=generate_password_hash(password, method='pbkdf2:sha256')) + new_user = User(username=username, password=generate_password_hash(password, method='pbkdf2:sha256')) # add the new user to the database db.session.add(new_user) @@ -59,4 +58,4 @@ def signup_post(): @login_required def logout(): logout_user() - return redirect(url_for('auth.index')) + return redirect(url_for('paginas.index')) diff --git a/LyricsPy/servicios/lyrics/models.py b/LyricsPy/servicios/lyrics/models.py index ad139d5..5c87631 100644 --- a/LyricsPy/servicios/lyrics/models.py +++ b/LyricsPy/servicios/lyrics/models.py @@ -1,7 +1,7 @@ from flask_sqlalchemy import SQLAlchemy from flask_login import UserMixin -db = SQLAlchemy() +from . import db class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) diff --git a/LyricsPy/servicios/lyrics/paginas.py b/LyricsPy/servicios/lyrics/paginas.py index 5059070..db00d63 100644 --- a/LyricsPy/servicios/lyrics/paginas.py +++ b/LyricsPy/servicios/lyrics/paginas.py @@ -79,15 +79,6 @@ def album(album_id): songs = Song.query.filter_by(album_id=album_id).all() return render_template('album.html', album=album, songs=songs) -@bp.route('/search') -def search(): - query = request.args.get('query', '') - if query: - songs = Song.query.filter(Song.title.contains(query)).all() - else: - songs = [] - return render_template('search.html', query=query, songs=songs) - @bp.route('/uploads/') @login_required def uploaded_file(filename): diff --git a/LyricsPy/servicios/lyrics/templates/_navegacion.html b/LyricsPy/servicios/lyrics/templates/_navegacion.html index e32a2fd..607b282 100644 --- a/LyricsPy/servicios/lyrics/templates/_navegacion.html +++ b/LyricsPy/servicios/lyrics/templates/_navegacion.html @@ -23,13 +23,16 @@