mail templates

This commit is contained in:
Ruidy Nemausat 2020-01-03 18:06:04 +01:00
parent c9ce373a4d
commit e8ea95fc87
18 changed files with 16 additions and 16 deletions

View file

@ -99,8 +99,8 @@ Le visiteur doit pouvoir :
## TO DO
- Ajouter un date picker dans le formulaire de réservation, changer les placeholders (j'ai pas envie de jouer avec JQuery)
- Envoyer devis réservation par mail et notification aux hôtes (put it in a background process, personnaliser les htmails : contact, admin et réservation)
- Ajouter un date picker dans le formulaire de réservation
- Envoyer devis réservation par mail et notification aux hôtes (personnaliser les htmails : contact, admin et réservation)
- Ajout page/module de paiement
- ajouter les témoignages depuis Booking, AirBnb, ajouter le lien
- changer l'adresse de l'admin, personnaliser le back-end (design et les infos displayed per model)

View file

@ -13,7 +13,6 @@ from villafleurie.settings import BASE_DIR
def build_calendar_api_service():
""" Build Google Calendar API service and returns calendar list and service """
creds = None
# If modifying these scopes, delete the file token.pickle.
SCOPES = [
@ -38,9 +37,7 @@ def build_calendar_api_service():
# Save the credentials for the next run
with open('token.pickle', 'wb') as token:
pickle.dump(creds, token)
service = build('calendar', 'v3', credentials=creds)
calendars = {
'T2': "burik7aclvhc7vsboh06c179uo@group.calendar.google.com",
'T3': "fu7h30p0gk4a2p4nvo7nsbgpok@group.calendar.google.com"
@ -51,7 +48,6 @@ def build_calendar_api_service():
def get_calendar_reservations(place):
service, calendars = build_calendar_api_service()
now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time
events_result = service.events().list(
calendarId=calendars[place.name],
timeMin=now,
@ -76,7 +72,6 @@ def synchronize_calendars(place):
""" Get a complete list of existing bookings in calendar
Creates reservation if not in db, update if already in db
Delete from db reservation deleted from cal """
reservation = get_calendar_reservations(place)
place = get_object_or_404(Place, name=place.name)
price = get_reservation_price(
@ -86,17 +81,14 @@ def synchronize_calendars(place):
)
start = reservation['start']
end = reservation['end']
guest = Guest.objects.filter(name=reservation['guest'])
if not guest.exists():
guest = Guest.objects.create(name=reservation['guest'])
else:
guest = guest.first()
db_booking = Reservation.objects.filter(
guest=guest
)
if not db_booking.exists():
Reservation.objects.create(
place=place,
@ -116,7 +108,6 @@ def synchronize_calendars(place):
def get_bookings(place):
""" Synchronize with Master calendar via a call to synchronize_calendar
Returns a list of all related place reservations """
synchronize_calendars(place)
booked_dates = Reservation.objects.filter(place=place)
return [booking for booking in booked_dates]
@ -124,7 +115,6 @@ def get_bookings(place):
def check_availability(place, start_date, end_date):
""" check if the related place is available during a given period """
bookings = get_bookings(place)
for booking in bookings:
if (booking.start <= start_date <= booking.end) or (booking.start <= end_date <= booking.end):

View file

@ -1,6 +1,7 @@
from __future__ import absolute_import, unicode_literals
from celery import shared_task
from django.core.mail import send_mail, mail_admins
from django.shortcuts import render
from villafleurie.settings import EMAIL_HOST_USER, BASE_DIR
from rental.bookings import build_calendar_api_service
import os
@ -11,16 +12,24 @@ def send_confirmation_mail(name, email, template="ticket"):
""" Send confirmation message to customer """
subject = "Nous avons reçu votre message"
message = f" Merci {name}, Bien reçu nous revenons vers vous rapidement ! - HtmlMessage"
html_path = os.path.join(BASE_DIR, 'rental/templates/rental/html/')
with open(os.path.join(html_path, f"{template}.html"), 'r') as html:
html_message = html.read()
# html_path = os.path.join(
# 'rental/templates/rental/mails/', f"{template}.html")
# context = {
# "name": name,
# "email": email,
# "message": message
# }
# html_message = render(request, html_path, context)
send_mail(
subject,
message,
EMAIL_HOST_USER,
[email],
# html_message=html_message.content
html_message=html_message
)

View file

@ -100,7 +100,7 @@
<body style="background-color:#f8f8f8;">
<div style="background-color:#f8f8f8;">
<div style="Margin:0px auto;max-width:600px;">
<div style="Margin:0px auto;max-width:600px;">
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
<tbody>
<tr>

View file

@ -8,7 +8,8 @@ ADMINS = [
]
SECRET_KEY = os.environ.get('SECRET_KEY')
# SECRET_KEY = "q00_4wqdc^n=7)p2lm)!gy&fms8md_b4#1aqysllvqq==2c9!$"
SECRET_KEY = "q00_4wqdc^n=7)p2lm)!gy&fms8md_b4#1aqysllvqq==2c9!$"
if os.environ.get('ENV') == 'PRODUCTION':
DEBUG = False
@ -148,6 +149,6 @@ EMAIL_SUBJECT_PREFIX = "[VillaFleurieGuadeloupe] "
DEFAULT_FROM_EMAIL = "'Nilka, VillaFleurie' <location.villaFleurie@gmail.com>"
EMAIL_HOST_USER = "location.villafleurie@gmail.com"
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
# EMAIL_HOST_PASSWORD = "location229818"
EMAIL_HOST_PASSWORD = "location229818"
CELERY_BROKER_URL = "amqp://rabbitmq"