-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: add schedule queryset requested filter #235
feat: add schedule queryset requested filter #235
Conversation
Thanks for the pull request, @BryanttV! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
0f4efec
to
a476204
Compare
Thanks for the contribution, @BryanttV! There's a PR against edx-platform@master, meaning this implementation should work with Tutor nightly. Is that correct? Can I use a nightly environment to test instead of Redwood? Let me know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested this proposal, I only did a static review. I'll be testing this once I get a reply to this comment. Thank you again!
openedx_filters/learning/filters.py
Outdated
class PreventScheduleQuerySetRequest(OpenEdxFilterException): | ||
""" | ||
Custom class used to stop the schedule queryset request process. | ||
""" | ||
|
||
def __init__(self, message: str, schedules: QuerySet): | ||
""" | ||
Override init that defines specific arguments used in the schedule queryset request process. | ||
|
||
Arguments: | ||
message (str): error message for the exception. | ||
schedules (QuerySet): Queryset of schedules to be sent | ||
""" | ||
super().__init__(message, schedules=schedules) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on which situations we would need to halt the filtering the queryset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might need to halt the filter when you get an error in the QuerySet filtering process. For example, here, the PreventScheduleQuerySetRequest
exception is raised if the nauuserextendedmodel
is not found as an attribute of the user model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand. But what would the management command's behavior be when the exception is raised? Would it change in any way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it doesn't change. If the exception is raised, the same QuerySet is returned and the command execution continues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to figure out whether we need an exception in this case. For instance, see https://github.com/openedx/openedx-filters/blob/main/openedx_filters/learning/filters.py#L784-L800 which is used to replace the IDV URL with another URL; there's no different behavior when a condition is met. In contrast, when an enrollment is forbidden for X or Y, then an exception can be raised and the application handles the new behavior differently. Do you think we'd need an exception here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use that exception if we want to prevent the schedules, but if not, I think it's better if we handle the default flow ("the same QuerySet is returned and the command execution continues") from the pipeline.
Comment related: openedx/edx-platform#35982 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your comments! In that case, the exception is not necessary. If you agree, I will remove it.
openedx_filters/learning/filters.py
Outdated
""" | ||
Custom class used to create schedule queryset filters filters and its custom methods. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that these docstrings are kind of a template for these filters, but I admit that they don't say much, and I'd like that to change. Can we be more explicit about the filter's usage here and in the other docstrings? That would be very valuable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I updated the docstring: d12254d
Yes, You can also use a nightly environment. |
I'll be reviewing openedx/edx-platform#35982 as well to verify the proposal. Thank you. |
@BryanttV: Thanks for the thorough explanation in both this PR and edx-platform's. We really appreciate it! Can you add a bit more info in the cover letter about what needs to be configured in the NAU extended profile model? Also, what exactly should I look for in the command line to check that this works? I added a log in the pipeline, that way I knew it was being called when running the command. |
Hi @mariajgrimaldi, thanks for the review! I updated the cover letter with more detailed instructions. Let me know if you need anything else. |
22bf9d0
to
d12254d
Compare
d12254d
to
1e3738f
Compare
Can you also document this use case here? https://docs.openedx.org/projects/openedx-filters/en/latest/reference/real-life-use-cases.html. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Hi @mariajgrimaldi, I added the use case: 362768f |
Description: This PR adds a filter to modify the default schedule queryset of the automatic email messages in
edx-platform
.The filter receives a single
schedules
argument of typeQuerySet
. An example of use is in this NAU pipeline that allows filtering the Schedules to only send emails to users who have the option to receive emails enabled in their profile (allow_newsletter=True
)JIRA: N/A
Dependencies:
Merge deadline: NO
Installation instructions:
openedx-filters
with the changes in this PR.edx-platform
with the changes in this PR. Please use the changes in this branch (For testing purposes).Testing instructions::
Create a new Schedule config for your site in
{lms_domain}/admin/schedules/scheduleconfig/
Create some users and enroll them in a course.
Create an NAU user extended model for each user in
{lms_domain}/admin/nau_openedx_extensions/nauuserextendedmodel/
. Update the following field, depending on whether you want to receive the newsletter.Create a Tutor inline plugin with the filter configuration:
Send a message of recurring nudge using the following command in the LMS container:
python manage.py lms send_recurring_nudge {site} --date {enroll-date + 3 days} # Example python manage.py lms send_recurring_nudge local.edly.io:8000 --date 2024-12-07
Depending on the value of each user's
allow_newsletter
field, you should see the filtered QuerySet ofSchedules
in the console. For example, here the Schedule was filtered because the user does not have the field set to TrueReviewers:
Merge checklist:
Post merge:
Author concerns: N/A