Skip to content

Conversation

@mariajgrimaldi
Copy link
Member

@mariajgrimaldi mariajgrimaldi commented Mar 1, 2022

Description

As part of the Hooks Extension Framework implementation plan, this PR adds a filter before the course about/home rendering process starts. We decided to include both in one PR given that they are quite alike.

Supporting information

Testing instructions

  1. Install openedx-filters library:
pip install openedx-filters==0.6.0
  1. Implement your pipeline steps in your favorite plugin. We created some as illustration in openedx-filters-samples. We'll be using those in this example.
  2. Install openedx-filters-samples
pip install -e git+https://github.com/eduNEXT/openedx-filters-samples.git@master#egg=openedx_filters_samples
  1. Configure your filters:

For course about tests you could run this tests

  • Render the course about. Instead, an error will be raised or a different template will be rendered.
OPEN_EDX_FILTERS_CONFIG = {
     "org.openedx.learning.course_about.render.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.samples.pipeline.RenderAlternativeCourseAbout",
            ]
    },
}
  • And with this one, you'll be able to give access to "View course from Studio" to non-staff users (just for testing) from the course about without being staff:
OPEN_EDX_FILTERS_CONFIG = {
     "org.openedx.learning.course_about.render.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.samples.pipeline.StaffViewCourseAbout",
            ]
    },
}
  • If you want to redirect to your custom course about, then:
OPEN_EDX_FILTERS_CONFIG = {
     "org.openedx.learning.course_about.render.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.samples.pipeline.RedirectCustomCourseAbout",
            ]
    },
}
  • And if you want to render your own response:
OPEN_EDX_FILTERS_CONFIG = {
     "org.openedx.learning.course_about.render.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.samples.pipeline.RenderCustomResponse",
            ]
    },
}

@openedx-webhooks openedx-webhooks added blended PR is managed through 2U's blended developmnt program waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Mar 1, 2022
@openedx-webhooks
Copy link

openedx-webhooks commented Mar 1, 2022

Thanks for the pull request, @mariajgrimaldi! I've created BLENDED-1120 to keep track of it in Jira. More details are on the BD-32 project page.

When this pull request is ready, tag your edX technical lead.

@mariajgrimaldi mariajgrimaldi force-pushed the MJG/course-about-render-filter branch 2 times, most recently from 1fea7b6 to 6d0764f Compare March 2, 2022 12:23
@mariajgrimaldi mariajgrimaldi changed the title [WIP] [BD-32] feat: add filter before course about rendering process starts #29995 [WIP] [BD-32] feat: add filter before course about rendering process starts Mar 2, 2022
@mariajgrimaldi mariajgrimaldi changed the title [WIP] [BD-32] feat: add filter before course about rendering process starts [BD-32] feat: add filter before course about rendering process starts Mar 2, 2022
@mariajgrimaldi mariajgrimaldi marked this pull request as ready for review March 2, 2022 13:16
@openedx-webhooks openedx-webhooks added needs triage and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Mar 2, 2022
@mariajgrimaldi mariajgrimaldi force-pushed the MJG/course-about-render-filter branch from 2add1cf to 41f2f3d Compare March 30, 2022 21:02
@mariajgrimaldi mariajgrimaldi changed the title [BD-32] feat: add filter before course about rendering process starts [BD-32] feat: add filter before course about/home rendering process starts Apr 1, 2022
@mariajgrimaldi
Copy link
Member Author

Hi there! I hope you're doing good 😃

I'm tagging you here since your involvement in either BD-32 or these files (course home & course about). Your expertise in these applications is crucial for us, and that's why we would appreciate a review from any one of you 😀

@ormsbee
@dianakhuang
@UsamaSadiq
@kdmccormick
@felipemontoya

Copy link
Member

@felipemontoya felipemontoya left a comment

Choose a reason for hiding this comment

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

This PR worked beautifully for modifying the behaviour of those pages before rendering. I tested the 8 options and made interlocking steps to stress test the system. I rendered custom pages defined at the plugin with the pipeline steps and also pages made directly as a django.http response.
Overall I'm thrilled to get this merged. There is one place where I think the naming of the exceptions needs to be clearer.

I so wanted this during the last few years! Great work @mariajgrimaldi.

I'll leave the review in request changes so that we solve the exception naming issue before merging. Also we need to squash the changes and if #29949 is merged first, then the library will already be up to date.

Copy link
Member

Choose a reason for hiding this comment

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

This one is tricky. We will pass the html as the input to the fragment and therefore we will need a little change to the signature of the error.
We need to tell the pipeline step developers to return a string. We could call it RenderCustomFragment.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right. I opened this PR with your suggestion.

Copy link
Member

Choose a reason for hiding this comment

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

We could also call it course_home_fragment_template, but that might be threading too thin.

@openedx-webhooks
Copy link

Thanks for the pull request, @mariajgrimaldi! I've created BLENDED-1182 to keep track of it in Jira. More details are on the BD-32 project page.

When this pull request is ready, tag your edX technical lead.

@kdmccormick
Copy link
Member

kdmccormick commented Apr 5, 2022

Hey @mariajgrimaldi . It looks like these new filters would rely on the presence of the deprecated legacy course home views, some or all of which are slated for removal shortly after the Maple Nutmeg cut next week: openedx/public-engineering#50 (there are a couple PRs linked on that DEPR issue which remove the legacy outline and dates tabs). In particular, the COURSE_HOME_USE_LEGACY_FRONTEND=False overrides in your tests makes me think that this PR depends on code paths that won't be around for much longer.

Is this meant to be temporary? If not, is there a way that it could be built that doesn't depend on the legacy frontend views? I haven't directly worked on the Course Home, so forgive me if I'm misunderstanding.

@mariajgrimaldi
Copy link
Member Author

Hi @kdmccormick 😄

Thanks for the heads up. I implemented this some time back and didn't consider the removal of the course home page. As I see it now, we shouldn't add the course home filter knowing the destiny of the course home.

@felipemontoya, do you have any objection?

@felipemontoya
Copy link
Member

I would not say I have an objection about removing, if the course home is going away is probably not worth to keep this in the PR. However from the extensibility of the platform we will probably want this same kind of controls for the new experience as well. Be that as a tool similar to filters in the MFEs or as a regular filters in the views that redirect to the MFEs or the APIs that load the data the MFE is showing.

In any case, that will require some definition work and I don't think it should drag the course_about filters into the longer discussion. I'm good if we take a part out of this and continue only with the course_about filter.

@mariajgrimaldi mariajgrimaldi force-pushed the MJG/course-about-render-filter branch from 7609795 to bb0f3f9 Compare April 7, 2022 14:01
@mariajgrimaldi mariajgrimaldi changed the title [BD-32] feat: add filter before course about/home rendering process starts [BD-32] feat: add filter before course about rendering process starts Apr 7, 2022
Copy link
Member

@felipemontoya felipemontoya left a comment

Choose a reason for hiding this comment

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

We are also ready here since the home fragment was removed.
A squash of the commits would be good though.

@mariajgrimaldi mariajgrimaldi force-pushed the MJG/course-about-render-filter branch from bb0f3f9 to 0223bc3 Compare April 11, 2022 12:59
@mariajgrimaldi mariajgrimaldi force-pushed the MJG/course-about-render-filter branch 4 times, most recently from 62b6dc5 to 696a51f Compare May 6, 2022 19:19
@mariajgrimaldi mariajgrimaldi force-pushed the MJG/course-about-render-filter branch from 696a51f to 9e5722e Compare May 6, 2022 19:31
@mariajgrimaldi mariajgrimaldi force-pushed the MJG/course-about-render-filter branch from 9e5722e to ccfa0b4 Compare May 11, 2022 17:41
@mariajgrimaldi mariajgrimaldi merged commit 6b8de6e into openedx:master May 11, 2022
@openedx-webhooks
Copy link

@mariajgrimaldi 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

github-actions bot added a commit that referenced this pull request Aug 8, 2022
<!--

🌰🌰
🌰🌰🌰🌰         🌰 Note: the Nutmeg master branch has been created.  Please consider whether your change
    🌰🌰🌰🌰     should also be applied to Nutmeg. If so, make another pull request against the
🌰🌰🌰🌰         open-release/nutmeg.master branch, or ping @nedbat for help or questions.
🌰🌰

Please give your pull request a short but descriptive title.
Use conventional commits to separate and summarize commits logically:
https://open-edx-proposals.readthedocs.io/en/latest/oep-0051-bp-conventional-commits.html

Use this template as a guide. Omit sections that don't apply. You may link to information rather than copy it.
More details about the template are at openedx/openedx-proposals#180
(link will be updated when that document merges)
-->

## Description

Backport filters that didn't make it to nutmeg release:

**Add filter before certificate creation starts**

(cherry picked from commit e8fa890)

**Add cohort change filter before moving users from cohorts**

(cherry picked from commit 465e5c0)

**Add filter before certificate rendering process starts**

(cherry picked from commit 7f974d1)

**Add filter before course dashboard rendering process starts**

(cherry picked from commit 895a649)

**Add filter before course about rendering process starts**

(cherry picked from commit ccfa0b4)

**Integrate cohort assignment filter definition to cohort model**

(cherry picked from commit ec69659)

## Supporting information

Refer to the BTR wg github issue for the rationale behind this PR: openedx/wg-build-test-release#187

## Testing instructions

1. Install the needed library release: `openedx-filters==0.7.0`
2. Install the samples library: 
`pip install git+https://github.com/eduNEXT/openedx-filters-samples.git@master#egg=openedx_filters_samples`
3. Then, configure each filter. If you want to test all the filters simultaneously, use this configuration and try to do each operation the filter is related to; the filter sample step will stop the operation.
```
OPEN_EDX_FILTERS_CONFIG = {
    "org.openedx.learning.certificate.creation.requested.v1": {
        "fail_silently": False,
        "pipeline": [
            "openedx_filters_samples.samples.pipeline.StopCertificateCreation"
        ]
    },
    "org.openedx.learning.cohort.change.requested.v1": {
        "fail_silently": False,
        "pipeline": [
            "openedx_filters_samples.samples.pipeline.StopCohortChange"
        ]
    },
    "org.openedx.learning.certificate.render.started.v1": {
        "fail_silently": False,
        "pipeline": [
            "openedx_filters_samples.samples.pipeline.RenderAlternativeCertificate",
        ]
    },
    "org.openedx.learning.dashboard.render.started.v1": {
        "fail_silently": False,
        "pipeline": [
            "openedx_filters_samples.samples.pipeline.RenderAlternativeDashboard",
        ]
    },
    "org.openedx.learning.course_about.render.started.v1": {
        "fail_silently": False,
        "pipeline": [
            "openedx_filters_samples.samples.pipeline.RenderAlternativeCourseAbout",
        ]
    },
    "org.openedx.learning.cohort.assignment.requested.v1": {
        "fail_silently": False,
        "pipeline": [
            "openedx_filters_samples.samples.pipeline.StopCohortAssignment"
        ]
    },
}
```

Please, for detailed instructions on how to test each filter, refer to each of these PR(s):

Filter for certificate creation:
#29949
Filter for cohort change:
#29964
Filter for certificate rendering:
#29976
Filter for dashboard rendering:
#29994
Filter for course about rendering:
#29996
Filter for cohort assignment:
#30431

## Deadline

For the next nutmeg release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blended PR is managed through 2U's blended developmnt program

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants