Browse Source

Muevo de gogs a gitea

main
Celestino Rey 8 months ago
parent
commit
6559d96104
2342 changed files with 96 additions and 660 deletions
  1. +3
    -3
      Yamls/entreadores-service.yaml
  2. +1
    -1
      Yamls/env-prod-db-configmap.yaml
  3. +1
    -1
      Yamls/postgresql-deployment.yaml
  4. +1
    -1
      Yamls/postgresql-service.yaml
  5. +1
    -1
      Yamls/pvc-postgresql.yaml
  6. +4
    -10
      src/entrenadores/settings.py
  7. +0
    -9
      src/lyrics/admin.py
  8. +0
    -6
      src/lyrics/apps.py
  9. +0
    -41
      src/lyrics/forms.py
  10. +0
    -48
      src/lyrics/management/commands/importar_albumes.py
  11. +0
    -42
      src/lyrics/management/commands/importar_artistas.py
  12. +0
    -51
      src/lyrics/management/commands/importar_canciones.py
  13. +0
    -42
      src/lyrics/models.py
  14. +0
    -39
      src/lyrics/serializers.py
  15. +0
    -39
      src/lyrics/urls.py
  16. +0
    -251
      src/lyrics/views.py
  17. +0
    -0
      src/macrociclos/.gitignore
  18. +0
    -0
      src/macrociclos/__init__.py
  19. +0
    -0
      src/macrociclos/admin.py
  20. +0
    -0
      src/macrociclos/apps.py
  21. +0
    -0
      src/macrociclos/forms.py
  22. +0
    -0
      src/macrociclos/management/__init__.py
  23. +0
    -0
      src/macrociclos/management/commands/__init__.py
  24. +0
    -0
      src/macrociclos/management/commands/importar_repostajes.py
  25. +0
    -0
      src/macrociclos/management/commands/importar_vehiculos.py
  26. +34
    -0
      src/macrociclos/models.py
  27. +0
    -0
      src/macrociclos/serializers.py
  28. +0
    -0
      src/macrociclos/static/css/portal.css
  29. +0
    -0
      src/macrociclos/static/images/app-logo.svg
  30. +0
    -0
      src/macrociclos/static/images/background/background-1.jpg
  31. +0
    -0
      src/macrociclos/static/images/background/background-2.jpg
  32. +0
    -0
      src/macrociclos/static/images/background/background-3.jpg
  33. +0
    -0
      src/macrociclos/static/images/background/background-palmeras.jpg
  34. +0
    -0
      src/macrociclos/static/images/doc-thumb-1.jpg
  35. +0
    -0
      src/macrociclos/static/images/doc-thumb-2.jpg
  36. +0
    -0
      src/macrociclos/static/images/favicon.ico
  37. +0
    -0
      src/macrociclos/static/images/favicon.png
  38. +0
    -0
      src/macrociclos/static/images/portal-logo.svg
  39. +0
    -0
      src/macrociclos/static/images/profiles/profile-1.png
  40. +0
    -0
      src/macrociclos/static/images/profiles/profile-2.png
  41. +0
    -0
      src/macrociclos/static/images/profiles/profile-3.png
  42. +0
    -0
      src/macrociclos/static/images/profiles/profile-4.png
  43. +0
    -0
      src/macrociclos/static/images/profiles/profile-5.png
  44. +0
    -0
      src/macrociclos/static/images/profiles/profile-6.png
  45. +0
    -0
      src/macrociclos/static/images/reymota-logo.svg
  46. +0
    -0
      src/macrociclos/static/images/user.png
  47. +0
    -0
      src/macrociclos/static/images/users/user-1.jpg
  48. +0
    -0
      src/macrociclos/static/images/users/user-2.jpg
  49. +0
    -0
      src/macrociclos/static/images/users/user-3.jpg
  50. +0
    -0
      src/macrociclos/static/images/users/user-4.jpg
  51. +0
    -0
      src/macrociclos/static/images/users/user-5.jpg
  52. +0
    -0
      src/macrociclos/static/images/users/user-6.jpg
  53. +0
    -0
      src/macrociclos/static/images/users/user-7.jpg
  54. +0
    -0
      src/macrociclos/static/images/users/user-8.jpg
  55. +0
    -0
      src/macrociclos/static/images/users/user-9.jpg
  56. +0
    -0
      src/macrociclos/static/js/app.js
  57. +0
    -0
      src/macrociclos/static/js/charts-demo.js
  58. +0
    -0
      src/macrociclos/static/js/index-charts.js
  59. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.css
  60. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.css.map
  61. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.min.css
  62. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.min.css.map
  63. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.rtl.css
  64. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.rtl.css.map
  65. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.rtl.min.css
  66. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.rtl.min.css.map
  67. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.css
  68. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.css.map
  69. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.min.css
  70. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.min.css.map
  71. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.rtl.css
  72. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.rtl.css.map
  73. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.rtl.min.css
  74. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.rtl.min.css.map
  75. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.css
  76. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.css.map
  77. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.min.css
  78. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.min.css.map
  79. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.rtl.css
  80. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.rtl.css.map
  81. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.rtl.min.css
  82. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.rtl.min.css.map
  83. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap.css
  84. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap.css.map
  85. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap.min.css
  86. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap.min.css.map
  87. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap.rtl.css
  88. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap.rtl.css.map
  89. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap.rtl.min.css
  90. +0
    -0
      src/macrociclos/static/plugins/bootstrap/css/bootstrap.rtl.min.css.map
  91. +0
    -0
      src/macrociclos/static/plugins/bootstrap/js/bootstrap.bundle.js
  92. +0
    -0
      src/macrociclos/static/plugins/bootstrap/js/bootstrap.bundle.js.map
  93. +0
    -0
      src/macrociclos/static/plugins/bootstrap/js/bootstrap.bundle.min.js
  94. +0
    -0
      src/macrociclos/static/plugins/bootstrap/js/bootstrap.bundle.min.js.map
  95. +0
    -0
      src/macrociclos/static/plugins/bootstrap/js/bootstrap.esm.js
  96. +0
    -0
      src/macrociclos/static/plugins/bootstrap/js/bootstrap.esm.js.map
  97. +0
    -0
      src/macrociclos/static/plugins/bootstrap/js/bootstrap.esm.min.js
  98. +0
    -0
      src/macrociclos/static/plugins/bootstrap/js/bootstrap.esm.min.js.map
  99. +0
    -0
      src/macrociclos/static/plugins/bootstrap/js/bootstrap.js
  100. +0
    -0
      src/macrociclos/static/plugins/bootstrap/js/bootstrap.js.map

Yamls/reymota-service.yaml → Yamls/entreadores-service.yaml View File

@ -1,13 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: reymota
namespace: reymota
name: entrenadores
namespace: entrenadores
spec:
type: NodePort
ports:
- name: "8080"
port: 8080
nodePort: 30341
nodePort: 30344
targetPort: 8080

+ 1
- 1
Yamls/env-prod-db-configmap.yaml View File

@ -8,4 +8,4 @@ metadata:
labels:
io.kompose.service: db-env-prod-db
name: env-prod-db
namespace: trainersapp
namespace: entrenadores

+ 1
- 1
Yamls/postgresql-deployment.yaml View File

@ -7,7 +7,7 @@ metadata:
labels:
io.kompose.service: postgresql
name: postgresql
namespace: trainersapp
namespace: entrenadores
spec:
replicas: 1
selector:


+ 1
- 1
Yamls/postgresql-service.yaml View File

@ -7,7 +7,7 @@ metadata:
labels:
io.kompose.service: postgresql
name: postgresql
namespace: trainersapp
namespace: entrenadores
spec:
ports:
- name: "5432"


+ 1
- 1
Yamls/pvc-postgresql.yaml View File

@ -6,7 +6,7 @@ metadata:
labels:
template: postgresql-persistent-template
name: postgresql
namespace: reymota
namespace: entrenadores
spec:
accessModes:
- ReadWriteOnce


+ 4
- 10
src/entrenadores/settings.py View File

@ -42,9 +42,8 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'repostajes',
'reymotausers',
'lyrics',
'macrociclos',
'usuariosusers',
]
MIDDLEWARE = [
@ -145,7 +144,7 @@ LOGIN_URL = '/accounts/login/'
LOGIN_REDIRECT_URL = 'principal'
LOGOUT_REDIRECT_URL = 'principal'
AUTH_USER_MODEL = "reymotausers.ReyMotaUser"
AUTH_USER_MODEL = "usuariosusers.UsuariosUser"
MEDIA_ROOT = BASE_DIR / "mediafiles"
MEDIA_URL = '/media/'
@ -189,12 +188,7 @@ LOGGING = {
'level': 'DEBUG',
'propagate': True,
},
'repostajes': {
'handlers': ['console', 'file'],
'level': 'DEBUG',
'propagate': False,
},
'lyrics': {
'macrociclos': {
'handlers': ['console', 'file'],
'level': 'DEBUG',
'propagate': False,


+ 0
- 9
src/lyrics/admin.py View File

@ -1,9 +0,0 @@
from django.contrib import admin
# Register your models here.
from .models import Artista, Album, Song
admin.site.register(Artista)
admin.site.register(Album)
admin.site.register(Song)

+ 0
- 6
src/lyrics/apps.py View File

@ -1,6 +0,0 @@
from django.apps import AppConfig
class LyricsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'lyrics'

+ 0
- 41
src/lyrics/forms.py View File

@ -1,41 +0,0 @@
from django import forms
from .models import Artista, Album, Song
class ArtistaForm(forms.ModelForm):
class Meta:
model = Artista
fields = ['nombre', 'biografia', 'foto']
nombre = forms.CharField(
widget=forms.TextInput(attrs={'class': 'form-control'}))
biografia = forms.CharField(
widget=forms.TextInput(attrs={'class': 'form-control'}))
class AlbumForm(forms.ModelForm):
class Meta:
model = Album
fields = ['name', 'artist', 'year', 'cover_image']
# year = forms.DateField(
# widget=forms.DateInput(attrs={'type': 'date', 'class': 'form-control'}))
artist = forms.ModelChoiceField(
queryset=Artista.objects.all(),
widget=forms.Select(attrs={'class': 'form-control'}))
class SongForm(forms.ModelForm):
class Meta:
model = Song
fields = ['title', 'artist', 'album', 'year', 'lyrics']
artist = forms.ModelChoiceField(
queryset=Artista.objects.all(),
widget=forms.Select(attrs={'class': 'form-control'}))
album = forms.ModelChoiceField(
queryset=Album.objects.all(), # habría que seleccionar los álbumes del artista
widget=forms.Select(attrs={'class': 'form-control'}))

+ 0
- 48
src/lyrics/management/commands/importar_albumes.py View File

@ -1,48 +0,0 @@
import json
from django.core.management.base import BaseCommand
from lyrics.models import Album, Artista
class Command(BaseCommand):
help = "Importa albumes desde un archivo JSON"
def add_arguments(self, parser):
parser.add_argument('archivo_json', type=str, help="Ruta del archivo JSON")
def handle(self, *args, **kwargs):
archivo_json = kwargs['archivo_json']
try:
with open(archivo_json, 'r', encoding='utf-8') as file:
datos = json.load(file)
self.stdout.write(self.style.WARNING(f"\nSe encontraron {len(datos)} albumes en el archivo '{archivo_json}'."))
confirmar = input("¿Deseas continuar con la importación? (s/n): ").strip().lower()
if confirmar != 's':
self.stdout.write(self.style.ERROR("Importación cancelada."))
return
albumes_creados = 0
for album_data in datos:
try:
artista = Artista.objects.get(nombre=album_data["artista_nombre"])
creado = Album.objects.create(
artist=artista,
name=album_data['name'],
year=album_data['year'],
cover_image=album_data['cover_image'],
)
if creado:
albumes_creados += 1
except Artista.DoesNotExist:
self.stderr.write(self.style.ERROR(f"Artista '{album_data['artista_nombre']}' no encontrado."))
self.stdout.write(self.style.SUCCESS(f'Se importaron {albumes_creados} albumes correctamente.'))
except FileNotFoundError:
self.stderr.write(self.style.ERROR(f"El archivo {archivo_json} no se encontró."))
except json.JSONDecodeError:
self.stderr.write(self.style.ERROR("Error al leer el archivo JSON. Asegúrate de que el formato sea correcto."))

+ 0
- 42
src/lyrics/management/commands/importar_artistas.py View File

@ -1,42 +0,0 @@
import json
from django.core.management.base import BaseCommand
from lyrics.models import Artista
class Command(BaseCommand):
help = "Importa artistas desde un archivo JSON"
def add_arguments(self, parser):
parser.add_argument('archivo_json', type=str, help="Ruta del archivo JSON")
def handle(self, *args, **kwargs):
archivo_json = kwargs['archivo_json']
try:
with open(archivo_json, 'r', encoding='utf-8') as file:
datos = json.load(file)
self.stdout.write(self.style.WARNING(f"\nSe encontraron {len(datos)} artistas en el archivo '{archivo_json}'."))
confirmar = input("¿Deseas continuar con la importación? (s/n): ").strip().lower()
if confirmar != 's':
self.stdout.write(self.style.ERROR("Importación cancelada."))
return
artistas_creados = 0
for artista_data in datos:
creado = Artista.objects.create(
id=artista_data['id'],
nombre=artista_data['nombre'],
biografia=artista_data['biografia'],
foto=artista_data['foto']
)
if creado:
artistas_creados += 1
self.stdout.write(self.style.SUCCESS(f'Se importaron {artistas_creados} artistas correctamente.'))
except FileNotFoundError:
self.stderr.write(self.style.ERROR(f"El archivo {archivo_json} no se encontró."))
except json.JSONDecodeError:
self.stderr.write(self.style.ERROR("Error al leer el archivo JSON. Asegúrate de que el formato sea correcto."))

+ 0
- 51
src/lyrics/management/commands/importar_canciones.py View File

@ -1,51 +0,0 @@
import json
from django.core.management.base import BaseCommand
from lyrics.models import Song, Album, Artista
class Command(BaseCommand):
help = "Importa canciones desde un archivo JSON"
def add_arguments(self, parser):
parser.add_argument('archivo_json', type=str, help="Ruta del archivo JSON")
def handle(self, *args, **kwargs):
archivo_json = kwargs['archivo_json']
try:
with open(archivo_json, 'r', encoding='utf-8') as file:
datos = json.load(file)
self.stdout.write(self.style.WARNING(f"\nSe encontraron {len(datos)} canciones en el archivo '{archivo_json}'."))
confirmar = input("¿Deseas continuar con la importación? (s/n): ").strip().lower()
if confirmar != 's':
self.stdout.write(self.style.ERROR("Importación cancelada."))
return
canciones_creados = 0
for cancion_data in datos:
try:
album = Album.objects.get(name=cancion_data["album_nombre"])
artista = Artista.objects.get(nombre=cancion_data["artista_nombre"])
creado = Song.objects.create(
album=album,
artist=artista,
title=cancion_data['title'],
year=cancion_data['year'],
lyrics=cancion_data['lyrics'],
pista=cancion_data['pista'],
)
if creado:
canciones_creados += 1
except Album.DoesNotExist:
self.stderr.write(self.style.ERROR(f"Album '{cancion_data['album']}' no encontrado."))
self.stdout.write(self.style.SUCCESS(f'Se importaron {canciones_creados} canciones correctamente.'))
except FileNotFoundError:
self.stderr.write(self.style.ERROR(f"El archivo {archivo_json} no se encontró."))
except json.JSONDecodeError:
self.stderr.write(self.style.ERROR("Error al leer el archivo JSON. Asegúrate de que el formato sea correcto."))

+ 0
- 42
src/lyrics/models.py View File

@ -1,42 +0,0 @@
from django.db import models
import datetime
from django.core.validators import MaxValueValidator, MinValueValidator
def current_year():
return datetime.date.today().year
def max_value_current_year(value):
return MaxValueValidator(current_year())(value)
class Artista(models.Model):
nombre = models.CharField(max_length=200)
biografia = models.TextField(blank=True, null=True)
foto = models.ImageField(upload_to='artistas/', blank=True, null=True) # Nuevo campo
def __str__(self):
return self.nombre
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(1945), max_value_current_year])
cover_image = models.ImageField(upload_to='cover_image/', blank=True, null=True) # Nuevo campo
def __str__(self):
return self.name
class Song(models.Model):
title = models.CharField(max_length=200)
artist = models.ForeignKey(Artista, on_delete=models.CASCADE)
album = models.ForeignKey(Album, on_delete=models.CASCADE, related_name='song')
year = models.DecimalField(max_digits=4, decimal_places=0, blank=False, null=False)
lyrics = models.TextField()
pista = models.DecimalField(max_digits=5, decimal_places=0, blank=True, null=True)
def __str__(self):
return self.title

+ 0
- 39
src/lyrics/serializers.py View File

@ -1,39 +0,0 @@
import os
from rest_framework import serializers
from .models import Artista, Album, Song
class ArtistaSerializer(serializers.ModelSerializer):
class Meta:
model = Artista
fields = '__all__' # Incluir todos los campos del modelo
def to_representation(self, instance):
ret = super().to_representation(instance)
ret['foto'] = "artistas/" + os.path.basename(ret['foto'])
return ret
class AlbumSerializer(serializers.ModelSerializer):
artista_nombre = serializers.CharField(source='artist.nombre', read_only=True)
class Meta:
model = Album
fields = ['name', 'year', 'cover_image', 'artista_nombre']
def to_representation(self, instance):
ret = super().to_representation(instance)
ret['cover_image'] = "cover_image/" + os.path.basename(ret['cover_image'])
return ret
class CancionSerializer(serializers.ModelSerializer):
artista_nombre = serializers.CharField(source='artist.nombre', read_only=True)
album_nombre = serializers.CharField(source='album.name', read_only=True)
class Meta:
model = Song
fields = ['title', 'year', 'lyrics', 'pista', 'artista_nombre', 'album_nombre']

+ 0
- 39
src/lyrics/urls.py View File

@ -1,39 +0,0 @@
from django.urls import path
from . import views
from .views import api_lista_artistas, api_detalle_artista
from .views import api_lista_albumes, api_detalle_album
from .views import api_lista_canciones, api_detalle_cancion
app_name = 'lyrics'
urlpatterns = [
path('', views.principal, name='principal'),
path('artistas/', views.lista_artistas, name='lista_artistas'),
path('artistas/nuevo/', views.nuevo_artista, name='nuevo_artista'),
path('artistas/<int:artista_id>/', views.detalle_artista, name='detalle_artista'),
path('artistas/<int:artista_id>/editar/', views.editar_artista, name='editar_artista'),
path('artistas/<int:artista_id>/eliminar/', views.eliminar_artista, name='eliminar_artista'),
path('album/', views.lista_albumes, name='lista_albumes'),
path('album/nuevo/', views.nuevo_album, name='nuevo_album'),
path('album/<int:album_id>/', views.detalle_album, name='detalle_album'),
path('album/<int:album_id>/editar/', views.editar_album, name='editar_album'),
path('album/<int:album_id>/eliminar/', views.eliminar_album, name='eliminar_album'),
path('song/', views.lista_songs, name='lista_songs'),
path('song/nuevo/', views.nuevo_song, name='nuevo_song'),
path('song/<int:song_id>/', views.detalle_song, name='detalle_song'),
path('song/<int:song_id>/editar/', views.editar_song, name='editar_song'),
path('song/<int:song_id>/eliminar/', views.eliminar_song, name='eliminar_song'),
path('api/artistas/', api_lista_artistas, name='api_lista_artistas'),
path('api/artistas/<int:artista_id>/', api_detalle_artista, name='api_detalle_artista'),
path('api/albumes/', api_lista_albumes, name='api_lista_albumes'),
path('api/albumes/<int:album_id>/', api_detalle_album, name='api_detalle_album'),
path('api/canciones/', api_lista_canciones, name='api_lista_canciones'),
path('api/canciones/<int:cancion_id>/', api_detalle_cancion, name='api_detalle_cancion'),
]

+ 0
- 251
src/lyrics/views.py View File

@ -1,251 +0,0 @@
# Create your views here.
from django.shortcuts import render, get_object_or_404, redirect
from django.contrib.auth.decorators import login_required
from rest_framework.response import Response
from rest_framework.decorators import api_view
from .models import Artista, Album, Song
from .forms import ArtistaForm, AlbumForm, SongForm
from .serializers import ArtistaSerializer, AlbumSerializer, CancionSerializer
import logging
logger = logging.getLogger(__name__)
@login_required
def principal(request):
artistas = Artista.objects.all()
albumes = Album.objects.all()
return render(request, 'lyrics/index.html', {'artistas': artistas, 'albumes': albumes})
#########################
# Vistas para los artistas
@login_required
def lista_artistas(request):
artistas = Artista.objects.all()
return render(request, 'lyrics/lista_artistas.html', {'artistas': artistas})
@login_required
def detalle_artista(request, artista_id):
artista = get_object_or_404(Artista, pk=artista_id)
albumes = Album.objects.filter(artist=artista_id)
return render(request, 'lyrics/detalle_artista.html', {'artista': artista, 'albumes': albumes})
@login_required
def nuevo_artista(request):
if request.method == 'POST':
form = ArtistaForm(request.POST, request.FILES)
if form.is_valid():
form.save()
return redirect('lyrics:lista_artistas')
else:
form = ArtistaForm()
return render(request, 'lyrics/form_artista.html', {'form': form})
@login_required
def editar_artista(request, artista_id):
artista = get_object_or_404(Artista, pk=artista_id)
if request.method == 'POST':
form = ArtistaForm(request.POST, request.FILES, instance=artista)
if form.is_valid():
form.save()
return redirect('lyrics:lista_artistas')
else:
form = ArtistaForm(instance=artista)
return render(request, 'lyrics/form_artista.html', {'form': form})
@login_required
def eliminar_artista(request, artista_id):
artista = get_object_or_404(Artista, pk=artista_id)
artista.delete()
return redirect('lyrics:lista_artistas')
#########################
# Vistas para los albumes
@login_required
def lista_albumes(request):
albumes = Album.objects.all()
return render(request, 'lyrics/lista_albumes.html', {'albumes': albumes})
@login_required
def detalle_album(request, album_id):
album = get_object_or_404(Album, pk=album_id)
songs = Song.objects.filter(album_id=album_id)
return render(request, 'lyrics/detalle_album.html', {'album': album, 'songs': songs})
@login_required
def nuevo_album(request):
artistas = Artista.objects.all() # vamos a ver si hay vehículos dados de alta
if artistas:
if request.method == 'POST':
form = AlbumForm(request.POST, request.FILES)
if form.is_valid():
form.save()
return redirect('lyrics:lista_albumes')
else:
form = AlbumForm()
return render(request, 'lyrics/form_album.html', {'form': form})
else:
return render(request, 'lyrics/index.html')
@login_required
def editar_album(request, album_id):
album = get_object_or_404(Album, pk=album_id)
if request.method == 'POST':
form = AlbumForm(request.POST, request.FILES, instance=album)
if form.is_valid():
form.save()
return redirect('lyrics:lista_albumes')
else:
form = AlbumForm(instance=album)
return render(request, 'lyrics/form_album.html', {'form': form})
@login_required
def eliminar_album(request, album_id):
album = Album.objects.get(pk=album_id)
album.delete()
return redirect('lyrics:lista_albumes')
#########################
# Vistas para los songs
@login_required
def lista_songs(request):
songs = Song.objects.all()
return render(request, 'lyrics/lista_songs.html', {'songs': songs})
@login_required
def detalle_song(request, song_id):
song = get_object_or_404(Song, pk=song_id)
albumes = Album.objects.filter(song=song_id)
return render(request, 'lyrics/detalle_song.html', {'song': song, 'albumes': albumes})
@login_required
def nuevo_song(request):
album_id = request.GET.get('album_id') # Obtener el album_id de los parámetros de la URL
if request.method == 'POST':
form = SongForm(request.POST, request.FILES)
if form.is_valid():
album = form.cleaned_data['album']
song_count = album.song.count()
nueva_cancion = form.save(commit=False)
nueva_cancion.pista = song_count + 1
nueva_cancion.save()
logger.info("Canción creada %s", nueva_cancion.title)
return redirect('lyrics:lista_songs')
else:
if album_id:
# Si tenemos un album_id, preseleccionamos ese álbum en el formulario
album = get_object_or_404(Album, id=album_id)
form = SongForm(initial={'album': album, 'artist': album.artist, 'year': album.year})
else:
form = SongForm()
return render(request, 'lyrics/form_song.html', {'form': form})
@login_required
def editar_song(request, song_id):
song = get_object_or_404(Song, pk=song_id)
if request.method == 'POST':
form = SongForm(request.POST, request.FILES, instance=song)
if form.is_valid():
form.save()
return redirect('lyrics:lista_songs')
else:
form = SongForm(instance=song)
return render(request, 'lyrics/form_song.html', {'form': form})
@login_required
def eliminar_song(request, song_id):
song = get_object_or_404(Song, pk=song_id)
song.delete()
return redirect('lyrics:lista_songs')
@api_view(['GET'])
def api_lista_artistas(request):
"""Devuelve la lista de todos los artistas."""
artistas = Artista.objects.all()
serializer = ArtistaSerializer(artistas, many=True)
return Response(serializer.data)
@api_view(['GET'])
def api_detalle_artista(request, artista_id):
"""Devuelve los detalles de un artista específico."""
try:
artista = Artista.objects.get(id=artista_id)
serializer = ArtistaSerializer(artista)
return Response(serializer.data)
except Artista.DoesNotExist:
return Response({'error': 'Artista no encontrado'}, status=404)
@api_view(['GET'])
def api_lista_albumes(request):
"""Devuelve la lista de todos los albumes."""
albumes = Album.objects.all()
serializer = AlbumSerializer(albumes, many=True)
return Response(serializer.data)
@api_view(['GET'])
def api_detalle_album(request, album_id):
"""Devuelve los detalles de un album específico."""
try:
album = Album.objects.get(id=album_id)
serializer = AlbumSerializer(album)
return Response(serializer.data)
except Album.DoesNotExist:
return Response({'error': 'Album no encontrado'}, status=404)
@api_view(['GET'])
def api_lista_canciones(request):
"""Devuelve la lista de todos los canciones."""
canciones = Song.objects.all()
serializer = CancionSerializer(canciones, many=True)
return Response(serializer.data)
@api_view(['GET'])
def api_detalle_cancion(request, cancion_id):
"""Devuelve los detalles de un cancion específica."""
try:
cancion = Song.objects.get(id=cancion_id)
serializer = CancionSerializer(cancion)
return Response(serializer.data)
except Song.DoesNotExist:
return Response({'error': 'Canción no encontrada'}, status=404)

src/repostajes/.gitignore → src/macrociclos/.gitignore View File


src/lyrics/__init__.py → src/macrociclos/__init__.py View File


src/repostajes/admin.py → src/macrociclos/admin.py View File


src/repostajes/apps.py → src/macrociclos/apps.py View File


src/repostajes/forms.py → src/macrociclos/forms.py View File


src/lyrics/management/__init__.py → src/macrociclos/management/__init__.py View File


src/lyrics/management/commands/__init__.py → src/macrociclos/management/commands/__init__.py View File


src/repostajes/management/commands/importar_repostajes.py → src/macrociclos/management/commands/importar_repostajes.py View File


src/repostajes/management/commands/importar_vehiculos.py → src/macrociclos/management/commands/importar_vehiculos.py View File


+ 34
- 0
src/macrociclos/models.py View File

@ -0,0 +1,34 @@
from django.db import models
from django.core.validators import MaxValueValidator
class Entrenador(models.Model):
nombre = models.CharField(max_length=200)
def __str__(self):
return self.nombre
class Deportista(models.Model):
nombre = models.CharField(max_length=200)
entrenador = models.ForeignKey(Entrenador, on_delete=models.CASCADE)
def __str__(self):
return self.nombre
class Macrociclo(models.Model):
TIPOS= [
('REG', 'REG'),
('ATR', 'ATR'),
('ACE', 'ACE')
]
nombre = models.CharField(max_length=200)
tipo = models.CharField(choices=TIPOS, max_length=3)
desde = models.DateField()
hasta = models.DateField()
deportista = models.ForeignKey(Deportista, on_delete=models.CASCADE)
entrenador = models.ForeignKey(Entrenador, on_delete=models.CASCADE)
def __str__(self):
return str(self.nombre)

src/repostajes/serializers.py → src/macrociclos/serializers.py View File


src/repostajes/static/css/portal.css → src/macrociclos/static/css/portal.css View File


src/repostajes/static/images/app-logo.svg → src/macrociclos/static/images/app-logo.svg View File


src/repostajes/static/images/background/background-1.jpg → src/macrociclos/static/images/background/background-1.jpg View File


src/repostajes/static/images/background/background-2.jpg → src/macrociclos/static/images/background/background-2.jpg View File


src/repostajes/static/images/background/background-3.jpg → src/macrociclos/static/images/background/background-3.jpg View File


src/repostajes/static/images/background/background-palmeras.jpg → src/macrociclos/static/images/background/background-palmeras.jpg View File


src/repostajes/static/images/doc-thumb-1.jpg → src/macrociclos/static/images/doc-thumb-1.jpg View File


src/repostajes/static/images/doc-thumb-2.jpg → src/macrociclos/static/images/doc-thumb-2.jpg View File


src/repostajes/static/images/favicon.ico → src/macrociclos/static/images/favicon.ico View File


src/repostajes/static/images/favicon.png → src/macrociclos/static/images/favicon.png View File


src/repostajes/static/images/portal-logo.svg → src/macrociclos/static/images/portal-logo.svg View File


src/repostajes/static/images/profiles/profile-1.png → src/macrociclos/static/images/profiles/profile-1.png View File


src/repostajes/static/images/profiles/profile-2.png → src/macrociclos/static/images/profiles/profile-2.png View File


src/repostajes/static/images/profiles/profile-3.png → src/macrociclos/static/images/profiles/profile-3.png View File


src/repostajes/static/images/profiles/profile-4.png → src/macrociclos/static/images/profiles/profile-4.png View File


src/repostajes/static/images/profiles/profile-5.png → src/macrociclos/static/images/profiles/profile-5.png View File


src/repostajes/static/images/profiles/profile-6.png → src/macrociclos/static/images/profiles/profile-6.png View File


src/repostajes/static/images/reymota-logo.svg → src/macrociclos/static/images/reymota-logo.svg View File


src/repostajes/static/images/user.png → src/macrociclos/static/images/user.png View File


src/repostajes/static/images/users/user-1.jpg → src/macrociclos/static/images/users/user-1.jpg View File


src/repostajes/static/images/users/user-2.jpg → src/macrociclos/static/images/users/user-2.jpg View File


src/repostajes/static/images/users/user-3.jpg → src/macrociclos/static/images/users/user-3.jpg View File


src/repostajes/static/images/users/user-4.jpg → src/macrociclos/static/images/users/user-4.jpg View File


src/repostajes/static/images/users/user-5.jpg → src/macrociclos/static/images/users/user-5.jpg View File


src/repostajes/static/images/users/user-6.jpg → src/macrociclos/static/images/users/user-6.jpg View File


src/repostajes/static/images/users/user-7.jpg → src/macrociclos/static/images/users/user-7.jpg View File


src/repostajes/static/images/users/user-8.jpg → src/macrociclos/static/images/users/user-8.jpg View File


src/repostajes/static/images/users/user-9.jpg → src/macrociclos/static/images/users/user-9.jpg View File


src/repostajes/static/js/app.js → src/macrociclos/static/js/app.js View File


src/repostajes/static/js/charts-demo.js → src/macrociclos/static/js/charts-demo.js View File


src/repostajes/static/js/index-charts.js → src/macrociclos/static/js/index-charts.js View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-grid.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-grid.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-grid.min.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.min.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-grid.min.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.min.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-grid.rtl.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.rtl.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-grid.rtl.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.rtl.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-grid.rtl.min.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.rtl.min.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-grid.rtl.min.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap-grid.rtl.min.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-reboot.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-reboot.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-reboot.min.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.min.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-reboot.min.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.min.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-reboot.rtl.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.rtl.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-reboot.rtl.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.rtl.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-reboot.rtl.min.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.rtl.min.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-reboot.rtl.min.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap-reboot.rtl.min.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-utilities.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-utilities.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-utilities.min.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.min.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-utilities.min.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.min.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-utilities.rtl.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.rtl.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-utilities.rtl.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.rtl.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-utilities.rtl.min.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.rtl.min.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap-utilities.rtl.min.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap-utilities.rtl.min.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap.min.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap.min.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap.min.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap.min.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap.rtl.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap.rtl.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap.rtl.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap.rtl.css.map View File


src/repostajes/static/plugins/bootstrap/css/bootstrap.rtl.min.css → src/macrociclos/static/plugins/bootstrap/css/bootstrap.rtl.min.css View File


src/repostajes/static/plugins/bootstrap/css/bootstrap.rtl.min.css.map → src/macrociclos/static/plugins/bootstrap/css/bootstrap.rtl.min.css.map View File


src/repostajes/static/plugins/bootstrap/js/bootstrap.bundle.js → src/macrociclos/static/plugins/bootstrap/js/bootstrap.bundle.js View File


src/repostajes/static/plugins/bootstrap/js/bootstrap.bundle.js.map → src/macrociclos/static/plugins/bootstrap/js/bootstrap.bundle.js.map View File


src/repostajes/static/plugins/bootstrap/js/bootstrap.bundle.min.js → src/macrociclos/static/plugins/bootstrap/js/bootstrap.bundle.min.js View File


src/repostajes/static/plugins/bootstrap/js/bootstrap.bundle.min.js.map → src/macrociclos/static/plugins/bootstrap/js/bootstrap.bundle.min.js.map View File


src/repostajes/static/plugins/bootstrap/js/bootstrap.esm.js → src/macrociclos/static/plugins/bootstrap/js/bootstrap.esm.js View File


src/repostajes/static/plugins/bootstrap/js/bootstrap.esm.js.map → src/macrociclos/static/plugins/bootstrap/js/bootstrap.esm.js.map View File


src/repostajes/static/plugins/bootstrap/js/bootstrap.esm.min.js → src/macrociclos/static/plugins/bootstrap/js/bootstrap.esm.min.js View File


src/repostajes/static/plugins/bootstrap/js/bootstrap.esm.min.js.map → src/macrociclos/static/plugins/bootstrap/js/bootstrap.esm.min.js.map View File


src/repostajes/static/plugins/bootstrap/js/bootstrap.js → src/macrociclos/static/plugins/bootstrap/js/bootstrap.js View File


src/repostajes/static/plugins/bootstrap/js/bootstrap.js.map → src/macrociclos/static/plugins/bootstrap/js/bootstrap.js.map View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save