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

Add openedx-filters hook to account settings before rendering it context #31295

Conversation

Henrrypg
Copy link
Contributor

@Henrrypg Henrrypg commented Nov 16, 2022

Description

This PR introduces a new openedx-filters hook:

  1. org.openedx.learning.student.settings.render.started.v1 hook in the platform at openedx/core/djangoapps/user_api/accounts/settings_views.py. This is implemented to hook the account settings context.

Users impacted by the change:

  • Users: Allow to get customized account settings.

Supporting information

openedx-filter: In this PR #46 is implemented this filter.

Testing instructions

You can have an example of this filter with its hook working in edunext-platform

You also have an example in openedx-filters-samples in this PR: eduNEXT/openedx-filters-samples#1

Deadline

None

Other information

Once accepted, this should be merged only after openedx/openedx-filters#46 is merged and the requirements are updated.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Nov 16, 2022
@openedx-webhooks
Copy link

openedx-webhooks commented Nov 16, 2022

Thanks for the pull request, @Henrrypg! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@Henrrypg Henrrypg marked this pull request as ready for review November 18, 2022 14:58
@Henrrypg Henrrypg marked this pull request as draft November 22, 2022 16:49
@Henrrypg Henrrypg force-pushed the hpg/add-filters-hook-registrationrenred-settingsrender branch from 1c2110d to 0501284 Compare November 30, 2022 17:30
@Henrrypg Henrrypg changed the title Add openedx-filters hook to registration before rendering of form description and account settings before rendering it context Add openedx-filters hook to account settings before rendering it context Nov 30, 2022
@Henrrypg Henrrypg marked this pull request as ready for review November 30, 2022 17:44
@mariajgrimaldi
Copy link
Member

mariajgrimaldi commented Dec 5, 2022

Hello! Thanks for your contribution. Please, add a testing example that works for this PR (not for edunext-platform), so it's easier for reviewers. You could use https://github.com/eduNEXT/openedx-filters-samples

@Henrrypg
Copy link
Contributor Author

Henrrypg commented Dec 5, 2022

@mariajgrimaldi As you suggested, i opened a PR in openedx-filters-samples with a testing example. What do you think?

@mphilbrick211
Copy link

Hi @Henrrypg! Just seeing if you are planning to re-run the failing checks on this?

CC: @mariajgrimaldi for review.

@mphilbrick211 mphilbrick211 added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Dec 16, 2022
@Henrrypg
Copy link
Contributor Author

Hello @mphilbrick211, i was working first with openedx/openedx-filters#46, thats why the checks are failling.


try:
context = AccountSettingsRenderStarted().run_filter(context=context)
except AccountSettingsRenderStarted.ErrorFilteringContext as exc:
Copy link
Member

@mariajgrimaldi mariajgrimaldi Dec 20, 2022

Choose a reason for hiding this comment

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

I was about to test this in conjunction the other PR (openedx-filters PR 46) but then realized this is not going to work. ErrorFilteringContext is not defined as one of the filter exceptions. Also, try to follow this implementation and adding unittests for this :)

@openedx-webhooks openedx-webhooks removed the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Dec 20, 2022
@mphilbrick211
Copy link

Hi @Henrrypg! Just checking in to see if you are planning to pursue this pull request?

@Henrrypg Henrrypg force-pushed the hpg/add-filters-hook-registrationrenred-settingsrender branch 2 times, most recently from 5760e2c to 8b1c90a Compare January 24, 2023 20:43
@Henrrypg
Copy link
Contributor Author

Henrrypg commented Jan 24, 2023

Hello @mphilbrick211 @mariajgrimaldi i just pushed a commit with the changes requested by @mariajgrimaldi, unitests and fix the implementation.

@mariajgrimaldi mariajgrimaldi self-assigned this Jan 31, 2023
Comment on lines 82 to 85
except AccountSettingsRenderStarted.RedirectToPage as exc:
return HttpResponseRedirect(exc.redirect_to)
except AccountSettingsRenderStarted.RenderCustomResponse as exc:
return exc.response
Copy link
Member

Choose a reason for hiding this comment

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

You're missing one exception. Please, use the other implementations as a guide.

}
return context

class TestAccountSettingsFilters(SharedModuleStoreTestCase):
Copy link
Member

Choose a reason for hiding this comment

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

I'd use these tests as a template for testing this kind of filters:

test_account_render_filter_executed
test_account_render_alternative
test_account_redirect
test_account_redirect_default
test_account_custom_response
test_account_render_without_filter_config

Those are precisely the same as here. I know this needs to be documented somewhere -we're working on it- but again, you could use them as a guide.

@mphilbrick211 mphilbrick211 added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Feb 1, 2023
@Henrrypg
Copy link
Contributor Author

Henrrypg commented Feb 17, 2023

How you suggested @mariajgrimaldi, i took your example filter and made some changes in favor of that. one exception was missing in filters pr but i already added it.

@mariajgrimaldi
Copy link
Member

mariajgrimaldi commented Feb 20, 2023

I'll check on this again tomorrow! After reviewing openedx/openedx-filters#46

@mphilbrick211 mphilbrick211 removed the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Feb 21, 2023
@mariajgrimaldi
Copy link
Member

@Henrrypg: can you rebase with the base branch? Also, I left a comment here: eduNEXT/openedx-filters-samples#1. It'd be convenient if you fixed it so we can test it easily :)

@mariajgrimaldi
Copy link
Member

openedx-filters v1.2.0 was released already!

@Henrrypg
Copy link
Contributor Author

Henrrypg commented Mar 1, 2023

@mariajgrimaldi Sure! I'll work on this

@Henrrypg Henrrypg force-pushed the hpg/add-filters-hook-registrationrenred-settingsrender branch from 53f81b8 to 87b9b4b Compare March 6, 2023 14:38
@Henrrypg
Copy link
Contributor Author

Henrrypg commented Mar 6, 2023

@mariajgrimaldi I rebased with master and eduNEXT/openedx-filters-samples#1 is already merged :)

@mariajgrimaldi
Copy link
Member

mariajgrimaldi commented Mar 7, 2023

These are the instructions I followed:

  • Install the latest openedx-filters package
  • Install openedx-filters-samples
  • Add the following settings to your environment:
OPEN_EDX_FILTERS_CONFIG = {
    "org.openedx.learning.student.settings.render.started.v1": {
        "fail_silently": False,
        "pipeline": [
            "openedx_filters_samples.samples.pipeline.StopAccountSettingsRender"
        ]
    }
}
  • Deactivate the account MFE (this filter applies just to the legacy account view)
  • Since the filter redirects to "", you should stay on the current page.

This looks good. The only thing that worries me is our maintenance plan for filters used in legacy pages. cc @felipemontoya

@mariajgrimaldi
Copy link
Member

@Henrrypg: can you please rebase with master and fix conflicts?

@Henrrypg Henrrypg force-pushed the hpg/add-filters-hook-registrationrenred-settingsrender branch from 87b9b4b to 5cbceee Compare March 7, 2023 20:21
@Henrrypg
Copy link
Contributor Author

Henrrypg commented Mar 7, 2023

Is done @mariajgrimaldi, checks are failing because openedx-filters version in master

@mariajgrimaldi
Copy link
Member

@Henrrypg: can you bump openedx-filters to 1.2.0? that's the latest release which has the filter you're including

@felipemontoya
Copy link
Member

The only thing that worries me is our maintenance plan for filters used in legacy pages.

As a user of a filter what I would expect:

  • for the page is being removed, I am notified for one stable release
  • when possible, the filter is used in the new replacement page or the API that MFEs call for the same feature. Otherwise a different but equivalent filter exists for the replacement page.

Do you think one or both of those are applicable here?

@mariajgrimaldi
Copy link
Member

mariajgrimaldi commented Mar 8, 2023

As a user of a filter what I would expect:

  • for the page is being removed, I am notified for one stable release
  • when possible, the filter is used in the new replacement page or the API that MFEs call for the same feature. Otherwise a different but equivalent filter exists for the replacement page.

Do you think one or both of those are applicable here?

That sounds good! I will take those ideas into our documentation so it's clear for future implementations. I'm attaching the DEPR ticket for account pages here for better tracking.

I also created an issue in openedx-filters: openedx/openedx-filters#73

@Henrrypg Henrrypg force-pushed the hpg/add-filters-hook-registrationrenred-settingsrender branch from 4107b3f to bec74b2 Compare March 8, 2023 17:42
@mariajgrimaldi
Copy link
Member

@Henrrypg: I'll approve once tests pass :). Let me know!

@Henrrypg
Copy link
Contributor Author

Henrrypg commented Mar 8, 2023

@mariajgrimaldi Is ready to test now :)

@Henrrypg Henrrypg force-pushed the hpg/add-filters-hook-registrationrenred-settingsrender branch from e8ea4d3 to 776e65b Compare March 9, 2023 14:49
@Henrrypg
Copy link
Contributor Author

Henrrypg commented Mar 9, 2023

@mariajgrimaldi i just rebased and checks are passing :)

Copy link
Member

@mariajgrimaldi mariajgrimaldi left a comment

Choose a reason for hiding this comment

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

LGTM

@mariajgrimaldi mariajgrimaldi merged commit d7ca7c1 into openedx:master Mar 9, 2023
@openedx-webhooks
Copy link

@Henrrypg 🎉 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants