diff --git a/ReyMotaAppsDj/.dockerignore b/ReyMotaAppsDj/.dockerignore
index b6ce3ed..9e55a94 100644
--- a/ReyMotaAppsDj/.dockerignore
+++ b/ReyMotaAppsDj/.dockerignore
@@ -2,3 +2,4 @@ Dockerfile
Makefile
volcadossql/
venv/
+reymota/lyrics/management/
diff --git a/ReyMotaAppsDj/K8S/Makefile b/ReyMotaAppsDj/K8S/Makefile
index ec25ab1..e0296d4 100644
--- a/ReyMotaAppsDj/K8S/Makefile
+++ b/ReyMotaAppsDj/K8S/Makefile
@@ -1,7 +1,7 @@
export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':')
#export REGISTRY=registry.cube.local
export REGISTRY=registry.reymota.es
-export IMG_VERSION = 0.9
+export IMG_VERSION = 0.16
export IMG_NGINX_VERSION = 1.0
# limpia todo
diff --git a/ReyMotaAppsDj/reymota/lyrics/forms.py b/ReyMotaAppsDj/reymota/lyrics/forms.py
index 87ae947..64a25ea 100644
--- a/ReyMotaAppsDj/reymota/lyrics/forms.py
+++ b/ReyMotaAppsDj/reymota/lyrics/forms.py
@@ -19,8 +19,8 @@ class AlbumForm(forms.ModelForm):
model = Album
fields = ['name', 'artist', 'year', 'cover_image']
- year = forms.DateField(
- widget=forms.DateInput(attrs={'type': 'date', 'class': 'form-control'}))
+ # year = forms.DateField(
+ # widget=forms.DateInput(attrs={'type': 'date', 'class': 'form-control'}))
artist = forms.ModelChoiceField(
queryset=Artista.objects.all(),
diff --git a/ReyMotaAppsDj/reymota/lyrics/management/commands/__init__.py b/ReyMotaAppsDj/reymota/lyrics/management/commands/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/ReyMotaAppsDj/reymota/lyrics/management/commands/importa_album.py b/ReyMotaAppsDj/reymota/lyrics/management/commands/importa_album.py
new file mode 100644
index 0000000..1f22f8e
--- /dev/null
+++ b/ReyMotaAppsDj/reymota/lyrics/management/commands/importa_album.py
@@ -0,0 +1,23 @@
+from django.core.management.base import BaseCommand, CommandError
+from lyrics.models import Album, Artista, Song
+import csv
+import argparse
+from datetime import datetime
+
+
+class Command(BaseCommand):
+ help = "Importa la lista de letras"
+
+ def add_arguments(self, parser):
+ parser.add_argument("fichero_csv", type=str, help='Ruta al fichero csv')
+
+ def handle(self, *args, **options):
+ fichero = options["fichero_csv"]
+ with open(fichero, 'r') as file:
+ reader = csv.DictReader(file)
+ for row in reader:
+ name = row['name'],
+ artist = row['artist'],
+ year = row['year'],
+ cover_image = row['cover_image']
+ print(name, ",", artist, ",", year, ",", cover_image)
diff --git a/ReyMotaAppsDj/reymota/lyrics/management/commands/importa_artista.py b/ReyMotaAppsDj/reymota/lyrics/management/commands/importa_artista.py
new file mode 100644
index 0000000..1f22f8e
--- /dev/null
+++ b/ReyMotaAppsDj/reymota/lyrics/management/commands/importa_artista.py
@@ -0,0 +1,23 @@
+from django.core.management.base import BaseCommand, CommandError
+from lyrics.models import Album, Artista, Song
+import csv
+import argparse
+from datetime import datetime
+
+
+class Command(BaseCommand):
+ help = "Importa la lista de letras"
+
+ def add_arguments(self, parser):
+ parser.add_argument("fichero_csv", type=str, help='Ruta al fichero csv')
+
+ def handle(self, *args, **options):
+ fichero = options["fichero_csv"]
+ with open(fichero, 'r') as file:
+ reader = csv.DictReader(file)
+ for row in reader:
+ name = row['name'],
+ artist = row['artist'],
+ year = row['year'],
+ cover_image = row['cover_image']
+ print(name, ",", artist, ",", year, ",", cover_image)
diff --git a/ReyMotaAppsDj/reymota/lyrics/management/commands/importa_song.py b/ReyMotaAppsDj/reymota/lyrics/management/commands/importa_song.py
new file mode 100644
index 0000000..0bc0456
--- /dev/null
+++ b/ReyMotaAppsDj/reymota/lyrics/management/commands/importa_song.py
@@ -0,0 +1,25 @@
+from django.core.management.base import BaseCommand, CommandError
+from lyrics.models import Album, Artista, Song
+import csv
+import argparse
+from datetime import datetime
+
+
+class Command(BaseCommand):
+ help = "Importa la lista de letras"
+
+ def add_arguments(self, parser):
+ parser.add_argument("fichero_csv", type=str, help='Ruta al fichero csv')
+
+ 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)
diff --git a/ReyMotaAppsDj/reymota/lyrics/models.py b/ReyMotaAppsDj/reymota/lyrics/models.py
index 28536af..ae26914 100644
--- a/ReyMotaAppsDj/reymota/lyrics/models.py
+++ b/ReyMotaAppsDj/reymota/lyrics/models.py
@@ -23,7 +23,7 @@ class Artista(models.Model):
class Album(models.Model):
name = models.CharField(max_length=200)
artist = models.ForeignKey(Artista, on_delete=models.CASCADE)
- year = models.PositiveBigIntegerField(default=current_year(), validators=[MinValueValidator(1984), max_value_current_year])
+ year = models.PositiveBigIntegerField(default=current_year(), validators=[MinValueValidator(1945), max_value_current_year])
cover_image = models.ImageField(upload_to='cover_image/', blank=True, null=True) # Nuevo campo
def __str__(self):
diff --git a/ReyMotaAppsDj/reymota/lyrics/views.py b/ReyMotaAppsDj/reymota/lyrics/views.py
index dde48db..63fb667 100644
--- a/ReyMotaAppsDj/reymota/lyrics/views.py
+++ b/ReyMotaAppsDj/reymota/lyrics/views.py
@@ -86,37 +86,7 @@ def nuevo_album(request):
if request.method == 'POST':
form = AlbumForm(request.POST, request.FILES)
if form.is_valid():
- instancia = form.save(commit=False)
-
- aplica_descuento = form.cleaned_data['aplica_descuento']
-
- if aplica_descuento:
- instancia.descuento = float(instancia.importe) * 0.03
- else:
- instancia.descuento = 0.0
-
- instancia.importe = float(instancia.importe) - instancia.descuento
-
- if instancia.litros > 0:
- instancia.precioxlitro = round(instancia.importe / float(instancia.litros), 2)
- else:
- instancia.precioxlitro = 0
-
- # lee todos los albumes del vehículo
- # albumes = Albums.query.filter_by(artista_id=artista_id).all()
-
- if Album.objects.filter(artista_id=instancia.artista):
- albumes = Album.objects.filter(artista_id=instancia.artista).order_by('-fecha')[0]
-
- instancia.kmsrecorridos = instancia.kms - albumes.kms
-
- if instancia.kmsrecorridos > 0:
- instancia.consumo = round(instancia.litros * 100 / instancia.kmsrecorridos, 2)
- else:
- instancia.kmsrecorridos = 0
- instancia.consumo = 0
-
- instancia.save()
+ form.save()
return redirect('lyrics:lista_albumes')
else:
diff --git a/ReyMotaAppsDj/reymota/templates/lyrics/lista_albumes.html b/ReyMotaAppsDj/reymota/templates/lyrics/lista_albumes.html
index 14a5125..2e8ead3 100644
--- a/ReyMotaAppsDj/reymota/templates/lyrics/lista_albumes.html
+++ b/ReyMotaAppsDj/reymota/templates/lyrics/lista_albumes.html
@@ -7,56 +7,63 @@
{% endblock menuapp %}
{% block content %}
-
-
-
+
+
+
-
-
-
-
-
- | Fecha |
- Vehículo |
- Kilómetros |
- Litros |
- Importe |
- Descuento |
- Precio por litro |
- Kms recorridos |
- Consumo/100 kms |
-
-
- {% for repostaje in repostajes %}
+
+
+
+
+
+
+
+
+
-
-
- | {{ repostaje.fecha }} |
- {{ repostaje.vehiculo.matricula }} |
- {{ repostaje.kms }} |
- {{ repostaje.litros }} |
- {{ repostaje.importe }} € |
- {{ repostaje.descuento }} € |
- {{ repostaje.precioxlitro }} € |
- {{ repostaje.kmsrecorridos }} |
- {{ repostaje.consumo }} |
-
-
- {% endfor %}
-
-
-
+
Cover |
+
Nombre |
+
Artista |
+
Año |
+
+
+
+
+ {% for album in albumes %}
+
+
+ {% if album.cover_image %}
+
+ {% else %}
+ Sin imágen
+ {% endif %}
+ |
+ {{ album.name }} |
+ {{ album.artist }} |
+ {{ album.year }} |
+
+ {% endfor %}
+
+
+
+
+
+
+
+
{% endblock %}