mirror of
https://github.com/rjNemo/villafleurie
synced 2026-06-12 13:26:47 +00:00
add send_confirmation and send_notificaiton methods to contact; add send_quotation method to booking; inject services in models and decoupled views
This commit is contained in:
parent
835fd664bf
commit
fed5732204
4 changed files with 30 additions and 23 deletions
|
|
@ -3,6 +3,7 @@ from django.db import models
|
||||||
from rental.models.guest import Guest
|
from rental.models.guest import Guest
|
||||||
from rental.models.place import Place
|
from rental.models.place import Place
|
||||||
import rental.services.calendar as calendar
|
import rental.services.calendar as calendar
|
||||||
|
import rental.tasks.apiMailer as mailer # or gMailer
|
||||||
|
|
||||||
|
|
||||||
class BookingManager(models.Manager):
|
class BookingManager(models.Manager):
|
||||||
|
|
@ -45,3 +46,6 @@ class Booking(models.Model):
|
||||||
nights = (self.end - self.start).days
|
nights = (self.end - self.start).days
|
||||||
|
|
||||||
return self.place.price * nights
|
return self.place.price * nights
|
||||||
|
|
||||||
|
def send_quotation(self):
|
||||||
|
mailer.send_quotation.delay(self.guest.name, self.guest.email)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
import rental.tasks.apiMailer as mailer # or gMailer
|
||||||
|
|
||||||
|
|
||||||
class Contact(models.Model):
|
class Contact(models.Model):
|
||||||
|
|
@ -12,3 +12,15 @@ class Contact(models.Model):
|
||||||
subject = models.EmailField(max_length=50)
|
subject = models.EmailField(max_length=50)
|
||||||
message = models.TextField(max_length=50)
|
message = models.TextField(max_length=50)
|
||||||
date = models.DateTimeField(auto_now_add=True)
|
date = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
|
def send_confirmation(self):
|
||||||
|
mailer.send_confirmation.delay(self.name, self.email)
|
||||||
|
|
||||||
|
def send_notification(self):
|
||||||
|
mailer.send_notification.delay(
|
||||||
|
self.name,
|
||||||
|
self.email,
|
||||||
|
self.subject,
|
||||||
|
self.message,
|
||||||
|
self.date
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@
|
||||||
mixpanel.init("fd38f05cab7987b17dfa3aac4ff1a032");
|
mixpanel.init("fd38f05cab7987b17dfa3aac4ff1a032");
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<title>VillaFleurie</title>
|
<title>VillaFleurie – Locations de vacances</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" />
|
||||||
<meta content="" name="description" />
|
<meta content="" name="description" />
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,8 @@ from rental.forms import ReservationForm, ContactForm
|
||||||
from rental.models.booking import Booking
|
from rental.models.booking import Booking
|
||||||
from rental.models.contact import Contact
|
from rental.models.contact import Contact
|
||||||
from rental.models.guest import Guest
|
from rental.models.guest import Guest
|
||||||
from rental.models.picture import Picture
|
|
||||||
from rental.models.place import Place
|
from rental.models.place import Place
|
||||||
from rental.models.testimonial import Testimonial
|
from rental.models.testimonial import Testimonial
|
||||||
from rental.services.calendar import check_availability, synchronize_calendars, update
|
|
||||||
from rental.tasks.apiMailer import * # or gMailer
|
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
|
|
@ -79,7 +76,6 @@ def handle_reservation_form(request, context={}, init_template='rental/reservati
|
||||||
guest = guest.first()
|
guest = guest.first()
|
||||||
|
|
||||||
place = get_object_or_404(Place, name=place_name)
|
place = get_object_or_404(Place, name=place_name)
|
||||||
# available = check_availability(place, )
|
|
||||||
|
|
||||||
if place.is_available(start, end):
|
if place.is_available(start, end):
|
||||||
reservation = Booking.objects.create_booking(
|
reservation = Booking.objects.create_booking(
|
||||||
|
|
@ -89,7 +85,8 @@ def handle_reservation_form(request, context={}, init_template='rental/reservati
|
||||||
start=start,
|
start=start,
|
||||||
end=end
|
end=end
|
||||||
)
|
)
|
||||||
send_quotation.delay(name, email)
|
|
||||||
|
reservation.send_quotation()
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'reservation': reservation
|
'reservation': reservation
|
||||||
|
|
@ -144,14 +141,8 @@ def contact(request):
|
||||||
message=form.cleaned_data['message']
|
message=form.cleaned_data['message']
|
||||||
)
|
)
|
||||||
|
|
||||||
send_confirmation.delay(contact.name, contact.email)
|
contact.send_confirmation()
|
||||||
send_notification.delay(
|
contact.send_notification()
|
||||||
contact.name,
|
|
||||||
contact.email,
|
|
||||||
contact.subject,
|
|
||||||
contact.message,
|
|
||||||
contact.date
|
|
||||||
)
|
|
||||||
|
|
||||||
return render(request, 'rental/contact_merci.html', {})
|
return render(request, 'rental/contact_merci.html', {})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue