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
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function(c, a) {
|
(function (c, a) {
|
||||||
if (!a.__SV) {
|
if (!a.__SV) {
|
||||||
var b = window;
|
var b = window;
|
||||||
try {
|
try {
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
j,
|
j,
|
||||||
k = b.location,
|
k = b.location,
|
||||||
f = k.hash;
|
f = k.hash;
|
||||||
d = function(a, b) {
|
d = function (a, b) {
|
||||||
return (m = a.match(RegExp(b + "=([^&]*)"))) ? m[1] : null;
|
return (m = a.match(RegExp(b + "=([^&]*)"))) ? m[1] : null;
|
||||||
};
|
};
|
||||||
f &&
|
f &&
|
||||||
|
|
@ -49,24 +49,24 @@
|
||||||
var l, h;
|
var l, h;
|
||||||
window.mixpanel = a;
|
window.mixpanel = a;
|
||||||
a._i = [];
|
a._i = [];
|
||||||
a.init = function(b, d, g) {
|
a.init = function (b, d, g) {
|
||||||
function c(b, i) {
|
function c(b, i) {
|
||||||
var a = i.split(".");
|
var a = i.split(".");
|
||||||
2 == a.length && ((b = b[a[0]]), (i = a[1]));
|
2 == a.length && ((b = b[a[0]]), (i = a[1]));
|
||||||
b[i] = function() {
|
b[i] = function () {
|
||||||
b.push([i].concat(Array.prototype.slice.call(arguments, 0)));
|
b.push([i].concat(Array.prototype.slice.call(arguments, 0)));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var e = a;
|
var e = a;
|
||||||
"undefined" !== typeof g ? (e = a[g] = []) : (g = "mixpanel");
|
"undefined" !== typeof g ? (e = a[g] = []) : (g = "mixpanel");
|
||||||
e.people = e.people || [];
|
e.people = e.people || [];
|
||||||
e.toString = function(b) {
|
e.toString = function (b) {
|
||||||
var a = "mixpanel";
|
var a = "mixpanel";
|
||||||
"mixpanel" !== g && (a += "." + g);
|
"mixpanel" !== g && (a += "." + g);
|
||||||
b || (a += " (stub)");
|
b || (a += " (stub)");
|
||||||
return a;
|
return a;
|
||||||
};
|
};
|
||||||
e.people.toString = function() {
|
e.people.toString = function () {
|
||||||
return e.toString(1) + ".people (stub)";
|
return e.toString(1) + ".people (stub)";
|
||||||
};
|
};
|
||||||
l = "disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(
|
l = "disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(
|
||||||
|
|
@ -74,9 +74,9 @@
|
||||||
);
|
);
|
||||||
for (h = 0; h < l.length; h++) c(e, l[h]);
|
for (h = 0; h < l.length; h++) c(e, l[h]);
|
||||||
var f = "set set_once union unset remove delete".split(" ");
|
var f = "set set_once union unset remove delete".split(" ");
|
||||||
e.get_group = function() {
|
e.get_group = function () {
|
||||||
function a(c) {
|
function a(c) {
|
||||||
b[c] = function() {
|
b[c] = function () {
|
||||||
call2_args = arguments;
|
call2_args = arguments;
|
||||||
call2 = [c].concat(Array.prototype.slice.call(call2_args, 0));
|
call2 = [c].concat(Array.prototype.slice.call(call2_args, 0));
|
||||||
e.push([d, call2]);
|
e.push([d, call2]);
|
||||||
|
|
@ -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