Skip to content

Conversation

@salman2013
Copy link
Contributor

@salman2013 salman2013 commented Nov 20, 2025

Description

In this PR i converted discussion's html files from mako into django template.

I converted following files.
_discussion_inline.html‎
_discussion_inline_studio.html‎
_filter_dropdown.html
_thread_list_template.html
_underscore_templates.html‎
discussion_board_fragment.html‎

Ticket Reference:
#36539

Acceptance criteria

  • html template should be refactored to django template with minimal code changes
  • Discussion XBlock experience shouldn't be changed
  • All test cases should be passed on the edx-platform

How to test this PR

To enable discussion xblock:

tutor plugins install forum
tutor plugins enable forum
tutor dev do init -l forum

To show the builtin discussion xblock component on unit page:

  • Go to studio admin site.
  • Go into discussion configurations (/admin/discussions/discussionsconfiguration/)
  • Update the provide to 'legacy'

To show the legacy discussion view from discussion tab:

  • Go to studio admin site.
  • Go into flags (/admin/waffle/flag/)
  • disable this flag 'discussions.enable_discussions_mfe'

Testing results

Sanbox testing results.

Screenshot 2025-11-28 at 6 31 46 PM Screenshot 2025-11-28 at 6 31 01 PM Screenshot 2025-11-28 at 6 31 15 PM Screenshot 2025-11-28 at 6 31 38 PM Screenshot 2025-11-28 at 6 32 11 PM Screenshot 2025-11-28 at 6 32 26 PM Screenshot 2025-11-28 at 6 32 41 PM

Note: The voting option is not working on master branch too, i did not look into that as this comes out of the scope of this PR, i will look into extraction of discussion block.
Screenshot 2026-01-02 at 6 29 30 PM

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

openedx-webhooks commented Nov 20, 2025

Thanks for the pull request, @salman2013!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@salman2013 salman2013 force-pushed the salman/discussion-django-template branch from 8c884bf to b9d018e Compare November 25, 2025 11:57
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Nov 25, 2025
@salman2013 salman2013 added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Nov 27, 2025
@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

Copy link
Contributor

@farhan farhan left a comment

Choose a reason for hiding this comment

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

have some queries

<span class="forum-nav-browse-title">${_("Posts I'm Following")}</span>
<span class="forum-nav-browse-title">{% trans "Posts I'm Following" as tmsg%} {{tmsg|force_escape}}</span>
</li>
${HTML(render_dropdown(category_map, []))}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this removal intentional?

Copy link
Contributor Author

@salman2013 salman2013 Dec 23, 2025

Choose a reason for hiding this comment

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

Yes it was intentional as django templates do not support calling Python functions directly or embedding HTML that way.

Copy link
Contributor Author

@salman2013 salman2013 Jan 5, 2026

Choose a reason for hiding this comment

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

I converted the render_dropdown code into django template formate and include the file in replacement of this.

The code is actually recursive methods calling which is not supported in django template so the possible solution i device is to make separate templates
_dropdown_category.html
_dropdown_items.html
_dropdown_entry.html
which include them each other in replacement of method calling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Testing results:
To make sure the converted code is working as expected i tested it by commented the code (not including category) first and then with including the category.

When we comment the code

{% include "discussion/_dropdown_items.html" with map=category_map topic_list="" %}

no category option available.
Screenshot 2026-01-05 at 7 40 28 PM

With conversion of render_dropdown into django templates and including file the category option is working as expected.
Screenshot 2026-01-05 at 7 40 07 PM
Screenshot 2026-01-05 at 7 50 30 PM

%>
{% load i18n %}

<%def name="render_dropdown(map, topic_list)">
Copy link
Contributor

Choose a reason for hiding this comment

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

render_dropdown seems not converted and was used at the end of the file.

Copy link
Contributor Author

@salman2013 salman2013 Dec 23, 2025

Choose a reason for hiding this comment

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

Thanks for looking into it.
Interestingly functionality is working as expected without it.
Reason is this template _filter_dropdown.html is including inside discussion_board_fragment.html

it is not passing any category and topic list so this render_dropdown is doing nothing.

As this is legacy discussion UI so i did not convert that part into django template.

I looked into the actual implementation for the finding its functionality just sharing here for reference
795c116
3de6e77

Copy link
Contributor Author

@salman2013 salman2013 Jan 5, 2026

Choose a reason for hiding this comment

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

I corrected my understanding regarding the context passing, the context passes to include tag like <%include file="_filter_dropdown.html" /> from parent template automatically.
I converted the code into django template.
The code is actually recursive methods calling which is not supported in django template so the possible solution i device is to make separate templates
_dropdown_category.html
_dropdown_items.html
_dropdown_entry.html
which include them each other in replacement of method calling.

Testing results:
#37662 (comment)

% if child in map["entries"] and c_type == TYPE_ENTRY:
${HTML(render_entry(map["entries"], child, topic_list))}
%else:
${HTML(render_category(map["subcategories"], child, topic_list))}
Copy link
Contributor

Choose a reason for hiding this comment

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

render_category and render_entry also seems not converted.

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@salman2013 salman2013 requested a review from farhan January 5, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

create-sandbox open-craft-grove should create a sandbox environment from this PR open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

5 participants