From c180070a9a9a28675d19de2044642b9f0e97530e Mon Sep 17 00:00:00 2001 From: Jeff LaJoie Date: Tue, 12 May 2020 09:01:20 -0400 Subject: [PATCH] Fixes serialization of course key for celery in course updates command --- openedx/core/djangoapps/schedules/resolvers.py | 8 +++++--- openedx/core/djangoapps/schedules/tasks.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/openedx/core/djangoapps/schedules/resolvers.py b/openedx/core/djangoapps/schedules/resolvers.py index 9a67710168..94b8a0c610 100644 --- a/openedx/core/djangoapps/schedules/resolvers.py +++ b/openedx/core/djangoapps/schedules/resolvers.py @@ -14,6 +14,7 @@ from edx_ace.recipient import Recipient from edx_ace.recipient_resolver import RecipientResolver from edx_django_utils.monitoring import function_trace, set_custom_metric from edx_when.api import get_schedules_with_due_date +from opaque_keys.edx.keys import CourseKey from lms.djangoapps.courseware.utils import verified_upgrade_deadline_link, can_show_verified_upgrade from lms.djangoapps.discussion.notification_prefs.views import UsernameCipher @@ -426,7 +427,7 @@ class CourseNextSectionUpdate(PrefixedDebugLoggerMixin, RecipientResolver): async_send_task = attr.ib() site = attr.ib() target_datetime = attr.ib() - course_key = attr.ib() + course_id = attr.ib() override_recipient_email = attr.ib(default=None) log_prefix = 'Next Section Course Update' @@ -447,7 +448,7 @@ class CourseNextSectionUpdate(PrefixedDebugLoggerMixin, RecipientResolver): LOG.info( u'Sending email to user: {} for course-key: {}'.format( user.username, - self.course_key + self.course_id ) ) # TODO: Uncomment below when going live @@ -455,8 +456,9 @@ class CourseNextSectionUpdate(PrefixedDebugLoggerMixin, RecipientResolver): # self.async_send_task.apply_async((self.site.id, str(msg)), retry=False) def get_schedules(self): + course_key = CourseKey.from_string(self.course_id) target_date = self.target_datetime.date() - schedules = get_schedules_with_due_date(self.course_key, target_date).filter( + schedules = get_schedules_with_due_date(course_key, target_date).filter( self.experience_filter, active=True, enrollment__user__is_active=True, diff --git a/openedx/core/djangoapps/schedules/tasks.py b/openedx/core/djangoapps/schedules/tasks.py index e40d92f1a8..d8132e6aa9 100644 --- a/openedx/core/djangoapps/schedules/tasks.py +++ b/openedx/core/djangoapps/schedules/tasks.py @@ -224,7 +224,7 @@ class ScheduleCourseNextSectionUpdate(ScheduleMessageBaseTask): task_args = ( site.id, serialize(target_datetime), # Need to leave as a datetime for serialization purposes here - course_key, + str(course_key), # Needs to be a string for celery to properly process override_recipient_email, ) cls.log_info(u'Launching task with args = %r', task_args) @@ -241,7 +241,7 @@ class ScheduleCourseNextSectionUpdate(ScheduleMessageBaseTask): self.async_send_task, site, deserialize(target_day_str), - course_key, + str(course_key), override_recipient_email, ).send()