Skip to content

fix: editors fetching query for self paced courses in send_course_deadline_emails command #4640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 16, 2025

Conversation

AfaqShuaib09
Copy link
Contributor

@AfaqShuaib09 AfaqShuaib09 commented Jun 12, 2025

This PR fixes the editors query to fetch them from the draft version of the course instead of the official version. While testing the send_course_deadline_emails command, I found that course editors are linked to the draft entry of the course, not the non-draft version.

I've verified email sending functionality by assigning manually course_editor to draft entry of course.

@AfaqShuaib09 AfaqShuaib09 marked this pull request as ready for review June 13, 2025 05:44
@@ -97,7 +97,7 @@ def handle_send_email_to_pcs_and_editors(self, course, course_run, email_variant
This method retrieves the email addresses of course editors and project coordinators associated with the course
and schedules the email to be sent using the `process_send_course_deadline_email` task.
"""
course_editors = list(course.editors.values_list('user__email', flat=True).distinct())
course_editors = list(course.draft_version.editors.values_list('user__email', flat=True).distinct())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use Course.objects.filter_drafts(), as it has been used in editor API, to ensure that if a draft exists, return that. Otherwise, return non-draft.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Course.objects.filter_drafts() basically returns a queryset of all draft courses. Are you referring to adding the uuid here to this queryset to fetch only specific course?

Or should we use it in the command’s handle method in filtering instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should we use it in the command’s handle method in filtering instead?

this. This will do the required filtering at the very top and we would not need to add this draft_version handling here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we update them here, we still need to access the official version below because the draft version of a course only has an associated draft run, which is not marketable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. Makes sense.

@AfaqShuaib09 AfaqShuaib09 force-pushed the afaq/prod-4348-2 branch 2 times, most recently from db26df8 to 330b6f2 Compare June 13, 2025 10:45
@AfaqShuaib09 AfaqShuaib09 merged commit 7932423 into master Jun 16, 2025
12 checks passed
@AfaqShuaib09 AfaqShuaib09 deleted the afaq/prod-4348-2 branch June 16, 2025 06:50
mfarhan943 pushed a commit to mfarhan943/course-discovery that referenced this pull request Jun 16, 2025
…dline_emails command (openedx#4640)

* fix: editors fetching query for self paced courses in send_course_deadline_emails command

* test: update unittests accordingly

* fix: a test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants