Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions lms/djangoapps/instructor/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import json
import logging
import re
import time
import requests
from django.conf import settings
from django_future.csrf import ensure_csrf_cookie
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions lms/envs/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,7 @@

# 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)
6 changes: 5 additions & 1 deletion lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
# 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,

Expand Down Expand Up @@ -1801,3 +1801,7 @@
"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 changes: 31 additions & 0 deletions lms/templates/emails/registration_codes_sale_email.txt
Original file line number Diff line number Diff line change
@@ -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]]")}
49 changes: 0 additions & 49 deletions lms/templates/emails/registration_codes_sale_invoice.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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)}