Browse Source

Cambios para editar album y canción

politica
Celestino Rey 1 year ago
parent
commit
188ea44f62
11 changed files with 145 additions and 7 deletions
  1. +1
    -1
      LyricsPy/K8S/Makefile
  2. +1
    -0
      LyricsPy/servicios/Dockerfile
  3. +1
    -0
      LyricsPy/servicios/env.produccion
  4. +5
    -1
      LyricsPy/servicios/lanza.sh
  5. +1
    -1
      LyricsPy/servicios/lyrics/__init__.py
  6. +40
    -0
      LyricsPy/servicios/lyrics/paginas.py
  7. +6
    -4
      LyricsPy/servicios/lyrics/templates/albumescard.html
  8. +39
    -0
      LyricsPy/servicios/lyrics/templates/edit_album.html
  9. +46
    -0
      LyricsPy/servicios/lyrics/templates/edit_song.html
  10. +4
    -0
      LyricsPy/servicios/lyrics/templates/song.html
  11. +1
    -0
      LyricsPy/servicios/requirements.txt

+ 1
- 1
LyricsPy/K8S/Makefile View File

@ -1,4 +1,4 @@
export IMG_VERSION = 7.1
export IMG_VERSION = 7.2
imagen: imagen:
cd ../servicios; make cd ../servicios; make


+ 1
- 0
LyricsPy/servicios/Dockerfile View File

@ -15,6 +15,7 @@ COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt RUN pip3 install -r requirements.txt
COPY . . COPY . .
COPY env.produccion .env
# run entrypoint.sh # run entrypoint.sh
ENTRYPOINT ["/lyrics/entrypoint.sh"] ENTRYPOINT ["/lyrics/entrypoint.sh"]

+ 1
- 0
LyricsPy/servicios/env.produccion View File

@ -0,0 +1 @@
ENVIRONMENT="Producción"

+ 5
- 1
LyricsPy/servicios/lanza.sh View File

@ -1 +1,5 @@
python -m flask --app lyrics run
#python -m flask --app lyrics run
export FLASK_DEBUG=1
export FLASK_APP=lyrics
flask run

+ 1
- 1
LyricsPy/servicios/lyrics/__init__.py View File

@ -46,7 +46,7 @@ def create_app():
print(f"Current Environment: {os.getenv('ENVIRONMENT')}") print(f"Current Environment: {os.getenv('ENVIRONMENT')}")
print(f"Using Database: {app.config.get('DATABASE')}")
print(f"Using Database: {app.config.get('SQLALCHEMY_DATABASE_URI')}")
print(f"Directorio de uploads: {app.config.get('UPLOAD_FOLDER')}") print(f"Directorio de uploads: {app.config.get('UPLOAD_FOLDER')}")
print(f"instance: {app.instance_path}") print(f"instance: {app.instance_path}")


+ 40
- 0
LyricsPy/servicios/lyrics/paginas.py View File

@ -65,6 +65,25 @@ def add_song():
albums = Album.query.all() albums = Album.query.all()
return render_template('add_song.html', albums=albums) return render_template('add_song.html', albums=albums)
@bp.route('/edit_song/<int:song_id>', methods=['GET', 'POST'])
@login_required
def edit_song(song_id):
song = Song.query.get_or_404(song_id)
albums = Album.query.all()
if request.method == 'POST':
song.title = request.form['title']
song.author = request.form['author']
song.order = request.form['order']
song.album_id = request.form['album_id']
song.lyrics = request.form['lyrics']
db.session.commit()
return redirect(url_for('song', song_id=song.id))
albums = Album.query.all()
return render_template('edit_song.html', song=song, albums=albums)
@bp.route('/add_song2album/<int:album_id>', methods=['GET', 'POST']) @bp.route('/add_song2album/<int:album_id>', methods=['GET', 'POST'])
@login_required @login_required
def add_song2album(album_id): def add_song2album(album_id):
@ -127,6 +146,27 @@ def add_album():
return render_template('add_album.html') return render_template('add_album.html')
@bp.route('/edit_album/<int:album_id>', methods=['GET', 'POST'])
@login_required
def edit_album(album_id):
album = Album.query.get_or_404(album_id)
if request.method == 'POST':
album.name = request.form['name']
album.artist = request.form['artist']
album.year = request.form['year']
if 'cover_image' in request.files:
cover_image = request.files['cover_image']
if cover_image.filename != '':
image_filename = secure_filename(cover_image.filename)
cover_image.save(os.path.join(bp.config['UPLOAD_FOLDER'], image_filename))
album.cover_image = image_filename
db.session.commit()
return redirect(url_for('album', album_id=album.id))
return render_template('edit_album.html', album=album)
@bp.route('/album/<int:album_id>') @bp.route('/album/<int:album_id>')
def album(album_id): def album(album_id):
album = Album.query.get_or_404(album_id) album = Album.query.get_or_404(album_id)


+ 6
- 4
LyricsPy/servicios/lyrics/templates/albumescard.html View File

@ -55,13 +55,14 @@
</svg> </svg>
</div><!--//dropdown-toggle--> </div><!--//dropdown-toggle-->
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"><svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-eye me-2" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<li><a class="dropdown-item" href="{{ url_for('paginas.album', album_id=album.id) }}"><svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-eye me-2" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.134 13.134 0 0 0 1.66 2.043C4.12 11.332 5.88 12.5 8 12.5c2.12 0 3.879-1.168 5.168-2.457A13.134 13.134 0 0 0 14.828 8a13.133 13.133 0 0 0-1.66-2.043C11.879 4.668 10.119 3.5 8 3.5c-2.12 0-3.879 1.168-5.168 2.457A13.133 13.133 0 0 0 1.172 8z"/> <path fill-rule="evenodd" d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.134 13.134 0 0 0 1.66 2.043C4.12 11.332 5.88 12.5 8 12.5c2.12 0 3.879-1.168 5.168-2.457A13.134 13.134 0 0 0 14.828 8a13.133 13.133 0 0 0-1.66-2.043C11.879 4.668 10.119 3.5 8 3.5c-2.12 0-3.879 1.168-5.168 2.457A13.133 13.133 0 0 0 1.172 8z"/>
<path fill-rule="evenodd" d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/> <path fill-rule="evenodd" d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/>
</svg>View</a></li>
<li><a class="dropdown-item" href="#"><svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-pencil me-2" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
</svg>Ver</a></li>
<li><a class="dropdown-item" href="{{ url_for('paginas.edit_album', album_id=album.id) }}"><svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-pencil me-2" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5L13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175l-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z"/> <path fill-rule="evenodd" d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5L13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175l-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z"/>
</svg>Edit</a></li>
</svg>Editar</a></li>
<!--
<li><a class="dropdown-item" href="#"><svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-download me-2" fill="currentColor" xmlns="http://www.w3.org/2000/svg"> <li><a class="dropdown-item" href="#"><svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-download me-2" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/> <path fill-rule="evenodd" d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/>
<path fill-rule="evenodd" d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"/> <path fill-rule="evenodd" d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"/>
@ -71,6 +72,7 @@
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/> <path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/>
<path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4L4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/> <path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4L4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/>
</svg>Delete</a></li> </svg>Delete</a></li>
-->
</ul> </ul>
</div><!--//dropdown--> </div><!--//dropdown-->
</div><!--//app-card-actions--> </div><!--//app-card-actions-->


+ 39
- 0
LyricsPy/servicios/lyrics/templates/edit_album.html View File

@ -0,0 +1,39 @@
{% extends 'base.html' %}
{% block content %}
<div class="column is-4 is-offset-4">
<h3>Editar Álbum</h3>
<div class="box">
<form method="POST" enctype="multipart/form-data" action="{{ url_for('paginas.edit_album', album_id=album.id) }}">
<div class="text mb-3">
<label for="name">Nombre:</label>
<input class="form-control" type="text" id="name" name="name" value="{{ album.name }}" required>
</div>
<div class="text mb-3">
<label for="artist">Artista:</label>
<input class="form-control" type="text" id="artist" name="artist" value="{{ album.artist }}" required>
</div>
<div class="text mb-3">
<label for="year">Año:</label>
<input class="form-control" type="number" id="year" name="year" value="{{ album.year }}" required>
</div>
<div class="text mb-3">
<label for="cover_image">Cover Image:</label>
<input class="form-control" type="file" id="cover_image" name="coverimage">
{% if album.cover_image %}
<img src="{{ url_for('paginas.uploaded_file', filename=album.cover_image) }}" alt="{{ album.name }}" style="width:100px;height:100px;"><br>
{% endif %}
</div>
<div class="text mb-3">
<button type="submit" class="btn app-btn-primary w-100 theme-btn mx-auto">Guardar cambios</button>
</div>
</form>
</div>
</div>
{% endblock %}

+ 46
- 0
LyricsPy/servicios/lyrics/templates/edit_song.html View File

@ -0,0 +1,46 @@
{% extends 'base.html' %}
{% block content %}
<div class="column is-4 is-offset-4">
<h3>Añadir nueva canción</h3>
<div class="box">
<form method="POST" action="{{ url_for('paginas.edit_song', song_id=song.id) }}">
<div class="text mb-3">
<label for="pista">Nº de pista:</label>
<input class="form-control" type="number" id="pista" name="pista" value="{{ song.pista }}" required>
</div>
<div class="text mb-3">
<label for="title">Título:</label>
<input class="form-control" type="text" id="title" name="title" value="{{ song.title }}" required>
</div>
<div class="text mb-3">
<label for="author">Autor:</label>
<input class="form-control" type="text" id="author" name="author" value="{{ song.author }}" required>
</div>
<div class="text mb-3">
<label for="album_id">Álbum:</label>
<select class="form-control" id="album_id" name="album_id" required>
{% for album in albums %}
<option value="{{ album.id }}" {% if song.album_id == album.id %}selected{% endif %}>{{ album.name }}</option>
<!--
<option value="{{ album.id }}" data-artist="{{ album.artist }}">{{ album.name }} by {{ album.artist }}</option>
-->
{% endfor %}
</select>
</div>
<div class="text mb-3">
<label for="lyrics">Letra:</label>
<textarea class="form-control" id="lyrics" name="lyrics" required>{{ song.lyrics }}</textarea>
</div>
<div class="text mb-3">
<button type="submit" class="btn app-btn-primary w-100 theme-btn mx-auto">Guardar cambios</button>
</div>
</form>
</div>
</div>
{% endblock %}

+ 4
- 0
LyricsPy/servicios/lyrics/templates/song.html View File

@ -24,6 +24,10 @@
</ul> </ul>
</div><!--//col--> </div><!--//col-->
<div class="col-12 col-lg-auto text-center text-lg-start">
<p><a href="{{ url_for('paginas.edit_song', song_id=song.id) }}">Editar</a></p>
</div>
</tr>
</div><!--//row--> </div><!--//row-->
</div><!--//app-card-header--> </div><!--//app-card-header-->
<div class="app-card-body p-4"> <div class="app-card-body p-4">


+ 1
- 0
LyricsPy/servicios/requirements.txt View File

@ -9,6 +9,7 @@ itsdangerous==2.2.0
Jinja2==3.1.4 Jinja2==3.1.4
MarkupSafe==2.1.5 MarkupSafe==2.1.5
packaging==24.1 packaging==24.1
python-dotenv==1.0.1
SQLAlchemy==2.0.31 SQLAlchemy==2.0.31
typing_extensions==4.12.2 typing_extensions==4.12.2
Werkzeug==3.0.3 Werkzeug==3.0.3

Loading…
Cancel
Save