Exemplo n.º 1
0
def declineBooking(request, pk):
    if request.method == "POST":
        b = get_object_or_404(Booking, pk=pk)
        f = BookingForm(request.POST)
        f.id = pk
        #send email notification
        subject = "East Scarborough Storefront - Booking Approved"
        message = "Dear " + b.booker.username + ",\n\nYour booking request '" + b.name + "' at East Scarborough Storefront has been declined.\nPlease call the Storefront for more details.\n\nThank you"
        b.booker.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
        b.delete()
        return render(request, 'juakstore/admin_declineBooking.html')
    else:
        form = BookingForm()
        return HttpResponseRedirect(reverse('juakstore/admin_declineBooking.html', args=(pk,)))
Exemplo n.º 2
0
def acceptBooking(request, pk):
    if request.method == "POST":
        b = get_object_or_404(Booking, pk=pk)
        f = BookingForm(request.POST)
        f.id = pk
        
        b.approved = True
        b.save()
        #send email notification
        subject = "East Scarborough Storefront - Booking Approved"
        current_site = Site.objects.get_current()        
        text_content = "Dear " + b.booker.username + ",\n\nYour booking request '" + b.name + "' at East Scarborough Storefront has been approved.\nYou can login at " + current_site.name + ".\n\nThank you"
        html_content = 'Dear ' + b.booker.username + ',<br><br>Your booking request ' + b.name + ' at East Scarborough Storefront has been approved.<br>You can login at <a href="http://' + current_site.domain + '">' + current_site.name + '</a>.<br><br>Thank you'
        msg = EmailMultiAlternatives(subject, text_content, settings.DEFAULT_FROM_EMAIL, [b.booker.email])
        msg.attach_alternative(html_content, "text/html")
        msg.send()          
        return render(request, 'juakstore/admin_acceptBooking.html', {'booking': b})
    else:
        form = BookingForm()
        return HttpResponseRedirect(reverse('juakstore/admin_acceptBooking.html', args=(pk,)))