This commit is contained in:
Ruidy Nemausat 2020-03-31 15:49:56 +02:00
parent 58f400d5e7
commit 7c28500c8f
4 changed files with 26 additions and 3 deletions

View file

@ -1,14 +1,13 @@
import datetime
from rental.pricing import get_reservation_price from rental.pricing import get_reservation_price
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from rental.models import Reservation, Place, Guest from rental.models import Reservation, Place, Guest
from villafleurie.settings import BASE_DIR
import datetime import datetime
from google.auth.transport.requests import Request from google.auth.transport.requests import Request
from google_auth_oauthlib.flow import InstalledAppFlow from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build from googleapiclient.discovery import build
import os.path import os.path
import pickle import pickle
from villafleurie.settings import BASE_DIR
def build_calendar_api_service(): def build_calendar_api_service():
@ -151,3 +150,7 @@ def update_calendar(reservation):
}, },
} }
).execute() ).execute()
if __name__ == '__main__':
s, c = build_calendar_api_service()

View file

@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals
from celery import shared_task from celery import shared_task
from villafleurie.settings import EMAIL_HOST_USER, DEFAULT_FROM_EMAIL from villafleurie.settings import EMAIL_HOST_USER, DEFAULT_FROM_EMAIL
import requests import requests
from datetime import datetime
""" Mailer Service used to send messages using API WebHooks. """ Mailer Service used to send messages using API WebHooks.
All Mailers must implement the following methods: All Mailers must implement the following methods:
@ -51,4 +52,13 @@ def send_notification(name, email, subject, message, date):
@shared_task @shared_task
def send_quotation(name, email): def send_quotation(name, email):
""" Send quotation to customer """ """ Send quotation to customer """
send_notification(
name,
email,
"Nouvelle demande de réservation",
"Depuis le site",
datetime.now()
)
send_confirmation(name, email) send_confirmation(name, email)

View file

@ -4,6 +4,10 @@
<html lang="fr"> <html lang="fr">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta
name="google-site-verification"
content="_VvUrAmbWy8dYj9sy2wePTF-ACH7ASdZLzDzScH9Lmo"
/>
<title>VillaFleurie</title> <title>VillaFleurie</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport" /> <meta content="width=device-width, initial-scale=1.0" name="viewport" />
<meta content="" name="keywords" /> <meta content="" name="keywords" />

View file

@ -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.db import IntegrityError
from django.shortcuts import render, get_object_or_404
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django.utils.translation import gettext_lazy as _
from rental.forms import ReservationForm, ContactForm from rental.forms import ReservationForm, ContactForm
from rental.models import Testimonial, Reservation, Guest, Place, Contact from rental.models import Testimonial, Reservation, Guest, Place, Contact
from rental.pricing import get_reservation_price 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' template = 'rental/merci.html'
return context, template return context, template
else: else:
form.add_error(None, ValidationError(
_("Cet hébergement n'est pas disponible aux dates indiquées."),
code='invalid'
))
context = {'form': form} context = {'form': form}
template = 'rental/reservation.html' template = 'rental/reservation.html'
return context, template return context, template