Commit bc70b1d9 by Adam Palay

change formatting for email messages to use full_name instead of first_ and last_name

fix templates
parent 0bea1855
...@@ -50,6 +50,7 @@ from instructor_task.views import get_task_completion_info ...@@ -50,6 +50,7 @@ from instructor_task.views import get_task_completion_info
from mitxmako.shortcuts import render_to_response from mitxmako.shortcuts import render_to_response
from psychometrics import psychoanalyze from psychometrics import psychoanalyze
from student.models import CourseEnrollment, CourseEnrollmentAllowed from student.models import CourseEnrollment, CourseEnrollmentAllowed
from student.views import course_from_id
import track.views import track.views
from mitxmako.shortcuts import render_to_string from mitxmako.shortcuts import render_to_string
from xblock.field_data import DictFieldData from xblock.field_data import DictFieldData
...@@ -60,6 +61,7 @@ from bulk_email.models import CourseEmail ...@@ -60,6 +61,7 @@ from bulk_email.models import CourseEmail
from html_to_text import html_to_text from html_to_text import html_to_text
from bulk_email import tasks from bulk_email import tasks
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# internal commands for managing forum roles: # internal commands for managing forum roles:
...@@ -1196,7 +1198,7 @@ def _do_enroll_students(course, course_id, students, overload=False, auto_enroll ...@@ -1196,7 +1198,7 @@ def _do_enroll_students(course, course_id, students, overload=False, auto_enroll
#Composition of email #Composition of email
d = {'site_name': stripped_site_name, d = {'site_name': stripped_site_name,
'registration_url': registration_url, 'registration_url': registration_url,
'course_id': course_id, 'course': course,
'auto_enroll': auto_enroll, 'auto_enroll': auto_enroll,
'course_url': 'https://' + stripped_site_name + '/courses/' + course_id, 'course_url': 'https://' + stripped_site_name + '/courses/' + course_id,
} }
...@@ -1246,8 +1248,7 @@ def _do_enroll_students(course, course_id, students, overload=False, auto_enroll ...@@ -1246,8 +1248,7 @@ def _do_enroll_students(course, course_id, students, overload=False, auto_enroll
if email_students: if email_students:
#User enrolled for first time, populate dict with user specific info #User enrolled for first time, populate dict with user specific info
d['email_address'] = student d['email_address'] = student
d['first_name'] = user.first_name d['full_name'] = user.profile.name
d['last_name'] = user.last_name
d['message'] = 'enrolled_enroll' d['message'] = 'enrolled_enroll'
send_mail_ret = send_mail_to_student(student, d) send_mail_ret = send_mail_to_student(student, d)
status[student] += (', email sent' if send_mail_ret else '') status[student] += (', email sent' if send_mail_ret else '')
...@@ -1283,9 +1284,10 @@ def _do_unenroll_students(course_id, students, email_students=False): ...@@ -1283,9 +1284,10 @@ def _do_unenroll_students(course_id, students, email_students=False):
stripped_site_name = _remove_preview(settings.SITE_NAME) stripped_site_name = _remove_preview(settings.SITE_NAME)
if email_students: if email_students:
course = course_from_id(course_id)
#Composition of email #Composition of email
d = {'site_name': stripped_site_name, d = {'site_name': stripped_site_name,
'course_id': course_id} 'course': course}
for student in old_students: for student in old_students:
...@@ -1318,8 +1320,7 @@ def _do_unenroll_students(course_id, students, email_students=False): ...@@ -1318,8 +1320,7 @@ def _do_unenroll_students(course_id, students, email_students=False):
if email_students: if email_students:
#User was enrolled #User was enrolled
d['email_address'] = student d['email_address'] = student
d['first_name'] = user.first_name d['full_name'] = user.profile.name
d['last_name'] = user.last_name
d['message'] = 'enrolled_unenroll' d['message'] = 'enrolled_unenroll'
send_mail_ret = send_mail_to_student(student, d) send_mail_ret = send_mail_to_student(student, d)
status[student] += (', email sent' if send_mail_ret else '') status[student] += (', email sent' if send_mail_ret else '')
...@@ -1348,8 +1349,7 @@ def send_mail_to_student(student, param_dict): ...@@ -1348,8 +1349,7 @@ def send_mail_to_student(student, param_dict):
`auto_enroll`: user input option (a `str`) `auto_enroll`: user input option (a `str`)
`course_url`: url of course (a `str`) `course_url`: url of course (a `str`)
`email_address`: email of student (a `str`) `email_address`: email of student (a `str`)
`first_name`: student first name (a `str`) `full_name`: student full name (a `str`)
`last_name`: student last name (a `str`)
`message`: type of email to send and template to use (a `str`) `message`: type of email to send and template to use (a `str`)
] ]
Returns a boolean indicating whether the email was sent successfully. Returns a boolean indicating whether the email was sent successfully.
...@@ -1365,9 +1365,13 @@ def send_mail_to_student(student, param_dict): ...@@ -1365,9 +1365,13 @@ def send_mail_to_student(student, param_dict):
subject = render_to_string(subject_template, param_dict) subject = render_to_string(subject_template, param_dict)
message = render_to_string(message_template, param_dict) message = render_to_string(message_template, param_dict)
# Remove leading and trailing whitespace from body
message = message.strip()
# Email subject *must not* contain newlines # Email subject *must not* contain newlines
subject = ''.join(subject.splitlines()) subject = ''.join(subject.splitlines())
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [student], fail_silently=False) send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [student], fail_silently=False)
return True return True
else: else:
return False return False
......
<%namespace file="../main.html" import="stanford_theme_enabled" /> <%namespace file="../main.html" import="stanford_theme_enabled" />
<%! from django.utils.translation import ugettext as _ %>
Thank you for signing up for ${settings.PLATFORM_NAME}! To activate ${_("Thank you for signing up for {platform_name}! To activate "
your account, please copy and paste this address into your web "your account, please copy and paste this address into your web "
browser's address bar: "browser's address bar:").format(platform_name=settings.PLATFORM_NAME)}
% if is_secure: % if is_secure:
https://${ site }/activate/${ key } https://${ site }/activate/${ key }
...@@ -12,13 +13,13 @@ browser's address bar: ...@@ -12,13 +13,13 @@ browser's address bar:
## Temporary hack until we develop a better way to adjust language ## Temporary hack until we develop a better way to adjust language
% if stanford_theme_enabled(): % if stanford_theme_enabled():
If you didn't request this, you don't need to do anything; you won't ${_("If you didn't request this, you don't need to do anything; you won't "
receive any more email from us. Please do not reply to this e-mail; "receive any more email from us. Please do not reply to this e-mail; "
if you require assistance, check the about section of the "if you require assistance, check the about section of the "
${settings.PLATFORM_NAME} Courses web site. "${platform_name} Courses web site.").format(platform_name=settings.PLATFORM_NAME)}
% else: % else:
If you didn't request this, you don't need to do anything; you won't ${_("If you didn't request this, you don't need to do anything; you won't "
receive any more email from us. Please do not reply to this e-mail; "receive any more email from us. Please do not reply to this e-mail; "
if you require assistance, check the help section of the "if you require assistance, check the help section of the "
${settings.PLATFORM_NAME} web site. "${platform_name} web site.").format(platform_name=settings.PLATFORM_NAME)}
% endif % endif
Your account for ${settings.PLATFORM_NAME} <%! from django.utils.translation import ugettext as _ %>
${_("Your account for {platform_name}").format(platform_name=settings.PLATFORM_NAME)}
Dear student, <%! from django.utils.translation import ugettext as _ %>
You have been invited to join ${course_id} at ${site_name} by a member of the course staff. ${_("Dear student,")}
To finish your registration, please visit ${registration_url} and fill out the registration form making sure to use ${email_address} in the E-mail field. ${_("You have been invited to join {course_name} at {site_name} by a "
"member of the course staff.").format(
course_name=course.display_name_with_default,
site_name=site_name
)}
${_("To finish your registration, please visit {registration_url} and fill "
"out the registration form making sure to use {email_address} in the "
"E-mail field.").format(
registration_url=registration_url,
email_address=email_address
)}
% if auto_enroll: % if auto_enroll:
Once you have registered and activated your account, you will see ${course_id} listed on your dashboard. ${_("Once you have registered and activated your account, you will see "
"{course_name} listed on your dashboard.").format(
course_name=course.display_name_with_default
)}
% else: % else:
Once you have registered and activated your account, visit ${course_url} to join the course. ${_("Once you have registered and activated your account, visit {course_url} "
"to join the course.").format(course_url=course_url)}
% endif % endif
---- ----
This email was automatically sent from ${site_name} to ${email_address} ${_("This email was automatically sent from {site_name} to "
\ No newline at end of file "{email_address}").format(
site_name=site_name, email_address=email_address
)}
\ No newline at end of file
You have been invited to register for ${course_id} <%! from django.utils.translation import ugettext as _ %>
\ No newline at end of file
${_("You have been invited to register for {course_name}").format(
course_name=course.display_name_with_default
)}
\ No newline at end of file
Dear ${first_name} ${last_name} <%! from django.utils.translation import ugettext as _ %>
You have been enrolled in ${course_id} at ${site_name} by a member of the course staff. The course should now appear on your ${site_name} dashboard. ${_("Dear {full_name}").format(full_name=full_name)}
To start accessing course materials, please visit ${course_url} ${_("You have been enrolled in {course_name} at {site_name} by a member "
"of the course staff. The course should now appear on your {site_name} "
"dashboard.").format(
course_name=course.display_name_with_default,
site_name=site_name
)}
${_("To start accessing course materials, please visit {course_url}").format(
course_url=course_url
)}
---- ----
This email was automatically sent from ${site_name} to ${first_name} ${last_name} ${_("This email was automatically sent from {site_name} to "
\ No newline at end of file "{full_name}").format(
site_name=site_name, full_name=full_name
)}
\ No newline at end of file
You have been enrolled in ${course_id} <%! from django.utils.translation import ugettext as _ %>
\ No newline at end of file
${_("You have been enrolled in {course_name}").format(
course_name=course.display_name_with_default
)}
\ No newline at end of file
Dear Student, <%! from django.utils.translation import ugettext as _ %>
You have been un-enrolled from course ${course_id} by a member of the course staff. Please disregard the invitation previously sent. ${_("Dear Student,")}
${_("You have been un-enrolled from course {course_name} by a member "
"of the course staff. Please disregard the invitation "
"previously sent.").format(course_name=course.display_name_with_default)}
---- ----
This email was automatically sent from ${site_name} to ${email_address} ${_("This email was automatically sent from {site_name} "
\ No newline at end of file "to {email_address}").format(
site_name=site_name, email_address=email_address
)}
\ No newline at end of file
Dear ${first_name} ${last_name} <%! from django.utils.translation import ugettext as _ %>
You have been un-enrolled in ${course_id} at ${site_name} by a member of the course staff. The course will no longer appear on your ${site_name} dashboard. ${_("Dear {full_name}").format(full_name=full_name)}
Your other courses have not been affected. ${_("You have been un-enrolled in {course_name} at {site_name} by a member "
"of the course staff. The course will no longer appear on your "
"{site_name} dashboard.").format(
course_name=course.display_name_with_default, site_name=site_name
)}
${_("Your other courses have not been affected.")}
---- ----
This email was automatically sent from ${site_name} to ${first_name} ${last_name} ${_("This email was automatically sent from ${site_name} to "
\ No newline at end of file "${full_name}").format(
full_name=full_name, site_name=site_name
)}
\ No newline at end of file
You have been un-enrolled from ${course_id} <%! from django.utils.translation import ugettext as _ %>
\ No newline at end of file
${_("You have been un-enrolled from {course_name}").format(
course_name=course.display_name_with_default
)}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment