Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*/__pycache__/**
.idea/
*.pyc
*pyc
Binary file modified db.sqlite3
Binary file not shown.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '2'
# version: '2'
services:
testservice:
build:
Expand Down
29 changes: 29 additions & 0 deletions pms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,32 @@ class Meta:
'total': forms.HiddenInput(),
'state': forms.HiddenInput(),
}


class BookingDatesForm(forms.Form):
checkin = forms.DateField(
label="Fecha de entrada",
widget=forms.DateInput(attrs={
'type': 'date',
'min': datetime.today().strftime('%Y-%m-%d'),
'max': '2026-12-31',
'class': 'form-control',
})
)
checkout = forms.DateField(
label="Fecha de salida",
widget=forms.DateInput(attrs={
'type': 'date',
'min': datetime.today().strftime('%Y-%m-%d'),
'max': '2026-12-31',
'class': 'form-control',
})
)

def clean(self):
cleaned_data = super().clean()
checkin = cleaned_data.get('checkin')
checkout = cleaned_data.get('checkout')
if checkin and checkout and checkout <= checkin:
raise forms.ValidationError("La fecha de salida debe ser posterior a la de entrada.")
return cleaned_data
21 changes: 19 additions & 2 deletions pms/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block content %}
<h1>Dashboard</h1>
<div class="card">
<div class="card mb-4">
<h5 class="card-header">Hoy</h5>
<div class="d-flex justify-content-evenly pt-5 pb-5">
<div class="card text-white p-3 card-customization" style="background-color: #1000ff;">
Expand All @@ -17,11 +17,28 @@ <h1 class="dashboard-value">{{dashboard.incoming_guests}}</h1>
<h5 class="small">Huéspedes saliendo</h5>
<h1 class="dashboard-value">{{dashboard.outcoming_guests}}</h1>
</div>

<div class="card text-white p-3 card-customization" style="background-color: #ff7f7f;">
<h5 class="small">Total facturado</h5>
<h1 class="dashboard-value">€ {% if dashboard.invoiced.total__sum == None %}0.00{% endif %} {{dashboard.invoiced.total__sum|floatformat:2}}</h1>
</div>
</div>
</div>

<div class="card">
<h5 class="card-header">Ocupación general</h5>
<div class="d-flex justify-content-center align-items-center pt-5 pb-5">
<div class="card text-white p-4 text-center" style="background-color: #6f42c1; min-width: 220px;">
<h5 class="small mb-1">% Ocupación</h5>
<h1 class="display-3 fw-bold mb-1">{{ dashboard.occupancy }}%</h1>
<p class="small mb-0 opacity-75">Reservas confirmadas / habitaciones totales</p>
<div class="progress mt-3" style="height: 10px;">
<div class="progress-bar bg-black" role="progressbar"
style="width: {{ dashboard.occupancy }}%;"
aria-valuenow="{{ dashboard.occupancy }}"
aria-valuemin="0" aria-valuemax="100">
</div>
</div>
</div>
</div>
</div>
{% endblock content%}
37 changes: 37 additions & 0 deletions pms/templates/edit_booking_dates.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% extends "main.html"%}

{% block content %}
<h1>Editar fechas de la reserva</h1>

<div class="card card-body mt-3" style="max-width: 480px;">
<h5 class="mb-3">Reserva <strong>{{ booking.code }}</strong> &mdash; {{ booking.room.name }}</h5>

{% if error %}
<div class="alert alert-danger">{{ error }}</div>
{% endif %}

<form action="" method="post">
{% csrf_token %}
{% for field in form %}
<div class="mb-3 row">
<div class="col-md-4">
{{ field.label_tag }}
</div>
<div class="col-md-8">
{{ field }}
{% if field.errors %}
<div class="text-danger small mt-1">{{ field.errors }}</div>
{% endif %}
</div>
</div>
{% endfor %}
{% if form.non_field_errors %}
<div class="alert alert-danger">{{ form.non_field_errors }}</div>
{% endif %}
<div class="d-flex gap-2 mt-3">
<a class="btn btn-outline-secondary" href="{% url 'home' %}">Volver</a>
<button class="btn btn-primary" type="submit">Guardar</button>
</div>
</form>
</div>
{% endblock content %}
12 changes: 7 additions & 5 deletions pms/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,18 @@ <h3>Reservas Realizadas</h3>
</div>
<div class="row">
<div class="col">

<a href="{% url 'edit_booking' pk=booking.id%} " >Editar datos de contacto</a>
{% if booking.state != "DEL" %}
<a href="{% url 'edit_booking' pk=booking.id%} ">Editar datos de contacto</a>
{% endif %}
</div>
<div class="col">

{% if booking.state != "DEL" %}
<a href="{% url 'edit_booking_dates' pk=booking.id%}">Editar fechas</a>
{% endif %}
</div>
<div class="col">

{% if booking.state != "DEL" %}
<a href="{% url 'delete_booking' pk=booking.id%} " >Cancelar reserva</a>
<a href="{% url 'delete_booking' pk=booking.id%} ">Cancelar reserva</a>
{% endif %}
</div>

Expand Down
2 changes: 1 addition & 1 deletion pms/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</li>
</ul>
<form action="{% url 'booking_search'%}" method="GET" class="d-flex">
<input class="form-control me-2" type="search" required name="filter" placeholder="Nombre o Localizador" aria-label="Search">
<input class="form-control me-2" type="search" required name="filter" placeholder="Busca tu reserva" aria-label="Search">
<button class="btn btn-outline-light" type="submit">Buscar </button>
</form>
</div>
Expand Down
44 changes: 33 additions & 11 deletions pms/templates/rooms.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,40 @@

{% block content %}
<h1>Habitaciones del hotel</h1>
{% for room in rooms%}
<div class="row card mt-3 mb-3 hover-card bg-tr-250">
<div class="col p-3">
<div class="">
{{room.name}} ({{room.room_type__name}})
</div>
<div>
<a href="{% url 'room_details' pk=room.id%}">Ver detalles</a>

<form method="GET" action="{% url 'rooms' %}" class="row g-2 align-items-center mb-4 mt-2">
<div class="col-auto">
<input type="text" name="name" class="form-control" placeholder="Buscar por nombre..." value="{{ name_filter }}">
</div>
<div class="col-auto">
<button type="submit" class="btn btn-primary">Filtrar</button>
</div>
{% if name_filter %}
<div class="col-auto">
<a href="{% url 'rooms' %}" class="btn btn-outline-secondary">Limpiar</a>
</div>
{% endif %}
</form>

{% if rooms|length == 0 %}
<div class="alert alert-info">
No se encontraron habitaciones.
</div>
{% else %}
{% for room in rooms%}
<div class="row card mt-3 mb-3 hover-card bg-tr-250">
<div class="col p-3">
<div class="">
{{room.name}} ({{room.room_type__name}})
</div>
<div>
<a href="{% url 'room_details' pk=room.id%}">Ver detalles</a>
</div>

</div>

</div>

</div>
{% endfor %}
{% endfor %}
{% endif %}

{% endblock content%}
Loading