Merge pull request #5361 from edx/cdodge/change-invoice-email-and-attachments
change registration code email and attachments, per product requirements
This commit is contained in:
@@ -9,6 +9,7 @@ import StringIO
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
import time
|
||||
import requests
|
||||
from django.conf import settings
|
||||
from django_future.csrf import ensure_csrf_cookie
|
||||
@@ -884,26 +885,40 @@ def generate_registration_codes(request, course_id):
|
||||
course_honor_mode = CourseMode.mode_for_course(course_id, 'honor')
|
||||
course_price = course_honor_mode.min_price
|
||||
quantity = course_code_number
|
||||
discount_price = (float(quantity * course_price) - float(sale_price))
|
||||
discount = (float(quantity * course_price) - float(sale_price))
|
||||
course_url = '{base_url}{course_about}'.format(
|
||||
base_url=request.META['HTTP_HOST'],
|
||||
base_url=microsite.get_value('SITE_NAME', settings.SITE_NAME),
|
||||
course_about=reverse('about_course', kwargs={'course_id': course_id.to_deprecated_string()})
|
||||
)
|
||||
dashboard_url = '{base_url}{dashboard}'.format(
|
||||
base_url=microsite.get_value('SITE_NAME', settings.SITE_NAME),
|
||||
dashboard=reverse('dashboard')
|
||||
)
|
||||
|
||||
from_address = microsite.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
|
||||
context = {
|
||||
'invoice': sale_invoice,
|
||||
'site_name': site_name,
|
||||
'course': course,
|
||||
'course_price': course_price,
|
||||
'discount_price': discount_price,
|
||||
'sub_total': course_price * quantity,
|
||||
'discount': discount,
|
||||
'sale_price': sale_price,
|
||||
'quantity': quantity,
|
||||
'registration_codes': course_registration_codes,
|
||||
'course_url': course_url,
|
||||
'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME),
|
||||
'dashboard_url': dashboard_url,
|
||||
'contact_email': from_address,
|
||||
'corp_address': microsite.get_value('invoice_corp_address', settings.INVOICE_CORP_ADDRESS),
|
||||
'payment_instructions': microsite.get_value('invoice_payment_instructions', settings. INVOICE_PAYMENT_INSTRUCTIONS),
|
||||
'date': time.strftime("%m/%d/%Y")
|
||||
}
|
||||
# composes registration codes invoice email
|
||||
subject = u'Invoice for {course_name}'.format(course_name=course.display_name)
|
||||
message = render_to_string('emails/registration_codes_sale_invoice.txt', context)
|
||||
from_address = microsite.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
|
||||
subject = u'Confirmation and Invoice for {course_name}'.format(course_name=course.display_name)
|
||||
message = render_to_string('emails/registration_codes_sale_email.txt', context)
|
||||
|
||||
invoice_attachment = render_to_string('emails/registration_codes_sale_invoice_attachment.txt', context)
|
||||
|
||||
#send_mail(subject, message, from_address, recipient_list, fail_silently=False)
|
||||
csv_file = StringIO.StringIO()
|
||||
@@ -919,6 +934,7 @@ def generate_registration_codes(request, course_id):
|
||||
email.from_email = from_address
|
||||
email.to = [recipient]
|
||||
email.attach(u'RegistrationCodes.csv', csv_file.getvalue(), 'text/csv')
|
||||
email.attach(u'Invoice.txt', invoice_attachment, 'text/plain')
|
||||
email.send()
|
||||
|
||||
return registration_codes_csv("Registration_Codes.csv", course_registration_codes)
|
||||
|
||||
@@ -468,3 +468,7 @@ REGISTRATION_CODE_LENGTH = ENV_TOKENS.get('REGISTRATION_CODE_LENGTH', 8)
|
||||
|
||||
# TODO (ECOM-16): Remove once the A/B test of auto-registration completes
|
||||
AUTO_REGISTRATION_AB_TEST_EXCLUDE_COURSES = set(ENV_TOKENS.get('AUTO_REGISTRATION_AB_TEST_EXCLUDE_COURSES', AUTO_REGISTRATION_AB_TEST_EXCLUDE_COURSES))
|
||||
|
||||
# REGISTRATION CODES DISPLAY INFORMATION
|
||||
INVOICE_CORP_ADDRESS = ENV_TOKENS.get('INVOICE_CORP_ADDRESS', INVOICE_CORP_ADDRESS)
|
||||
INVOICE_PAYMENT_INSTRUCTIONS = ENV_TOKENS.get('INVOICE_PAYMENT_INSTRUCTIONS', INVOICE_PAYMENT_INSTRUCTIONS)
|
||||
|
||||
@@ -287,7 +287,7 @@ FEATURES = {
|
||||
# False to not redirect the user
|
||||
'ALWAYS_REDIRECT_HOMEPAGE_TO_DASHBOARD_FOR_AUTHENTICATED_USER': True,
|
||||
|
||||
# Expose Mobile REST API. Note that if you use this, you must also set
|
||||
# Expose Mobile REST API. Note that if you use this, you must also set
|
||||
# ENABLE_OAUTH2_PROVIDER to True
|
||||
'ENABLE_MOBILE_REST_API': False,
|
||||
|
||||
@@ -1801,3 +1801,7 @@ AUTO_REGISTRATION_AB_TEST_EXCLUDE_COURSES = set([
|
||||
"HarvardX/SW12.9x/3T2014",
|
||||
"HarvardX/SW12.8x/3T2014",
|
||||
])
|
||||
|
||||
# REGISTRATION CODES DISPLAY INFORMATION SUBTITUTIONS IN THE INVOICE ATTACHMENT
|
||||
INVOICE_CORP_ADDRESS = "Please place your corporate address\nin this configuration"
|
||||
INVOICE_PAYMENT_INSTRUCTIONS = "This is where you can\nput directions on how people\nbuying registration codes"
|
||||
|
||||
31
lms/templates/emails/registration_codes_sale_email.txt
Normal file
31
lms/templates/emails/registration_codes_sale_email.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
|
||||
${_("Thank you for your purchase of {course_name}!").format(course_name=course.display_name)}
|
||||
|
||||
${_("An invoice for ${total_price} is attached. Payment is due immediately. Information on payment methods can be found on the invoice.").format(total_price=sale_price)}
|
||||
|
||||
${_("A CSV file of your registration codes is attached. Please distribute registration codes to each student planning to enroll using the email template below.")}
|
||||
|
||||
${_("Thanks,")}
|
||||
${_("Your {platform_name} Team").format(platform_name=platform_name)}
|
||||
|
||||
|
||||
———————————————————————————————————————————
|
||||
|
||||
|
||||
${_("Dear [[Name]]:")}
|
||||
|
||||
${_("We have provided an enrollment for you in the course {course_name} from {platform_name}. Please follow the instructions below to claim your access.").format(course_name=course.display_name, platform_name=platform_name)}
|
||||
|
||||
${_("Your redeem code is: [[Enter Redeem Code here from the attached CSV]]")}
|
||||
|
||||
${_("(1) Register for an account at https://{site_name}.").format(site_name=site_name)}
|
||||
${_("(2) Once registered, navigate to https://{course_url}").format(course_url=course_url)}
|
||||
${_("(3) Click 'Add {course_number} to Cart'").format(course_number=course.display_coursenumber)}
|
||||
${_("(4) On the shopping cart page, enter your redeem code and click apply code. This will make payment equal to $0.")}
|
||||
${_("(5) Click 'Register'")}
|
||||
${_("(6) You should be able to see your course on your student dashboard at https://{dashboard_url}").format(dashboard_url=dashboard_url)}
|
||||
${_("(7) Course materials will not be available until the course start date.")}
|
||||
|
||||
${_("Sincerely,")}
|
||||
${_("[[Your Signature]]")}
|
||||
@@ -1,49 +0,0 @@
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
|
||||
${_("Professional Education Invoicing Center")}
|
||||
|
||||
${_("Portland Street, ")}
|
||||
${_("9th floor Cambridge, MA,")}
|
||||
${_("02139 finance@edx.org")}
|
||||
|
||||
${_("---------------------------------")}
|
||||
|
||||
${_("Bill To:")}
|
||||
|
||||
${_("{company_name}").format(company_name=invoice.company_name)}
|
||||
|
||||
${_("{purchaser_name}").format(purchaser_name=invoice.company_contact_name)}
|
||||
|
||||
% if invoice.customer_reference_number:
|
||||
${_("Customer Reference Number: {customer_reference_number}").format(customer_reference_number=invoice.customer_reference_number)}
|
||||
%endif
|
||||
|
||||
${_("---------------------------------")}
|
||||
|
||||
${_("Registration codes:")}
|
||||
|
||||
${_("Please distribute one of the following registration codes to each student who is going to enroll in the class.")}
|
||||
${_("A student can redeem one of these codes by registering an account on ({site_name}.edx.org), starting the purchase").format(site_name=site_name)}
|
||||
${_("process on this course by adding it to their shopping cart from this page ({course_url}), and").format(course_url=course_url)}
|
||||
${_("entering their registration code while in the shopping cart.")}
|
||||
|
||||
%for registration_code in registration_codes:
|
||||
${registration_code.code}
|
||||
%endfor
|
||||
|
||||
${_("---------------------------------")}
|
||||
|
||||
${_("Thank you for your purchase! Failure to pay this invoice will result the invalidation of student enrollments")}
|
||||
${_("that use these codes. All purchases are final. Please refer to the cancellation policy")}
|
||||
${_("on {site_name} for more information.").format(site_name=site_name)}
|
||||
|
||||
${_("---------------------------------")}
|
||||
|
||||
${_("Course: {course_name} {start_date} - {end_date}").format(course_name=course.display_name, start_date=course.start_date_text, end_date=course.end_date_text)}
|
||||
${_("Price: ${price}").format(price=course_price)}
|
||||
${_("Quantity: ${quantity}").format(quantity=quantity)}
|
||||
${_("Sub-Total: ${sub_total}").format(sub_total=quantity*course_price)}
|
||||
${_("Discount: ${discount}").format(discount=discount_price)}
|
||||
|
||||
${_("--------- ------")}
|
||||
${_("Total Due: ${total_price}").format(total_price=sale_price)}
|
||||
@@ -0,0 +1,43 @@
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
|
||||
${_("INVOICE")}
|
||||
|
||||
———————————————————————————————————————————
|
||||
|
||||
${corp_address}
|
||||
|
||||
${_("Date: {date}").format(date=date)}
|
||||
${_("Invoice No: {invoice_number}").format(invoice_number=invoice.id)}
|
||||
${_("Terms: Due Immediately")}
|
||||
${_("Due Date: {date}").format(date=date)}
|
||||
|
||||
${_("Bill to:")}
|
||||
${invoice.company_name}
|
||||
${invoice.address_line_1}
|
||||
% if invoice.address_line_2:
|
||||
${invoice.address_line_2}
|
||||
% endif
|
||||
% if invoice.address_line_3:
|
||||
${invoice.address_line_3}
|
||||
% endif
|
||||
${invoice.city}, ${invoice.state}, ${invoice.zip}
|
||||
${invoice.country}
|
||||
${_("Customer Reference Number: {reference_number}").format(reference_number=invoice.customer_reference_number if invoice.customer_reference_number else "")}
|
||||
|
||||
${_("Balance Due: ${sale_price}").format(sale_price=sale_price)}
|
||||
|
||||
———————————————————————————————————————————
|
||||
|
||||
${_("Course: {course_name}").format(course_name=course.display_name)}
|
||||
${_("Price: ${course_price} Quantity: {quantity} Sub-Total: ${sub_total} Discount: ${discount}").format(course_price=course_price, quantity=quantity, sub_total=sub_total, discount=discount)}
|
||||
${_("Total: ${sale_price}").format(sale_price=sale_price)}
|
||||
|
||||
———————————————————————————————————————————
|
||||
|
||||
${_("Payment instructions")}
|
||||
|
||||
${payment_instructions}
|
||||
|
||||
${_("Failure to pay this invoice will result the invalidation of student enrollment that use these codes. All purchases are final. Please refer to the cancellation policy on {site_name} for more information.").format(site_name=site_name)}
|
||||
|
||||
${_("If you have payment questions, please contact {contact_email}").format(contact_email=contact_email)}
|
||||
Reference in New Issue
Block a user