mirror of
https://github.com/rjNemo/villafleurie
synced 2026-06-06 02:16:47 +00:00
calendar api request
This commit is contained in:
parent
eea16b3eb0
commit
c9ce373a4d
7 changed files with 18 additions and 22 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Villafleurie : moteur de réservation autonome
|
||||
|
||||
`V 0.1 Le site est structuré. Il reste à appliquer le contenu et les visuels`
|
||||
`V 1.0 Le site est prêt à l'emploi`
|
||||
|
||||
Auteur : Ruidy Nemausat
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ Le visiteur doit pouvoir :
|
|||
1. Page d'accueil
|
||||
|
||||
- Landing page
|
||||
- CTA = "Réserver maintenant"
|
||||
- CTA = "Réserver"
|
||||
|
||||
2. Page logement
|
||||
|
||||
|
|
@ -99,8 +99,6 @@ Le visiteur doit pouvoir :
|
|||
|
||||
## TO DO
|
||||
|
||||
- Gestion du calendrier
|
||||
- Tester la synchro avec Google calendar
|
||||
- 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)
|
||||
- Ajout page/module de paiement
|
||||
|
|
@ -119,7 +117,7 @@ Le visiteur doit pouvoir :
|
|||
- Système de facturation: CRUD Réservations et envoi. Automatisation si possible
|
||||
- Réservation page : Ajouter des photos. Renvoyer vers la page Location onClick sur Réserver TX. Proposer Upsells : navette + location voiture.
|
||||
- Vider le contenu du folder root ?
|
||||
- Page confirmation message contact envoyé
|
||||
- Pages confirmation message contact envoyé, reservations réussies ou non (expliquer pourquoi)
|
||||
- SSL certificate
|
||||
|
||||
## BUGS
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ services:
|
|||
|
||||
web: &web
|
||||
build: .
|
||||
# command: bash -c "python manage.py migrate && python manage.py loaddata villafleurie.json && gunicorn -w 4 villafleurie.wsgi -b 0.0.0.0:8000"
|
||||
command: bash -c "python manage.py migrate && gunicorn -w 4 villafleurie.wsgi -b 0.0.0.0:8000"
|
||||
volumes:
|
||||
- .:/villafleurie
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@ def build_calendar_api_service():
|
|||
|
||||
creds = None
|
||||
# If modifying these scopes, delete the file token.pickle.
|
||||
SCOPES = ['https://www.googleapis.com/auth/calendar']
|
||||
SCOPES = [
|
||||
'https://www.googleapis.com/auth/calendar',
|
||||
'https://www.googleapis.com/auth/calendar.events'
|
||||
]
|
||||
# The file token.pickle stores the user's access and refresh tokens, and is
|
||||
# created automatically when the authorization flow completes for the first
|
||||
# time.
|
||||
|
|
@ -42,7 +45,6 @@ def build_calendar_api_service():
|
|||
'T2': "burik7aclvhc7vsboh06c179uo@group.calendar.google.com",
|
||||
'T3': "fu7h30p0gk4a2p4nvo7nsbgpok@group.calendar.google.com"
|
||||
}
|
||||
|
||||
return service, calendars
|
||||
|
||||
|
||||
|
|
@ -117,7 +119,6 @@ def get_bookings(place):
|
|||
|
||||
synchronize_calendars(place)
|
||||
booked_dates = Reservation.objects.filter(place=place)
|
||||
# if booking.place.name == f"{place.name}"]
|
||||
return [booking for booking in booked_dates]
|
||||
|
||||
|
||||
|
|
@ -134,7 +135,6 @@ def check_availability(place, start_date, end_date):
|
|||
def update_calendar(reservation):
|
||||
""" push new reservation to master calendar """
|
||||
# authenticate and build service
|
||||
# event.insert(calendarId, summary="Guest", description="Message", end, start )
|
||||
service, calendars = build_calendar_api_service()
|
||||
start = reservation.start.strftime('%Y-%m-%d')
|
||||
end = reservation.end.strftime('%Y-%m-%d')
|
||||
|
|
@ -151,8 +151,8 @@ def update_calendar(reservation):
|
|||
"date": end
|
||||
},
|
||||
}
|
||||
)
|
||||
).execute()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
update_calendar(reservation)
|
||||
# if __name__ == "__main__":
|
||||
# update_calendar(reservation)
|
||||
|
|
|
|||
|
|
@ -54,14 +54,14 @@ class ReservationForm(forms.Form):
|
|||
# min_length=4,
|
||||
widget=forms.DateInput(attrs={
|
||||
'class': 'form-control form-control-lg form-control-a',
|
||||
'placeholder': 'Début *'}),
|
||||
'placeholder': '01/01/2020 *'}),
|
||||
required=True)
|
||||
end = forms.DateField(
|
||||
label='',
|
||||
input_formats=['%d/%m/%Y'],
|
||||
widget=forms.DateInput(attrs={
|
||||
'class': 'form-control form-control-lg form-control-a',
|
||||
'placeholder': 'Fin *'}),
|
||||
'placeholder': '31/12/2020 *'}),
|
||||
required=True)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals
|
|||
from celery import shared_task
|
||||
from django.core.mail import send_mail, mail_admins
|
||||
from villafleurie.settings import EMAIL_HOST_USER, BASE_DIR
|
||||
from rental.bookings import build_calendar_api_service
|
||||
import os
|
||||
|
||||
|
||||
|
|
@ -30,7 +31,6 @@ def send_notification(subject, name, message, template="activation"):
|
|||
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()
|
||||
|
||||
mail_admins(
|
||||
f"{name} a envoyé un message",
|
||||
f"Sujet : {subject}\nMessage : {message}",
|
||||
|
|
@ -39,8 +39,6 @@ def send_notification(subject, name, message, template="activation"):
|
|||
|
||||
|
||||
@shared_task
|
||||
def send_quotation(reservation):
|
||||
def send_quotation(name, email):
|
||||
""" Send quotation to customer """
|
||||
name = reservation.guest.name
|
||||
email = list(reservation.guest.email)
|
||||
send_confirmation_mail(name, email, template="welcome")
|
||||
|
|
|
|||
|
|
@ -123,12 +123,11 @@ def reservation(request):
|
|||
end=end,
|
||||
price=price
|
||||
)
|
||||
send_quotation.delay(reservation)
|
||||
update_calendar(reservation) # add to celery tasks too
|
||||
send_quotation.delay(name, email)
|
||||
update_calendar(reservation)
|
||||
context = {
|
||||
'reservation': reservation
|
||||
}
|
||||
|
||||
return render(request, 'rental/merci.html', context)
|
||||
else:
|
||||
context = {'form': form}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ ADMINS = [
|
|||
]
|
||||
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY')
|
||||
# SECRET_KEY = "q00_4wqdc^n=7)p2lm)!gy&fms8md_b4#1aqysllvqq==2c9!$"
|
||||
|
||||
if os.environ.get('ENV') == 'PRODUCTION':
|
||||
DEBUG = False
|
||||
|
|
@ -147,5 +148,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"
|
||||
|
||||
CELERY_BROKER_URL = "amqp://rabbitmq"
|
||||
|
|
|
|||
Loading…
Reference in a new issue