diff --git a/rental/bookings.py b/rental/bookings.py index 8922212..532f3d9 100644 --- a/rental/bookings.py +++ b/rental/bookings.py @@ -1,14 +1,13 @@ -import datetime from rental.pricing import get_reservation_price from django.shortcuts import get_object_or_404 from rental.models import Reservation, Place, Guest +from villafleurie.settings import BASE_DIR import datetime from google.auth.transport.requests import Request from google_auth_oauthlib.flow import InstalledAppFlow from googleapiclient.discovery import build import os.path import pickle -from villafleurie.settings import BASE_DIR def build_calendar_api_service(): @@ -151,3 +150,7 @@ def update_calendar(reservation): }, } ).execute() + + +if __name__ == '__main__': + s, c = build_calendar_api_service() diff --git a/rental/tasks/apiMailer.py b/rental/tasks/apiMailer.py index 2fc6703..716074e 100644 --- a/rental/tasks/apiMailer.py +++ b/rental/tasks/apiMailer.py @@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals from celery import shared_task from villafleurie.settings import EMAIL_HOST_USER, DEFAULT_FROM_EMAIL import requests +from datetime import datetime """ Mailer Service used to send messages using API WebHooks. All Mailers must implement the following methods: @@ -51,4 +52,13 @@ def send_notification(name, email, subject, message, date): @shared_task def send_quotation(name, email): """ Send quotation to customer """ + + send_notification( + name, + email, + "Nouvelle demande de réservation", + "Depuis le site", + datetime.now() + ) + send_confirmation(name, email) diff --git a/rental/templates/rental/base.html b/rental/templates/rental/base.html index e5fced0..508c025 100644 --- a/rental/templates/rental/base.html +++ b/rental/templates/rental/base.html @@ -4,6 +4,10 @@ + VillaFleurie diff --git a/rental/views.py b/rental/views.py index ce707cb..c018a6e 100644 --- a/rental/views.py +++ b/rental/views.py @@ -1,6 +1,8 @@ -from django.shortcuts import render, get_object_or_404 +from django.core.exceptions import ValidationError from django.db import IntegrityError +from django.shortcuts import render, get_object_or_404 from django.views.generic.base import TemplateView +from django.utils.translation import gettext_lazy as _ from rental.forms import ReservationForm, ContactForm from rental.models import Testimonial, Reservation, Guest, Place, Contact from rental.pricing import get_reservation_price @@ -92,6 +94,10 @@ def handle_reservation_form(request, context={}, init_template='rental/reservati template = 'rental/merci.html' return context, template else: + form.add_error(None, ValidationError( + _("Cet hébergement n'est pas disponible aux dates indiquées."), + code='invalid' + )) context = {'form': form} template = 'rental/reservation.html' return context, template