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: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:latest
FROM python:3.10-slim

ENV PYTHONUNBUFFERED 1
ENV DJANGO_SETTINGS_MODULE="chapp.settings"
Expand Down
Binary file modified db.sqlite3
Binary file not shown.
Binary file modified pms/form_dates/__pycache__/Ymd.cpython-310.pyc
Binary file not shown.
60 changes: 59 additions & 1 deletion pms/forms.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from datetime import datetime
from datetime import date, datetime
from django import forms
from django.forms import ModelForm

from .models import Booking, Customer

MAX_BOOKING_DATE = date(2026, 12, 31)


class RoomSearchForm(ModelForm):
class Meta:
Expand Down Expand Up @@ -56,3 +58,59 @@ class Meta:
'total': forms.HiddenInput(),
'state': forms.HiddenInput(),
}


class BookingDatesForm(ModelForm):
class Meta:
model = Booking
fields = ["checkin", "checkout"]
labels = {
"checkin": "Fecha entrada",
"checkout": "Fecha salida",
}
widgets = {
"checkin": forms.DateInput(
attrs={
"type": "date",
"min": date.today().strftime("%Y-%m-%d"),
"max": MAX_BOOKING_DATE.strftime("%Y-%m-%d"),
}
),
"checkout": forms.DateInput(
attrs={
"type": "date",
"min": date.today().strftime("%Y-%m-%d"),
"max": MAX_BOOKING_DATE.strftime("%Y-%m-%d"),
}
),
}

def clean(self):
cleaned_data = super().clean()
checkin = cleaned_data.get("checkin")
checkout = cleaned_data.get("checkout")

today = date.today()

if checkin and checkin < today:
self.add_error("checkin", "La fecha de entrada no puede ser anterior a hoy.")
if checkout and checkout < today:
self.add_error("checkout", "La fecha de salida no puede ser anterior a hoy.")

if checkin and checkin > MAX_BOOKING_DATE:
self.add_error(
"checkin",
f"La fecha de entrada no puede ser posterior a {MAX_BOOKING_DATE.strftime('%d/%m/%Y')}.",
)
if checkout and checkout > MAX_BOOKING_DATE:
self.add_error(
"checkout",
f"La fecha de salida no puede ser posterior a {MAX_BOOKING_DATE.strftime('%d/%m/%Y')}.",
)

if checkin and checkout and checkin >= checkout:
raise forms.ValidationError(
"La fecha de salida debe ser posterior a la fecha de entrada."
)

return cleaned_data
Binary file modified pms/migrations/__pycache__/0001_initial.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified pms/migrations/__pycache__/0008_alter_book_code.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified pms/migrations/__pycache__/0011_alter_book_code.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified pms/migrations/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file modified pms/reservation_code/__pycache__/generate.cpython-310.pyc
Binary file not shown.
5 changes: 5 additions & 0 deletions pms/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ <h1 class="dashboard-value">{{dashboard.outcoming_guests}}</h1>
<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 class="card text-white p-3 card-customization" style="background-color: #6f42c1;">
<h5 class="small">% ocupación</h5>
<h1 class="dashboard-value">{{dashboard.occupancy_pct|floatformat:2}}%</h1>
</div>
</div>
</div>
{% endblock content%}
43 changes: 43 additions & 0 deletions pms/templates/edit_booking_dates.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{% extends "main.html"%}

{% block content %}
<h1>Editar fechas</h1>

<div class="mb-3">
<div><strong>Reserva:</strong> {{booking.code}}</div>
<div><strong>Habitación:</strong> {{booking.room}}</div>
</div>

<form action="" method="post">
{% csrf_token%}

{% if form.non_field_errors %}
<div class="alert alert-danger">
{% for error in form.non_field_errors %}
<div>{{error}}</div>
{% endfor %}
</div>
{% endif %}

{% for field in form %}
<div class="row mb-2">
<div class="col-md-2">
{{field.label_tag}}
</div>
<div class="col-md-auto">
{{field}}
</div>
<div class="col text-danger">
{% for error in field.errors %}
<div>{{error}}</div>
{% endfor %}
</div>
</div>
{% endfor %}

<a class="btn btn-outline-primary" href="{% url 'home' %}">Volver</a>
<button class="btn btn-primary" type="submit">Guardar</button>
</form>

{% endblock content%}

4 changes: 3 additions & 1 deletion pms/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ <h3>Reservas Realizadas</h3>
<a href="{% url 'edit_booking' pk=booking.id%} " >Editar datos de contacto</a>
</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">

Expand Down
19 changes: 19 additions & 0 deletions pms/templates/rooms.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

{% block content %}
<h1>Habitaciones del hotel</h1>

<form method="GET" class="row g-2 align-items-end">
<div class="col-sm-6 col-md-4">
<label for="room-name-filter" class="form-label">Filtrar por nombre</label>
<input
id="room-name-filter"
class="form-control"
type="search"
name="name"
value="{{ name|default:'' }}"
placeholder="Ej: Room 1"
>
</div>
<div class="col-auto">
<button class="btn btn-primary" type="submit">Filtrar</button>
<a class="btn btn-outline-secondary" href="{% url 'rooms' %}">Limpiar</a>
</div>
</form>

{% for room in rooms%}
<div class="row card mt-3 mb-3 hover-card bg-tr-250">
<div class="col p-3">
Expand Down
Loading