diff --git a/Libros/biblioteca/autores/220px-Yuval_Noah_Harari_cropped.jpg b/Libros/biblioteca/autores/220px-Yuval_Noah_Harari_cropped.jpg new file mode 100644 index 0000000..8043105 Binary files /dev/null and b/Libros/biblioteca/autores/220px-Yuval_Noah_Harari_cropped.jpg differ diff --git a/Libros/biblioteca/autores/220px-Yuval_Noah_Harari_cropped_LijFJPx.jpg b/Libros/biblioteca/autores/220px-Yuval_Noah_Harari_cropped_LijFJPx.jpg new file mode 100644 index 0000000..8043105 Binary files /dev/null and b/Libros/biblioteca/autores/220px-Yuval_Noah_Harari_cropped_LijFJPx.jpg differ diff --git a/Libros/biblioteca/autores/daniel_Tk9mZbV.jpg b/Libros/biblioteca/autores/daniel_Tk9mZbV.jpg new file mode 100644 index 0000000..d7775bd Binary files /dev/null and b/Libros/biblioteca/autores/daniel_Tk9mZbV.jpg differ diff --git a/Libros/biblioteca/biblioteca/settings.py b/Libros/biblioteca/biblioteca/settings.py index 0c4d85f..d08dbc2 100644 --- a/Libros/biblioteca/biblioteca/settings.py +++ b/Libros/biblioteca/biblioteca/settings.py @@ -122,3 +122,7 @@ STATIC_URL = 'static/' # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +LOGIN_URL = '/accounts/login/' +LOGIN_REDIRECT_URL = '/gestion/' +LOGOUT_REDIRECT_URL = '/accounts/login/' \ No newline at end of file diff --git a/Libros/biblioteca/biblioteca/urls.py b/Libros/biblioteca/biblioteca/urls.py index 63da708..6688707 100644 --- a/Libros/biblioteca/biblioteca/urls.py +++ b/Libros/biblioteca/biblioteca/urls.py @@ -18,10 +18,14 @@ from django.contrib import admin from django.urls import path, include from django.conf import settings from django.conf.urls.static import static +from django.contrib.auth import views as auth_views urlpatterns = [ path('obreros/', admin.site.urls), path('gestion/', include('gestion.urls')), + + path('accounts/login/', auth_views.LoginView.as_view(), name='login'), + path('accounts/logout/', auth_views.LogoutView.as_view(), name='logout'), ] diff --git a/Libros/biblioteca/db.sqlite3 b/Libros/biblioteca/db.sqlite3 index 9d40bdb..38c8d39 100644 Binary files a/Libros/biblioteca/db.sqlite3 and b/Libros/biblioteca/db.sqlite3 differ diff --git a/Libros/biblioteca/gestion/forms.py b/Libros/biblioteca/gestion/forms.py index 783a1bf..c26f299 100644 --- a/Libros/biblioteca/gestion/forms.py +++ b/Libros/biblioteca/gestion/forms.py @@ -6,7 +6,22 @@ class AutorForm(forms.ModelForm): model = Autor fields = ['nombre', 'biografia', 'foto'] + nombre = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'})) + biografia = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'})) +# foto = forms.FileField(widget=forms.TextInput(attrs={'class': 'form-control', 'type': 'file'})) + class LibroForm(forms.ModelForm): class Meta: model = Libro fields = ['titulo', 'autor', 'fecha_publicacion', 'descripcion', 'archivo', 'portada'] + + titulo = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'})) +# fecha_publicacion = forms.DateField(widget=forms.TextInput(attrs={'class': 'form-control'})) + descripcion = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'})) +# archivo = forms.FileField(widget=forms.TextInput(attrs={'class': 'form-control', 'type': 'file'})) +# portada = forms.FileField(widget=forms.TextInput(attrs={'class': 'form-control', 'type': 'file'})) + + autor = forms.ModelChoiceField( + queryset=Autor.objects.all(), + widget=forms.Select(attrs={'class': 'form-control'})) + diff --git a/Libros/biblioteca/gestion/models.py b/Libros/biblioteca/gestion/models.py index c4c8aeb..11d5cea 100644 --- a/Libros/biblioteca/gestion/models.py +++ b/Libros/biblioteca/gestion/models.py @@ -1,4 +1,5 @@ from django.db import models + import datetime from django.core.validators import MaxValueValidator, MinValueValidator diff --git a/Libros/biblioteca/gestion/templates/gestion/detalle_autor.html b/Libros/biblioteca/gestion/templates/gestion/detalle_autor.html index e674bea..6ff5a62 100644 --- a/Libros/biblioteca/gestion/templates/gestion/detalle_autor.html +++ b/Libros/biblioteca/gestion/templates/gestion/detalle_autor.html @@ -1,14 +1,64 @@ - - - - Detalle del Autor - - -

{{ autor.nombre }}

-

{{ autor.biografia }}

- {% if autor.foto %} - Foto del autor - {% endif %} - Volver a la lista de autores - - +{% extends 'base.html' %} + +{% block content %} +
+
+
+
+
+ {% if autor.foto %} +

{{ autor.nombre}}

+ {% else %} +

No hay imágen disponible

+ {% endif %} +
+
+

{{ autor.nombre }}

+ +
    +
  • {{ autor.nombre }}
  • +
+
+
+
+
+ + {% if libros %} + + + + + + + + + {% for libro in libros %} + + + {% if libro.portada %} + + {% else %} +

Sin imagen

+ {% endif %} + + {% endfor %} + +
TítuloPortada
{{ libro.titulo }}Portada del libro
+ {% else %} +

No se han encontrado libros para este autor

+ {% endif %} +
+
+ +
+ + + +
+
+{% endblock %} + diff --git a/Libros/biblioteca/gestion/templates/gestion/detalle_libro.html b/Libros/biblioteca/gestion/templates/gestion/detalle_libro.html index 4f15b77..77e4e0a 100644 --- a/Libros/biblioteca/gestion/templates/gestion/detalle_libro.html +++ b/Libros/biblioteca/gestion/templates/gestion/detalle_libro.html @@ -1,18 +1,34 @@ - - - - Detalle del Libro - - -

{{ libro.titulo }}

-

{{ libro.descripcion }}

-

Autor: {{ libro.autor.nombre }}

-

Fecha de Publicación: {{ libro.fecha_publicacion }}

- {% if libro.portada %} - Portada del libro - {% endif %} - {% if libro.archivo %} -

Descargar

- {% endif %} Volver a la lista de libros - - + +{% extends 'base.html' %} + +{% block content %} +
+
+
+
+
+ {% if libro.portada %} +

{{ libro.titulo }}

+ {% else %} +

No hay imágen disponible

+ {% endif %} + {% if libro.archivo %} +

Descargar

+ {% endif %} +
+
+

{{ libro.titulo }}

+ + +
+ +
+
+
+{% endblock %} diff --git a/Libros/biblioteca/gestion/templates/gestion/form_autor.html b/Libros/biblioteca/gestion/templates/gestion/form_autor.html index fa0f805..a06111e 100644 --- a/Libros/biblioteca/gestion/templates/gestion/form_autor.html +++ b/Libros/biblioteca/gestion/templates/gestion/form_autor.html @@ -1,15 +1,18 @@ - - - - Formulario de Autor - - -

{% if form.instance.pk %}Editar Autor{% else %}Nuevo Autor{% endif %}

-
- {% csrf_token %} - {{ form.as_p }} - -
- Cancelar - - +{% extends 'base.html' %} + +{% block content %} +
+ +

{% if form.instance.pk %}Editar Autor{% else %}Nuevo Autor{% endif %}

+
+ +
+ {% csrf_token %} + {{ form.as_p }} +
+ +
+
+
+
+{% endblock %} diff --git a/Libros/biblioteca/gestion/templates/gestion/form_libro.html b/Libros/biblioteca/gestion/templates/gestion/form_libro.html index a53786b..67ad68c 100644 --- a/Libros/biblioteca/gestion/templates/gestion/form_libro.html +++ b/Libros/biblioteca/gestion/templates/gestion/form_libro.html @@ -1,15 +1,16 @@ - - - - Formulario de Libro - - -

{% if form.instance.pk %}Editar Libro{% else %}Nuevo Libro{% endif %}

-
- {% csrf_token %} - {{ form.as_p }} - -
- Cancelar - - +{% extends 'base.html' %} + +{% block content %} +
+

{% if form.instance.pk %}Editar Libro{% else %}Nuevo Libro{% endif %}

+
+
+ {% csrf_token %} + {{ form.as_p }} +
+ +
+
+
+
+{% endblock %} diff --git a/Libros/biblioteca/gestion/templates/gestion/lista_autores.html b/Libros/biblioteca/gestion/templates/gestion/lista_autores.html index 4797171..3db4c28 100644 --- a/Libros/biblioteca/gestion/templates/gestion/lista_autores.html +++ b/Libros/biblioteca/gestion/templates/gestion/lista_autores.html @@ -25,7 +25,7 @@
{% if autor.foto %} - Foto del autor + Foto del autor {% else %} Sin imágen {% endif %} diff --git a/Libros/biblioteca/gestion/templates/registration/login.html b/Libros/biblioteca/gestion/templates/registration/login.html new file mode 100644 index 0000000..0eeacc2 --- /dev/null +++ b/Libros/biblioteca/gestion/templates/registration/login.html @@ -0,0 +1,14 @@ + + + + Iniciar Sesión + + +

Iniciar Sesión

+
+ {% csrf_token %} + {{ form.as_p }} + +
+ + diff --git a/Libros/biblioteca/gestion/views.py b/Libros/biblioteca/gestion/views.py index d756833..45d20ce 100644 --- a/Libros/biblioteca/gestion/views.py +++ b/Libros/biblioteca/gestion/views.py @@ -1,4 +1,5 @@ from django.shortcuts import render, get_object_or_404, redirect +from django.contrib.auth.decorators import login_required from .models import Autor, Libro from .forms import AutorForm, LibroForm @@ -12,8 +13,12 @@ def lista_autores(request): def detalle_autor(request, autor_id): autor = get_object_or_404(Autor, pk=autor_id) - return render(request, 'gestion/detalle_autor.html', {'autor': autor}) + libros = Libro.objects.filter(autor=autor_id) + + return render(request, 'gestion/detalle_autor.html', {'autor': autor, 'libros': libros}) + +@login_required def nuevo_autor(request): if request.method == 'POST': form = AutorForm(request.POST, request.FILES) @@ -24,6 +29,7 @@ def nuevo_autor(request): form = AutorForm() return render(request, 'gestion/form_autor.html', {'form': form}) +@login_required def editar_autor(request, autor_id): autor = get_object_or_404(Autor, pk=autor_id) if request.method == 'POST': @@ -35,6 +41,7 @@ def editar_autor(request, autor_id): form = AutorForm(instance=autor) return render(request, 'gestion/form_autor.html', {'form': form}) +@login_required def eliminar_autor(request, autor_id): autor = get_object_or_404(Autor, pk=autor_id) autor.delete() @@ -49,6 +56,7 @@ def detalle_libro(request, libro_id): libro = get_object_or_404(Libro, pk=libro_id) return render(request, 'gestion/detalle_libro.html', {'libro': libro}) +@login_required def nuevo_libro(request): if request.method == 'POST': form = LibroForm(request.POST, request.FILES) @@ -59,6 +67,7 @@ def nuevo_libro(request): form = LibroForm() return render(request, 'gestion/form_libro.html', {'form': form}) +@login_required def editar_libro(request, libro_id): libro = get_object_or_404(Libro, pk=libro_id) if request.method == 'POST': @@ -70,6 +79,7 @@ def editar_libro(request, libro_id): form = LibroForm(instance=libro) return render(request, 'gestion/form_libro.html', {'form': form}) +@login_required def eliminar_libro(request, libro_id): libro = get_object_or_404(Libro, pk=libro_id) libro.delete() diff --git a/Libros/biblioteca/libros/21_lecciones_para_el_siglo_XXI_-_Yuval_Noah_Harari_234.epub b/Libros/biblioteca/libros/21_lecciones_para_el_siglo_XXI_-_Yuval_Noah_Harari_234.epub new file mode 100644 index 0000000..c7ba50f Binary files /dev/null and b/Libros/biblioteca/libros/21_lecciones_para_el_siglo_XXI_-_Yuval_Noah_Harari_234.epub differ diff --git a/Libros/biblioteca/libros/Palacio_de_la_Luna_El_-_Auster_Paul_99.epub b/Libros/biblioteca/libros/Palacio_de_la_Luna_El_-_Auster_Paul_99.epub new file mode 100644 index 0000000..4884491 Binary files /dev/null and b/Libros/biblioteca/libros/Palacio_de_la_Luna_El_-_Auster_Paul_99.epub differ diff --git a/Libros/biblioteca/portadas/invisible.jpeg b/Libros/biblioteca/portadas/invisible.jpeg new file mode 100644 index 0000000..e09fb7f Binary files /dev/null and b/Libros/biblioteca/portadas/invisible.jpeg differ diff --git a/Libros/biblioteca/portadas/lecciones.jpeg b/Libros/biblioteca/portadas/lecciones.jpeg new file mode 100644 index 0000000..7422ee5 Binary files /dev/null and b/Libros/biblioteca/portadas/lecciones.jpeg differ diff --git a/Libros/biblioteca/portadas/palacio.jpeg b/Libros/biblioteca/portadas/palacio.jpeg new file mode 100644 index 0000000..df52665 Binary files /dev/null and b/Libros/biblioteca/portadas/palacio.jpeg differ