Skip to content
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: reactive schedules nudge emails filter #56

Open
wants to merge 18 commits into
base: nau/redwood.master
Choose a base branch
from

Conversation

BryanttV
Copy link

@BryanttV BryanttV commented Dec 6, 2024

Description

This PR adds a pipeline step to use the ScheduleQuerySetRequested filter. This step allows filtering the users in the Schedule QuerySet to keep only users with the allow_newsletter field set to True.

Related Issues

Testing Instructions

  1. Create a Tutor environment in the Redwood version.

  2. Install this plugin with the changes in this PR. ⚠️ Don't forget to run migrations.

  3. Install openedx-filters with the changes in this PR.

  4. Create a mount of edx-platform with the changes in this PR.

  5. Create a new Schedule config for your site in {lms_domain}/admin/schedules/scheduleconfig/

    image

  6. Create some users and enroll them in a course.

  7. Create an NAU user extended model for each user in {lms_domain}/admin/nau_openedx_extensions/nauuserextendedmodel/

  8. Create a Tutor inline plugin with the filter configuration:

    name: filter-settings
    version: 0.1.0
    patches:
      openedx-common-settings: |
        OPEN_EDX_FILTERS_CONFIG = {
          "org.openedx.learning.schedule.queryset.requested.v1": {
            "fail_silently": False,
            "pipeline": [
              "nau_openedx_extensions.filters.pipeline.FilterUsersWithAllowedNewsletter",
            ],
          },
        }
  9. 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
  10. Depending on the value of each user's allow_newsletter field, you should see the filtered QuerySet of Schedules in the console.

@BryanttV BryanttV marked this pull request as ready for review December 9, 2024 18:01
@BryanttV BryanttV force-pushed the bav/reactive-schedules-nudge-emails branch from 832050f to 6513278 Compare December 9, 2024 18:20
@BryanttV BryanttV force-pushed the bav/reactive-schedules-nudge-emails branch from 6513278 to 1aef6f0 Compare December 9, 2024 18:39
@MaferMazu MaferMazu self-requested a review December 9, 2024 22:54
Copy link
Contributor

@MaferMazu MaferMazu left a comment

Choose a reason for hiding this comment

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

Thanks for those PRs, @BryanttV.

I tested it, and it worked as expected ✨

About this PR, I have a few comments:

  • We probably don't need the definition.py file; we will have that code in openedx-filters. We can update the openedx-filters package here, and to add more context, we can add a reference to the filter we are using in the pipeline doc. Or are we adding that for another reason?
  • I am not sure which case we encountered the FieldError. If you have identified, I would like to know.

nau_openedx_extensions/filters/pipeline.py Outdated Show resolved Hide resolved
@BryanttV
Copy link
Author

Hi @MaferMazu, thanks for the review!

We probably don't need the definition.py file; we will have that code in openedx-filters. We can update the openedx-filters package here, and to add more context, we can add a reference to the filter we are using in the pipeline doc. Or are we adding that for another reason?

That's right, the definition.py is only for testing. I deleted it from this branch. When the openedx-filter PR is merged, we should update the requirements here.

I am not sure which case we encountered the FieldError. If you have identified, I would like to know.

This validation is only in case the plugin migrations have not been executed, and the model does not exist. Do you think we don't need it?

@BryanttV BryanttV requested a review from MaferMazu December 12, 2024 12:33
@BryanttV BryanttV force-pushed the bav/reactive-schedules-nudge-emails branch from 805dcbb to d10bb12 Compare December 12, 2024 17:52
@MaferMazu
Copy link
Contributor

MF: I am not sure which case we encountered the FieldError. If you have identified, I would like to know.
Bryann: This validation is only in case the plugin migrations have not been executed, and the model does not exist. Do you think we don't need it?

I understand why you added it, but I think this part of the code shouldn't be responsible for the lack of migration; having the migrations is a pre-requisite.

If you want, we can add a small note to the filter docs, but I think it is not necessary.

Copy link
Contributor

@MaferMazu MaferMazu left a comment

Choose a reason for hiding this comment

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

This looks good to me ✨

Thanks for these PRs

@MaferMazu MaferMazu self-requested a review December 13, 2024 14:54
@MaferMazu
Copy link
Contributor

@BryanttV, as I said, this looks good, but I think we should add some tests.

Example: https://github.com/fccn/nau-openedx-extensions/blob/nau/nutmeg.master/nau_openedx_extensions/tests/test_pipeline.py

@BryanttV
Copy link
Author

Hi @MaferMazu, I added the unit tests.

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.

2 participants