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

fix: refactor MakoService to allow specifying namespace per template #33061

Merged
merged 3 commits into from
Aug 21, 2023

Conversation

bradenmacdonald
Copy link
Contributor

@bradenmacdonald bradenmacdonald commented Aug 18, 2023

Description

Currently, the "Manage Access" menu in Studio is not working consistently (sometimes it does work though), due to a template error:

Screenshot 2023-08-18 at 10 47 28 AM

This is not the first error we've had with the MakoService being unable to find mako templates, and the problem stems from different search paths for "LMS templates" vs "CMS templates", and the fact that the runtime has this internal state that determines which paths to search for any given template. As you can see, the CMS runtime is often using the wrong paths, resulting in this error.

I believe that the best fix for this issue that will keep it from happening in the future, as it has happened at least 3 or 4 times so far, is to change the MakoService API to allow specifying the search path along with the template name. You want to render a template that's in lms/templates/...? Great, now call render_lms_template(). Want to render one that's in cms/templates/...? Great, now call render_cms_template().

Of course mako templates are terrible and they should all be replaced with django templates or React UI, but that's a battle for another day.

Supporting information

One of the past bugs: #32895

Testing instructions

  1. Create a course in Studio, set it's "Advanced Module List" to ["annotatable", "poll", "library_content", "lti_consumer"] .
  2. Add to the course: one of every "Advanced" XBlock listed, one each of library content, problem, text, video, and discussion.
  3. Make sure the studio_view ("Edit") and author view are working (for library content, configure a library then click "View >" - that's the author view; other blocks, the author view is just what you see in studio, and usually identical to the student view).
  4. Publish the unit and view it in the LMS to make sure all the blocks are working there too.

Deadline

ASAP - CAT-2 issue

Other info

Private-ref: MNG-3884

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Aug 18, 2023
@openedx-webhooks
Copy link

Thanks for the pull request, @bradenmacdonald! 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.

Copy link
Contributor

@rayzhou-bit rayzhou-bit 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.

I tested each block in studio, library and lms with local devstack and do not see any issues.

@bradenmacdonald bradenmacdonald merged commit d60cdc2 into openedx:master Aug 21, 2023
42 checks passed
@bradenmacdonald bradenmacdonald deleted the braden/makoservice-fix branch August 21, 2023 17:05
@openedx-webhooks
Copy link

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

@kenclary
Copy link
Contributor

I don't mind that this got merged, but I think the terminology is further obfuscating the problem.

This isn't about CMS vs LMS (in fact, it is only ever relevant to CMS). The namespace isn't being used as a namespace; it's being used as a switch between mako "engines," specifically between regular CMS and CMS "preview" (for authors previewing student views).

Basically I don't like the naming of these functions.

@bradenmacdonald
Copy link
Contributor Author

bradenmacdonald commented Aug 21, 2023

@kenclary The only difference between those "engines" is the DIRS argument which determines whether to search LMS dirs or CMS dirs. They don't have any difference in behavior, other than one searches the LMS paths and the common paths, while the other searches the CMS paths and the common paths. (And I guess the "namespace" is different, but that's just used to distinguish the engines for some reason, and has no impact on template functionality.)

So I thought this naming would be most clear to developers, as it reflects the actual difference/goal (set which template paths get searched), and not the mechanism by which that happens or the confusing term used ("namespace"). What would you suggest instead?

This isn't about CMS vs LMS

Let's say you want to render visibility_editor.html. Which function/engine you need to use depends only on whether it is located in lms/templates/visibility_editor.html or cms/templates/visibility_editor.html. So isn't that CMS vs LMS?

@edx-pipeline-bot
Copy link
Contributor

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

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

bszabo added a commit that referenced this pull request Aug 21, 2023
bszabo added a commit that referenced this pull request Aug 21, 2023
bradenmacdonald added a commit to open-craft/edx-platform that referenced this pull request Aug 22, 2023
bradenmacdonald added a commit that referenced this pull request Aug 23, 2023
…y (Take 2) (#33077)

* fix: refactor MakoService to allow specifying namespace per template (#33061)

* fix: instr. dashboard broken by bulk email reusing HtmlBlock studio_view

* fix: lint issue from unused import
mehedikhan72 pushed a commit to mehedikhan72/edx-platform that referenced this pull request Aug 24, 2023
mehedikhan72 pushed a commit to mehedikhan72/edx-platform that referenced this pull request Aug 24, 2023
mehedikhan72 pushed a commit to mehedikhan72/edx-platform that referenced this pull request Aug 24, 2023
…y (Take 2) (openedx#33077)

* fix: refactor MakoService to allow specifying namespace per template (openedx#33061)

* fix: instr. dashboard broken by bulk email reusing HtmlBlock studio_view

* fix: lint issue from unused import
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.

5 participants