Skip to content

Commit

Permalink
Version 1.1.1 App library added
Browse files Browse the repository at this point in the history
  • Loading branch information
Jav2000 committed Dec 20, 2024
1 parent 948f2f8 commit 4f790b1
Show file tree
Hide file tree
Showing 22 changed files with 518 additions and 5 deletions.
1 change: 1 addition & 0 deletions coupleApp/core/templates/home_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<li><a href="{% url 'trips:trips_page' %}" class="home-menu-item">Sitios en donde hemos estado</a></li>
<li><a href="{% url 'gallery:photo_gallery' %}" class="home-menu-item">Galería de Fotos</a></li>
<li><a href="{% url 'makeup:makeup_items_page' %}" class="home-menu-item">Mi maquillaje</a></li>
<li><a href="{% url 'library:library_page' %}" class="home-menu-item">Mi librería</a></li>
<li><a href="#" class="home-menu-item">Próximamente: Nuevas Aplicaciones</a></li>
</ul>
</nav>
Expand Down
5 changes: 3 additions & 2 deletions coupleApp/coupleApp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
GOOGLE_MAPS_API_KEY = config('GOOGLE_MAPS_API_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True

ALLOWED_HOSTS = ['localhost', '127.0.0.1', '192.168.1.10']

Expand All @@ -39,7 +39,8 @@
'core',
'trips',
'gallery',
'makeup'
'makeup',
'library'
]

MIDDLEWARE = [
Expand Down
1 change: 1 addition & 0 deletions coupleApp/coupleApp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
path('trips/', include('trips.urls')),
path('gallery/', include('gallery.urls')),
path('makeup/', include('makeup.urls')),
path('library/', include('library.urls')),
]
Empty file added coupleApp/library/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions coupleApp/library/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.contrib import admin

from .models import Book

# Register your models here.
@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
list_display = ('title', 'author', 'genre', 'publish_date') # Campos a mostrar en la lista de libros
list_filter = ('genre', 'publish_date') # Filtros por género y fecha de publicación
search_fields = ('title', 'author') # Permite buscar por título y autor
ordering = ('-publish_date',) # Ordenar los libros por la fecha de publicación en orden descendente
6 changes: 6 additions & 0 deletions coupleApp/library/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class LibraryConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'library'
8 changes: 8 additions & 0 deletions coupleApp/library/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django import forms

from .models import Book

class BookForm(forms.ModelForm):
class Meta:
model = Book
fields = ['title', 'author', 'description', 'isbn', 'genre', 'publish_date', 'pages', 'cover_image']
31 changes: 31 additions & 0 deletions coupleApp/library/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 5.1.3 on 2024-12-20 17:03

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Book',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200)),
('author', models.CharField(max_length=200)),
('description', models.TextField(blank=True, null=True)),
('isbn', models.CharField(blank=True, max_length=13, null=True, unique=True)),
('genre', models.CharField(blank=True, max_length=100, null=True)),
('publish_date', models.DateField(blank=True, null=True)),
('pages', models.PositiveIntegerField(blank=True, null=True)),
('language', models.CharField(blank=True, max_length=50, null=True)),
('cover_image', models.ImageField(blank=True, null=True, upload_to='book_covers/')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
),
]
Empty file.
17 changes: 17 additions & 0 deletions coupleApp/library/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.db import models

# Create your models here.
class Book(models.Model):
title = models.CharField(max_length=200) # Título del libro (obligatorio)
author = models.CharField(max_length=200) # Autor del libro (obligatorio)
description = models.TextField(blank=True, null=True) # Descripción (opcional)
isbn = models.CharField(max_length=13, unique=True, blank=True, null=True) # ISBN (opcional)
genre = models.CharField(max_length=100, blank=True, null=True) # Género (opcional)
publish_date = models.DateField(null=True, blank=True) # Fecha de publicación (opcional)
pages = models.PositiveIntegerField(blank=True, null=True) # Número de páginas (opcional)
cover_image = models.ImageField(upload_to='book_covers/', blank=True, null=True) # Imagen de la portada (opcional)
created_at = models.DateTimeField(auto_now_add=True) # Fecha de creación
updated_at = models.DateTimeField(auto_now=True) # Fecha de última actualización

def __str__(self):
return self.title
80 changes: 80 additions & 0 deletions coupleApp/library/templates/book_details_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html lang="es">
<head>
{% load static %}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>{% block title %}Sitios Visitados{% endblock %}</title>

<link rel="stylesheet" href="{% static 'css/general.css' %}">
<link rel="stylesheet" href="{% static 'css/gallery/photo_gallery.css' %}">
<link rel="icon" href="{% static 'images/Lucier.ico' %}" type="image/x-icon">

<script src="{% static 'js/gallery/photo_gallery.js' %}" defer></script>

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
</head>
<body>
<header class="header">
<div class="logo-container">
<a href="{% url 'core:home_page' %}">
<img src="{% static 'images/Lucier.png' %}" alt="Logo Lucier" class="logo">
</a>
</div>
<div class="header-content">
<h1>Sitios donde hemos estado</h1>
<p>Aquí puedes ver todos los lugares en los que hemos estado y añadir los nuevos a donde vayamos.</p>
</div>
</header>
<div class="header-bar">
<div class="back-button-container">
<a href="{% url 'library:library_page' %}" class="btn-back">&#8592;</a>
</div>
</div>
<div class="main-container">
<main class="main-content">
<div class="details">
<header class="details-header">
<div class="action-buttons">
<a href="{% url 'library:edit_book' book.pk %}" class="btn-edit"><i class="fas fa-pencil-alt"></i></a>
<form action="{% url 'library:delete_book' book.pk %}" method="post" class="btn-delete-form">
{% csrf_token %}
<button type="submit" class="btn-delete" onclick="return confirm('¿Estás seguro de que deseas eliminar este producto?')"><i class="fas fa-trash-alt"></i></button>
</form>
</div>
<h2>{{ book.title }}</h2>
</header>

<section class="description">
<h3>Autor</h3>
<p>{{ book.author }}</p>
</section>

<section class="item-info">
<h3>Información adicional</h3>
<ul>
<li><strong>Descripción:</strong> {{ book.description|default:"No disponible" }}</li>
<li><strong>Género:</strong> {{ book.genre|default:"No disponible" }}</li>
<li><strong>ISBN:</strong> {{ book.isbn|default:"No disponible" }}</li>
<li><strong>Fecha de publicación:</strong> {{ book.publish_date|default:"No disponible" }}</li>
<li><strong>Páginas:</strong> {{ book.pages|default:"No disponible" }}</li>
</ul>
</section>

<section class="item-image">
<h3>Imagen del libro</h3>
{% if book.cover_image %}
<img src="{{ book.cover_image.url }}" alt="Imagen de {{ book.name }}" class="item-image-preview">
{% else %}
<p>No se ha cargado imagen.</p>
{% endif %}
</section>
</div>
</main>
</div>
<footer class="footer">
<p>&copy; 2024 Lucier <span style="color: #C71585;"></span></p>
</footer>
</body>
</html>
65 changes: 65 additions & 0 deletions coupleApp/library/templates/edit_book.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="es">
<head>
{% load static %}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>{% block title %}Editar viaje{% endblock %}</title>

<link rel="stylesheet" href="{% static 'css/general.css' %}">
<link rel="icon" href="{% static 'images/Lucier.ico' %}" type="image/x-icon">

<script src="{% static 'js/trips/add_edit_trip.js' %}" defer></script>
</head>
<body>
<header class="header">
<div class="logo-container">
<a href="{% url 'core:home_page' %}">
<img src="{% static 'images/Lucier.png' %}" alt="Logo Lucier" class="logo">
</a>
</div>
<div class="header-content">
<h1>Editar viaje a: {{ trip.destiny }}</h1>
</div>
</header>
<div class="header-bar">
<div class="back-button-container">
<a href="{% url 'library:book_details_page' book.pk %}" class="btn-back" aria-label="Volver a la lista de sitios">&#8592;</a>
</div>
</div>
<div class="main-container">
<main class="main-content">
<form method="post" id="dataForm" class="new-form">
{% csrf_token %}
<div class="form-group">
<label for="title">Título</label>
<input type="text" id="title" name="title" class="form-control" value="{{ book.title }}" required>
</div>

<div class="form-group">
<label for="author">Autor</label>
<textarea id="description" name="author" class="form-control">{{ book.author }}</textarea>
</div>

<div class="form-group">
<label for="isbn">ISBN</label>
<input type="text" id="isbn" name="isbn" class="form-control" value="{{ book.isbn }}" required>
</div>

<div class="form-group">
<label for="cover_image">Imagen</label>
<input type="file" id="cover_image" name="cover_image" class="form-control" accept="image/*" value="{{item.cover_image}}">
</div>

<!-- Botón de Envío -->
<button type="submit">Guardar cambios</button>
</form>
</main>
</div>

<footer class="footer">
<p>&copy; 2024 Lucier <span style="color: #C71585;"></span></p>
</footer>
</body>
</html>
71 changes: 71 additions & 0 deletions coupleApp/library/templates/library_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!DOCTYPE html>
<html lang="es">
<head>
{% load static %}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>{% block title %}Sitios Visitados{% endblock %}</title>

<link rel="stylesheet" href="{% static 'css/general.css' %}">
<link rel="stylesheet" href="{% static 'css/gallery/photo_gallery.css' %}">
<link rel="icon" href="{% static 'images/Lucier.ico' %}" type="image/x-icon">

<script src="{% static 'js/gallery/photo_gallery.js' %}" defer></script>

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
</head>
<body>
<header class="header">
<div class="logo-container">
<a href="{% url 'core:home_page' %}">
<img src="{% static 'images/Lucier.png' %}" alt="Logo Lucier" class="logo">
</a>
</div>
<div class="header-content">
<h1>Sitios donde hemos estado</h1>
<p>Aquí puedes ver todos los lugares en los que hemos estado y añadir los nuevos a donde vayamos.</p>
</div>
</header>
<div class="header-bar">
<div class="back-button-container">
<a href="{% url 'core:home_page' %}" class="btn-back" aria-label="Volver a la lista de sitios">&#8592;</a>
</div>
<div class="add-buttons-container">
<div id="add-button-container" class="add-button-container">
<a href="{% url 'library:new_book' %}" class="btn-add">
<button type="button">Nuevo libro</button>
</a>
</div>
</div>
</div>
<div class="main-container">
<main class="main-content">
<div class="books-list">
<h1 class="category-title">Todos los Libros</h1>
{% if books %}
<ul class="product-list">
{% for book in books %}
<li class="product-item">
<a href="{% url 'library:book_details_page' book.pk %}" class="product-link">
<div class="product-info">
<h2 class="product-name">{{ book.title }}</h2>
<p class="product-brand">{{ book.author }}</p>
</div>
<span class="product-arrow"></span>
</a>
</li>
{% endfor %}
</ul>
{% else %}
<p class="no-items">No hay libros disponibles.</p>
{% endif %}
</div>
</main>
</div>

<footer class="footer">
<p>&copy; 2024 Lucier <span style="color: #C71585;"></span></p>
</footer>
</body>
</html>
Loading

0 comments on commit 4f790b1

Please sign in to comment.