fix: make course optimizer specific changes to user task completion email
This commit is contained in:
@@ -86,9 +86,16 @@ def user_task_stopped_handler(sender, **kwargs): # pylint: disable=unused-argum
|
||||
reverse('usertaskstatus-detail', args=[status.uuid])
|
||||
)
|
||||
|
||||
# check if this is a course optimizer task
|
||||
is_course_optimizer_task = False
|
||||
course_optimizer_artifact = UserTaskArtifact.objects.filter(status=status, name="BrokenLinks").first()
|
||||
if course_optimizer_artifact:
|
||||
is_course_optimizer_task = True
|
||||
|
||||
user_email = status.user.email
|
||||
olx_validation_text = get_olx_validation_from_artifact()
|
||||
task_args = [task_name, str(status.state_text), user_email, detail_url, olx_validation_text]
|
||||
task_args = [task_name, str(status.state_text), user_email, detail_url,
|
||||
olx_validation_text, is_course_optimizer_task]
|
||||
try:
|
||||
send_task_complete_email.delay(*task_args)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
|
||||
@@ -21,17 +21,18 @@ TASK_COMPLETE_EMAIL_TIMEOUT = 60
|
||||
|
||||
@shared_task(bind=True)
|
||||
@set_code_owner_attribute
|
||||
def send_task_complete_email(self, task_name, task_state_text, dest_addr, detail_url, olx_validation_text=None):
|
||||
def send_task_complete_email(self, task_name, task_state_text, dest_addr, detail_url,
|
||||
olx_validation_text=None, is_course_optimizer_task=False):
|
||||
"""
|
||||
Sending an email to the users when an async task completes.
|
||||
"""
|
||||
retries = self.request.retries
|
||||
|
||||
context = {
|
||||
'task_name': task_name,
|
||||
'task_status': task_state_text,
|
||||
'detail_url': detail_url,
|
||||
'olx_validation_errors': {},
|
||||
'is_course_optimizer_task': is_course_optimizer_task,
|
||||
}
|
||||
if olx_validation_text:
|
||||
try:
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
|
||||
${_("Your {task_name} task has completed with the status '{task_status}'. Use this URL to view task details or download any files created: {detail_url}").format(task_name=task_name, task_status=task_status, detail_url=detail_url)}
|
||||
|
||||
% elif is_course_optimizer_task:
|
||||
|
||||
${_("Your {task_name} task has completed with the status '{task_status}'. Sign in to view the details of your task.").format(task_name=task_name, task_status=task_status)}
|
||||
|
||||
% else:
|
||||
|
||||
${_("Your {task_name} task has completed with the status '{task_status}'. Sign in to view the details of your task or download any files created.").format(task_name=task_name, task_status=task_status)}
|
||||
|
||||
@@ -1,2 +1,11 @@
|
||||
<%! from django.utils.translation import gettext as _ %>
|
||||
|
||||
% if is_course_optimizer_task:
|
||||
|
||||
${_("{platform_name} {studio_name}: Course Optimizer Status Update").format(platform_name=settings.PLATFORM_NAME, studio_name=settings.STUDIO_NAME)}
|
||||
|
||||
% else:
|
||||
|
||||
${_("{platform_name} {studio_name}: Task Status Update").format(platform_name=settings.PLATFORM_NAME, studio_name=settings.STUDIO_NAME)}
|
||||
|
||||
% endif
|
||||
|
||||
Reference in New Issue
Block a user