Esempio n. 1
0
def send_admissions_booking_confirmation(admissionsBooking, request, context_processor):
    email_obj = TemplateEmailBase()

    admissionsLine = AdmissionsLine.objects.get(admissionsBooking=admissionsBooking)
    subject = 'Admission Fee Payment Confirmation {} on {}'.format(admissionsBooking.confirmation_number,admissionsLine.arrivalDate)
    template = 'mooring/email/admissions_confirmation.html'
    cc = None
    bcc = None
    from_email = None
    template_group = context_processor['TEMPLATE_GROUP']

#    email_obj.subject = 'Admission Fee Payment Confirmation {} on {}'.format(admissionsBooking.confirmation_number,admissionsLine.arrivalDate)
#    email_obj.html_template = 'mooring/email/admissions_confirmation.html'
#    email_obj.txt_template = 'mooring/email/admissions_confirmation.txt'
    email = admissionsBooking.customer.email
    #bcc = [default_rottnest_email]
#    rottnest_email = default_rottnest_email
    #rottnest_email = default_from_email
    my_bookings_url = request.build_absolute_uri('/mybookings/')

    context = {
        'booking': admissionsBooking,
        'my_bookings': my_bookings_url
    }
    att = BytesIO()
    pdf.create_admissions_confirmation(att, admissionsBooking, context_processor)
    att.seek(0)
#    filename = 'confirmation-AD{}({}).pdf'.format(admissionsBooking.id, admissionsBooking.customer.get_full_name())
#    email_obj.send([email], from_address=rottnest_email, context=context, cc=cc, bcc=bcc, attachments=[(filename, att.read(), 'application/pdf')])

    sendHtmlEmail([email],subject,context,template,cc,bcc,from_email,template_group,attachments=[('confirmation-AD{}.pdf'.format(admissionsBooking.id), att.read(), 'application/pdf')])
Esempio n. 2
0
def send_admissions_booking_confirmation(admissionsBooking, context_processor):
    email_obj = TemplateEmailBase()

    admissionsLine = AdmissionsLine.objects.get(admissionsBooking=admissionsBooking)
    subject = 'Admission Fee Payment Confirmation {} on {}'.format(admissionsBooking.confirmation_number,admissionsLine.arrivalDate)
    template = 'mooring/email/admissions_confirmation.html'
    cc = None
    bcc = None
    from_email = None
    template_group = context_processor['TEMPLATE_GROUP']

#    email_obj.subject = 'Admission Fee Payment Confirmation {} on {}'.format(admissionsBooking.confirmation_number,admissionsLine.arrivalDate)
#    email_obj.html_template = 'mooring/email/admissions_confirmation.html'
#    email_obj.txt_template = 'mooring/email/admissions_confirmation.txt'
    email = admissionsBooking.customer.email
    #bcc = [default_rottnest_email]
#    rottnest_email = default_rottnest_email
    #rottnest_email = default_from_email
    my_bookings_url = context_processor['PUBLIC_URL']+'/mybookings/'

    context = {
        'booking': admissionsBooking,
        'my_bookings': my_bookings_url,
        'context_processor': context_processor
    }
    att = BytesIO()
    pdf.create_admissions_confirmation(att, admissionsBooking, context_processor)
    att.seek(0)
#    filename = 'confirmation-AD{}({}).pdf'.format(admissionsBooking.id, admissionsBooking.customer.get_full_name())
#    email_obj.send([email], from_address=rottnest_email, context=context, cc=cc, bcc=bcc, attachments=[(filename, att.read(), 'application/pdf')])

    sendHtmlEmail([email],subject,context,template,cc,bcc,from_email,template_group,attachments=[('confirmation-AD{}.pdf'.format(admissionsBooking.id), att.read(), 'application/pdf')])
Esempio n. 3
0
def send_booking_confirmation(booking, request, context_processor):
    email_obj = TemplateEmailBase()
    email_obj.subject = 'Your booking {} at {} is confirmed'.format(
        booking.confirmation_number, booking.mooringarea.name)
    email_obj.html_template = 'mooring/email/confirmation.html'
    email_obj.txt_template = 'mooring/email/confirmation.txt'
    from_email = None
    email = booking.customer.email

    template = 'mooring/email/booking_confirmation.html'

    cc = None
    bcc = [default_campground_email]
    template_group = context_processor['TEMPLATE_GROUP']

    #campground_email = booking.mooringarea.email if booking.mooringarea.email else default_campground_email
    campground_email = default_from_email
    if campground_email != default_campground_email:
        cc = [campground_email]

    my_bookings_url = context_processor['PUBLIC_URL'] + '/mybookings/'
    #booking_availability = request.build_absolute_uri('/availability/?site_id={}'.format(booking.mooringarea.id))
    unpaid_vehicle = False
    mobile_number = booking.customer.mobile_number
    booking_number = booking.details.get('phone', None)
    phone_number = booking.customer.phone_number
    tel = None

    if booking_number:
        tel = booking_number
    elif mobile_number:
        tel = mobile_number
    else:
        tel = phone_number
    tel = tel if tel else ''

    for v in booking.vehicle_payment_status:
        if v.get('Paid') == 'No':
            unpaid_vehicle = True
            break
    additional_info = booking.mooringarea.additional_info if booking.mooringarea.additional_info else ''

    msbs = MooringsiteBooking.objects.filter(booking=booking)
    contact_list = []
    moorings = []
    for m in msbs:
        if m.campsite.mooringarea not in moorings:
            moorings.append(m.campsite.mooringarea)
            contact = m.campsite.mooringarea.contact
            if not any(c['email'] == contact.email
                       for c in contact_list) or not any(
                           c['phone'] == contact.phone_number
                           for c in contact_list):
                line = {
                    'moorings': m.campsite.mooringarea.name,
                    'email': contact.email,
                    'phone': contact.phone_number
                }
                contact_list.append(line)
            else:
                index = next((index for (index, d) in enumerate(contact_list)
                              if d['email'] == contact.email), None)
                contact_list[index][
                    'moorings'] += ', ' + m.campsite.mooringarea.name

    context = {
        'booking': booking,
        'phone_number': tel,
        'campground_email': campground_email,
        'my_bookings': my_bookings_url,
        #'availability': booking_availability,
        'unpaid_vehicle': unpaid_vehicle,
        'additional_info': additional_info,
        'contact_list': contact_list,
        'context_processor': context_processor
    }

    att = BytesIO()
    mooring_booking = []
    if MooringsiteBooking.objects.filter(booking=booking).count() > 0:
        mooring_booking = MooringsiteBooking.objects.filter(booking=booking)
    pdf.create_confirmation(att, booking, mooring_booking, context_processor)
    att.seek(0)
    subject = "Your mooring booking confirmation"
    if booking.admission_payment:
        subject = "Your mooring booking and admissions confirmation"
        att2 = BytesIO()
        admissionsBooking = AdmissionsBooking.objects.get(
            id=booking.admission_payment.id)
        pdf.create_admissions_confirmation(att2, admissionsBooking,
                                           context_processor)
        att2.seek(0)
        filename = 'confirmation-AD{}.pdf'.format(admissionsBooking.id)
        sendHtmlEmail([email],
                      subject,
                      context,
                      template,
                      cc,
                      bcc,
                      from_email,
                      template_group,
                      attachments=[('confirmation-PS{}.pdf'.format(booking.id),
                                    att.read(), 'application/pdf'),
                                   (filename, att2.read(), 'application/pdf')])
        #email_obj.send([email], from_address=campground_email, context=context, cc=cc, bcc=bcc, attachments=[('confirmation-PS{}.pdf'.format(booking.id), att.read(), 'application/pdf'), (filename, att2.read(), 'application/pdf')])
    else:
        #email_obj.send([email], from_address=campground_email, context=context, cc=cc, bcc=bcc, attachments=[('confirmation-PS{}.pdf'.format(booking.id), att.read(), 'application/pdf')])
        sendHtmlEmail([email],
                      subject,
                      context,
                      template,
                      cc,
                      bcc,
                      from_email,
                      template_group,
                      attachments=[('confirmation-PS{}.pdf'.format(booking.id),
                                    att.read(), 'application/pdf')])
    booking.confirmation_sent = True
    booking.save()
Esempio n. 4
0
def send_booking_confirmation(booking,request,context_processor):
    email_obj = TemplateEmailBase()
    email_obj.subject = 'Your booking {} at {} is confirmed'.format(booking.confirmation_number,booking.mooringarea.name)
    email_obj.html_template = 'mooring/email/confirmation.html'
    email_obj.txt_template = 'mooring/email/confirmation.txt'
    from_email = None

    email = booking.customer.email

    template = 'mooring/email/booking_confirmation.html'

    cc = None
    bcc = [default_campground_email]

    template_group = context_processor['TEMPLATE_GROUP']

    #campground_email = booking.mooringarea.email if booking.mooringarea.email else default_campground_email
    campground_email = default_from_email
    if campground_email != default_campground_email:
        cc = [campground_email]

    my_bookings_url = request.build_absolute_uri('/mybookings/')
    booking_availability = request.build_absolute_uri('/availability/?site_id={}'.format(booking.mooringarea.id))
    unpaid_vehicle = False
    mobile_number = booking.customer.mobile_number
    booking_number = booking.details.get('phone',None)
    phone_number = booking.customer.phone_number
    tel = None
    if booking_number:
        tel = booking_number
    elif mobile_number:
        tel = mobile_number
    else:
        tel = phone_number
    tel = tel if tel else ''

    for v in booking.vehicle_payment_status:
        if v.get('Paid') == 'No':
            unpaid_vehicle = True
            break
    
    
    additional_info = booking.mooringarea.additional_info if booking.mooringarea.additional_info else ''

    msbs = MooringsiteBooking.objects.filter(booking=booking)
    contact_list = []
    moorings = []
    for m in msbs:
        if m.campsite.mooringarea not in moorings:
            moorings.append(m.campsite.mooringarea)
            contact = m.campsite.mooringarea.contact
            if not any(c['email'] == contact.email for c in contact_list) or not any(c['phone'] == contact.phone_number for c in contact_list):
                line = {'moorings': m.campsite.mooringarea.name, 'email': contact.email, 'phone': contact.phone_number}
                contact_list.append(line)
            else:
                index = next((index for (index, d) in enumerate(contact_list) if d['email'] == contact.email), None)
                contact_list[index]['moorings'] += ', ' + m.campsite.mooringarea.name


    
    context = {
        'booking': booking,
        'phone_number': tel,
        'campground_email': campground_email,
        'my_bookings': my_bookings_url,
        'availability': booking_availability,
        'unpaid_vehicle': unpaid_vehicle,
        'additional_info': additional_info,
        'contact_list': contact_list,
    }

    att = BytesIO()
    mooring_booking = []
    if MooringsiteBooking.objects.filter(booking=booking).count() > 0:
        mooring_booking = MooringsiteBooking.objects.filter(booking=booking)
    pdf.create_confirmation(att, booking, mooring_booking,context_processor)
    att.seek(0) 
    subject = "Your mooring booking confirmation"
    if booking.admission_payment:
        subject = "Your mooring booking and admissions confirmation"
        att2 = BytesIO()
        admissionsBooking = AdmissionsBooking.objects.get(id=booking.admission_payment.id)
        pdf.create_admissions_confirmation(att2, admissionsBooking, context_processor)
        att2.seek(0)
        filename = 'confirmation-AD{}.pdf'.format(admissionsBooking.id)
        sendHtmlEmail([email],subject,context,template,cc,bcc,from_email,template_group,attachments=[('confirmation-PS{}.pdf'.format(booking.id), att.read(), 'application/pdf'), (filename, att2.read(), 'application/pdf')])
        #email_obj.send([email], from_address=campground_email, context=context, cc=cc, bcc=bcc, attachments=[('confirmation-PS{}.pdf'.format(booking.id), att.read(), 'application/pdf'), (filename, att2.read(), 'application/pdf')])
    else:
        #email_obj.send([email], from_address=campground_email, context=context, cc=cc, bcc=bcc, attachments=[('confirmation-PS{}.pdf'.format(booking.id), att.read(), 'application/pdf')])
        sendHtmlEmail([email],subject,context,template,cc,bcc,from_email,template_group,attachments=[('confirmation-PS{}.pdf'.format(booking.id), att.read(), 'application/pdf')])
    booking.confirmation_sent = True
    booking.save()