diff --git a/ReyMotaAppsDj/K8S/Makefile.local b/ReyMotaAppsDj/K8S/Makefile.local index 7e294f4..fd70952 100644 --- a/ReyMotaAppsDj/K8S/Makefile.local +++ b/ReyMotaAppsDj/K8S/Makefile.local @@ -2,7 +2,7 @@ export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':') export REGISTRY=localhost:30500 #export REGISTRY=registry.reymota.es -export IMG_VERSION = 0.44 +export IMG_VERSION = 0.46 export IMG_NGINX_VERSION = 1.0 # limpia todo diff --git a/ReyMotaAppsDj/requirements.txt b/ReyMotaAppsDj/requirements.txt index 67be145..17e59e2 100644 --- a/ReyMotaAppsDj/requirements.txt +++ b/ReyMotaAppsDj/requirements.txt @@ -11,3 +11,4 @@ pyflakes==3.2.0 sqlparse==0.5.1 typing_extensions==4.12.2 django-calculation==1.0.0 +pandas==2.2.3 \ No newline at end of file diff --git a/ReyMotaAppsDj/reymota/lyrics/management/commands/importa_song.py b/ReyMotaAppsDj/reymota/lyrics/management/commands/importa_song.py index b9d40fe..0659fdd 100644 --- a/ReyMotaAppsDj/reymota/lyrics/management/commands/importa_song.py +++ b/ReyMotaAppsDj/reymota/lyrics/management/commands/importa_song.py @@ -3,6 +3,7 @@ from lyrics.models import Album, Artista, Song import csv import argparse from datetime import datetime +import pandas as pd class Command(BaseCommand): @@ -13,13 +14,13 @@ class Command(BaseCommand): def handle(self, *args, **options): fichero = options["fichero_csv"] - with open(fichero, 'r') as file: - reader = csv.DictReader(file) - for row in reader: - title = row['title'], - artist = row['artist'], - album = row['album'], - year = row['year'], - lyrics = row['lyrics'] - pista = row['pista'] - print(title, ",", artist, ",", album, ",", year, ",", pista) + contenido = pd.read_csv(fichero) + + for fila in contenido.iterrows(): + print(fila[1].title, ", ", fila[1].artist, ", ", fila[1].album) + + artista = Artista.objects.get(nombre=fila[1].artist) + album = Album.objects.get(pk=fila[1].album) + + cancion = Song(title=fila[1].title, artist=artista, album=album, pista=fila[1].pista, lyrics=fila[1].lyrics) + cancion.save() diff --git a/ReyMotaAppsDj/reymota/lyrics/views.py b/ReyMotaAppsDj/reymota/lyrics/views.py index 17bbd49..c604454 100644 --- a/ReyMotaAppsDj/reymota/lyrics/views.py +++ b/ReyMotaAppsDj/reymota/lyrics/views.py @@ -74,7 +74,9 @@ def lista_albumes(request): @login_required def detalle_album(request, album_id): album = get_object_or_404(Album, pk=album_id) - return render(request, 'lyrics/detalle_album.html', {'album': album}) + songs = Song.objects.filter(album_id=album_id) + + return render(request, 'lyrics/detalle_album.html', {'album': album, 'songs': songs}) @login_required diff --git a/ReyMotaAppsDj/reymota/templates/lyrics/detalle_album.html b/ReyMotaAppsDj/reymota/templates/lyrics/detalle_album.html index bffe273..e96c8b8 100644 --- a/ReyMotaAppsDj/reymota/templates/lyrics/detalle_album.html +++ b/ReyMotaAppsDj/reymota/templates/lyrics/detalle_album.html @@ -23,7 +23,7 @@

{{ album.name }}

- +