diff --git a/README.md b/README.md index b1f0e8c..a53e441 100644 --- a/README.md +++ b/README.md @@ -29,15 +29,17 @@ Le visiteur doit pouvoir : ### Back-end -- `Django 3.0` -- `PostgreSQL` +- `Django 3.0` python based web application +- `PostgreSQL` object-relational database +- `Celery` asynchronous task queue +- `RabbitMQ` messaging broker +- `NginX` reverse-proxy & static files server - `Docker` -- `NginX` - Google Calendar API ### Hébergement -- Virtual Private Server +- VPS on [Vultr](https://my.vultr.com/subs/?SUBID=32140017) ## Pages @@ -98,8 +100,8 @@ 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) +- 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 - ajouter les témoignages depuis Booking, AirBnb, ajouter le lien @@ -117,8 +119,10 @@ 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 ? -- Confirmation message contact envoyé +- Page confirmation message contact envoyé +- SSL certificate ## BUGS - La synchro ne gère pas les heures dans le calendriers +- Bouton réserver dans la Navbar … diff --git a/docker-compose.yml b/docker-compose.yml index 6168739..e60cc64 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ volumes: services: db: - image: postgres + image: postgres:alpine environment: POSTGRES_USER: villafleurie POSTGRES_DB: villafleurie @@ -16,7 +16,8 @@ services: - dbdata:/var/lib/postgresql/data ports: - 5432:5432 - web: + + 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" @@ -28,7 +29,10 @@ services: - "8000:8000" depends_on: - db + - rabbitmq + - celery env_file: prod.env + nginx: build: context: . @@ -40,3 +44,14 @@ services: - media:/media depends_on: - web + + celery: + <<: *web + command: celery -A villafleurie worker --loglevel=info + ports: [] + depends_on: + - rabbitmq + - db + + rabbitmq: + image: rabbitmq:alpine diff --git a/rental/static/rental/img/favicon.png b/rental/static/rental/img/favicon.ico similarity index 100% rename from rental/static/rental/img/favicon.png rename to rental/static/rental/img/favicon.ico diff --git a/rental/mailing.py b/rental/tasks.py similarity index 91% rename from rental/mailing.py rename to rental/tasks.py index 75967fe..6635178 100644 --- a/rental/mailing.py +++ b/rental/tasks.py @@ -1,12 +1,11 @@ +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 import os -# from celery import Celery - -# app = Celery('mailing', brocker='amqp://localhost/') -# @app.task +@shared_task def send_confirmation_mail(name, email, template="ticket"): """ Send confirmation message to customer """ subject = "Nous avons reçu votre message" @@ -25,6 +24,7 @@ def send_confirmation_mail(name, email, template="ticket"): ) +@shared_task def send_notification(subject, name, message, template="activation"): """ Send notification to admins """ html_path = os.path.join(BASE_DIR, 'rental/templates/rental/html/') @@ -38,6 +38,7 @@ def send_notification(subject, name, message, template="activation"): ) +@shared_task def send_quotation(reservation): """ Send quotation to customer """ name = reservation.guest.name diff --git a/rental/templates/rental/404.html b/rental/templates/rental/404.html index e69de29..658c3bf 100644 --- a/rental/templates/rental/404.html +++ b/rental/templates/rental/404.html @@ -0,0 +1,43 @@ +{% extends 'rental/base.html' %} {% load static %} {% block content %} + +
+
+
+
+
+

Oups ! Il n'y a rien ici …

+ Merci pour votre visite +
+
+
+ +
+
+
+
+ +
+
+
+
+ +{% endblock %} diff --git a/rental/templates/rental/contact.html b/rental/templates/rental/contact.html index 5a0f8ad..947532f 100644 --- a/rental/templates/rental/contact.html +++ b/rental/templates/rental/contact.html @@ -72,7 +72,7 @@

- ✉️Email : + ✉️ Email : location.villafleurie@gmail.com

- 📞Téléphone : + 📞 Téléphone : 06 98 26 76 34 diff --git a/rental/templates/rental/reservation.html b/rental/templates/rental/reservation.html index fd467dd..2ea412b 100644 --- a/rental/templates/rental/reservation.html +++ b/rental/templates/rental/reservation.html @@ -1,83 +1,118 @@ -{% extends 'rental/base.html'%} -{% load static %} +{% extends 'rental/base.html'%} {% load static %} {% block content %} -{% block content %} - - -

-
-
-
-
-

Réservation

- Vous souhaiter effectuer une demande de réservation ? - Vous avez des questions, des suggestions d’amélioration ou des commentaires ? -
Laissez-nous un message !
-
-
-
- +
+
+
+
+
+

Réservation

+ Vous souhaiter effectuer une demande de réservation ? Vous avez des + questions, des suggestions d’amélioration ou des commentaires ? +
Laissez-nous un message !
+
+ +
-
- - - + - - {% include 'rental/reservation_form.html' %} - - -{% endblock %} +{% include 'rental/reservation_form.html' %} {% endblock %} diff --git a/rental/views.py b/rental/views.py index 2204d13..0e7995c 100644 --- a/rental/views.py +++ b/rental/views.py @@ -7,7 +7,7 @@ from .forms import ReservationForm, ContactForm from django.db import IntegrityError from rental.pricing import get_reservation_price from rental.bookings import check_availability, synchronize_calendars, update_calendar -from rental.mailing import send_confirmation_mail, send_notification, send_quotation +from rental.tasks import send_confirmation_mail, send_notification, send_quotation def index(request): @@ -123,8 +123,8 @@ def reservation(request): end=end, price=price ) - send_quotation(reservation) - update_calendar(reservation) + send_quotation.delay(reservation) + update_calendar(reservation) # add to celery tasks too context = { 'reservation': reservation } @@ -166,8 +166,8 @@ def contact(request): subject = form.cleaned_data['subject'] message = form.cleaned_data['message'] - send_confirmation_mail(name, email) - send_notification(subject, name, message) + send_confirmation_mail.delay(name, email) + send_notification.delay(subject, name, message) else: form = ContactForm() context = {'form': form} diff --git a/villafleurie/__init__.py b/villafleurie/__init__.py index e69de29..d51fd28 100644 --- a/villafleurie/__init__.py +++ b/villafleurie/__init__.py @@ -0,0 +1,4 @@ +from __future__ import absolute_import, unicode_literals +from .celery import app as celery_app + +__all__ = ('celery_app',) diff --git a/villafleurie/celery.py b/villafleurie/celery.py new file mode 100644 index 0000000..0584dc6 --- /dev/null +++ b/villafleurie/celery.py @@ -0,0 +1,14 @@ +from __future__ import absolute_import, unicode_literals +import os +from celery import Celery + + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'villafleurie.settings') +app = Celery('villafleurie') +app.config_from_object('django.conf:settings', namespace='CELERY') +app.autodiscover_tasks() + + +@app.task(bind=True) +def debug_task(self): + print('Request: {0!r}'.format(self.request)) diff --git a/villafleurie/settings.py b/villafleurie/settings.py index 24d3865..2d22415 100644 --- a/villafleurie/settings.py +++ b/villafleurie/settings.py @@ -137,7 +137,6 @@ USE_TZ = True STATIC_URL = '/static/' STATIC_ROOT = "/static_files/" -# MEDIA_ROOT = os.path.join(BASE_DIR, "media") MEDIA_URL = '/media/' MEDIA_ROOT = '/media/' @@ -148,3 +147,5 @@ EMAIL_SUBJECT_PREFIX = "[VillaFleurieGuadeloupe] " DEFAULT_FROM_EMAIL = "'Nilka, VillaFleurie' " EMAIL_HOST_USER = "location.villafleurie@gmail.com" EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD') + +CELERY_BROKER_URL = "amqp://rabbitmq"