chore: convert mako template into django template
This commit is contained in:
@@ -11,6 +11,7 @@ import json
|
||||
import uuid
|
||||
|
||||
from unittest import mock
|
||||
from unittest.mock import patch
|
||||
import ddt
|
||||
from django.conf import settings
|
||||
from django.test.utils import override_settings
|
||||
@@ -18,9 +19,10 @@ from django.urls import reverse
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from web_fragments.fragment import Fragment
|
||||
from xblock.field_data import DictFieldData
|
||||
from xmodule.discussion_block import DiscussionXBlock, loader
|
||||
from xmodule.discussion_block import DiscussionXBlock
|
||||
from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import BlockFactory, ToyCourseFactory
|
||||
from xmodule.tests.helpers import mock_render_template
|
||||
|
||||
from lms.djangoapps.course_api.blocks.tests.helpers import deserialize_usage_key
|
||||
from lms.djangoapps.courseware.block_render import get_block_for_descriptor
|
||||
@@ -153,15 +155,15 @@ class TestViews(TestDiscussionXBlock):
|
||||
assert self.render_template.call_count == 1
|
||||
return self.render_template.call_args_list[0][0][0]
|
||||
|
||||
def test_studio_view(self):
|
||||
@patch('xblock.utils.resources.ResourceLoader.render_django_template', side_effect=mock_render_template)
|
||||
def test_studio_view(self, mock_render_django_template):
|
||||
"""
|
||||
Test for the studio view.
|
||||
"""
|
||||
fragment = self.block.author_view()
|
||||
assert isinstance(fragment, Fragment)
|
||||
assert fragment.content == self.template_canary
|
||||
self.render_template.assert_called_once_with(
|
||||
'discussion/_discussion_inline_studio.html',
|
||||
mock_render_django_template.assert_called_once_with(
|
||||
'templates/discussion/_discussion_inline_studio.html',
|
||||
{
|
||||
'discussion_id': self.discussion_id,
|
||||
'is_visible': True,
|
||||
@@ -192,10 +194,11 @@ class TestViews(TestDiscussionXBlock):
|
||||
}
|
||||
|
||||
self.block.has_permission = lambda perm: permission_dict[perm]
|
||||
with mock.patch.object(loader, 'render_template', mock.Mock):
|
||||
with mock.patch('xmodule.discussion_block.render_to_string', return_value='') as mock_render:
|
||||
self.block.student_view()
|
||||
|
||||
context = self.get_template_context()
|
||||
# Get context from the mock call
|
||||
assert mock_render.call_count == 1
|
||||
context = mock_render.call_args_list[0][0][1]
|
||||
|
||||
for permission_name, expected_value in expected_permissions.items():
|
||||
assert expected_value == context[permission_name]
|
||||
@@ -204,7 +207,7 @@ class TestViews(TestDiscussionXBlock):
|
||||
"""
|
||||
Test proper js init function is called.
|
||||
"""
|
||||
with mock.patch.object(loader, 'render_template', mock.Mock):
|
||||
with mock.patch('xmodule.discussion_block.render_to_string', return_value=''):
|
||||
fragment = self.block.student_view()
|
||||
assert fragment.js_init_fn == 'DiscussionInlineBlock'
|
||||
|
||||
|
||||
@@ -1,78 +1,76 @@
|
||||
## mako
|
||||
{% load static i18n %}
|
||||
|
||||
<%namespace name='static' file='../static_content.html'/>
|
||||
|
||||
<%page expression_filter="h"/>
|
||||
|
||||
<%!
|
||||
import json
|
||||
from django.utils.translation import gettext as _
|
||||
from django.template.defaultfilters import escapejs
|
||||
from django.urls import reverse
|
||||
|
||||
from lms.djangoapps.discussion.django_comment_client.permissions import has_permission
|
||||
from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
%>
|
||||
|
||||
<section class="discussion discussion-board page-content-container" id="discussion-container"
|
||||
data-course-id="${course.id}"
|
||||
data-user-create-comment="${json.dumps(can_create_comment)}"
|
||||
data-user-create-subcomment="${json.dumps(can_create_subcomment)}"
|
||||
<section class="discussion discussion-board page-content-container"
|
||||
id="discussion-container"
|
||||
data-course-id="{{ course.id }}"
|
||||
data-user-create-comment="{{ can_create_comment|yesno:'true,false' }}"
|
||||
data-user-create-subcomment="{{ can_create_subcomment|yesno:'true,false' }}"
|
||||
data-read-only="false"
|
||||
data-sort-preference="${sort_preference}"
|
||||
data-flag-moderator="${json.dumps(flag_moderator)}"
|
||||
data-user-group-id="${user_group_id}">
|
||||
data-sort-preference="{{ sort_preference }}"
|
||||
data-flag-moderator="{{ flag_moderator|yesno:'true,false' }}"
|
||||
data-user-group-id="{{ user_group_id }}">
|
||||
|
||||
<header class="page-header has-secondary">
|
||||
## Breadcrumb navigation
|
||||
{# Breadcrumb navigation #}
|
||||
<div class="page-header-main">
|
||||
<nav aria-label="${_('Discussions')}" class="sr-is-focusable" tabindex="-1">
|
||||
<nav aria-label="{% trans 'Discussions' as tmsg %} {{tmsg|force_escape}}" class="sr-is-focusable" tabindex="-1">
|
||||
<div class="has-breadcrumbs"></div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div class="page-header-secondary">
|
||||
## Add Post button
|
||||
% if has_permission(user, 'create_thread', course.id):
|
||||
{# Add Post button #}
|
||||
{% if can_create_thread %}
|
||||
<div class="forum-actions">
|
||||
<button class="btn btn-outline-primary btn-small new-post-btn">${_("Add a Post")}</button>
|
||||
<button class="btn btn-outline-primary btn-small new-post-btn">
|
||||
{% trans "Add a Post" as tmsg %} {{tmsg|force_escape}}
|
||||
</button>
|
||||
</div>
|
||||
% endif
|
||||
## Search box
|
||||
{% endif %}
|
||||
{# Search box #}
|
||||
<div class="forum-search"></div>
|
||||
</div>
|
||||
</header>
|
||||
% if course_expiration_fragment:
|
||||
${HTML(course_expiration_fragment.content)}
|
||||
% endif
|
||||
|
||||
{% if course_expiration_fragment %}
|
||||
{{ course_expiration_fragment.content|safe }}
|
||||
{% endif %}
|
||||
|
||||
<div class="page-content"
|
||||
% if getattr(course, 'language'):
|
||||
lang="${course.language}"
|
||||
% endif
|
||||
{% if course.language %}
|
||||
lang="{{ course.language }}"
|
||||
{% endif %}
|
||||
>
|
||||
<div class="discussion-body">
|
||||
<main id="main" class="discussion-column" aria-label="Content" tabindex="-1">
|
||||
<article class="new-post-article is-hidden" style="display: none" tabindex="-1" aria-label="${_("New topic form")}"></article>
|
||||
<article class="new-post-article is-hidden" style="display: none" tabindex="-1" aria-label="{% trans 'New topic form' as tmsg %} {{tmsg|force_escape}}">
|
||||
</article>
|
||||
<div class="forum-content"></div>
|
||||
</main>
|
||||
<aside class="forum-nav" role="complementary" aria-label="${_("Discussion thread list")}">
|
||||
<%include file="_filter_dropdown.html" />
|
||||
<aside class="forum-nav" role="complementary" aria-label="{% trans 'Discussion thread list' as tmsg %} {{tmsg|force_escape}}">
|
||||
{% include "discussion/_filter_dropdown.html" %}
|
||||
<div class="discussion-thread-list-container"></div>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<%include file="_underscore_templates.html" />
|
||||
<%include file="_thread_list_template.html" />
|
||||
{% include "discussion/_underscore_templates.html" %}
|
||||
{% include "discussion/_thread_list_template.html" %}
|
||||
|
||||
<%static:require_module_async module_name="js/commerce/track_ecommerce_events" class_name="TrackECommerceEvents">
|
||||
<script>
|
||||
require(["js/commerce/track_ecommerce_events"], function (TrackECommerceEvents) {
|
||||
|
||||
var fbeLink = $("#FBE_banner");
|
||||
var fbeLink = $("#FBE_banner");
|
||||
|
||||
TrackECommerceEvents.trackUpsellClick(fbeLink, 'discussion_audit_access_expires', {
|
||||
pageName: "discussion_tab",
|
||||
linkType: "link",
|
||||
linkCategory: "FBE_banner"
|
||||
});
|
||||
|
||||
</%static:require_module_async>
|
||||
TrackECommerceEvents.trackUpsellClick(
|
||||
fbeLink,
|
||||
'discussion_audit_access_expires',
|
||||
{
|
||||
pageName: "discussion_tab",
|
||||
linkType: "link",
|
||||
linkCategory: "FBE_banner"
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -560,7 +560,8 @@ def _create_discussion_board_context(request, base_context, thread=None):
|
||||
'is_commentable_divided': is_commentable_divided(course_key, discussion_id, course_discussion_settings),
|
||||
# If the default topic id is None the front-end code will look for a topic that contains "General"
|
||||
'discussion_default_topic_id': _get_discussion_default_topic_id(course),
|
||||
'enable_daily_digest': is_forum_daily_digest_enabled()
|
||||
'enable_daily_digest': is_forum_daily_digest_enabled(),
|
||||
'PLATFORM_NAME': settings.PLATFORM_NAME
|
||||
})
|
||||
context.update(
|
||||
get_experiment_user_metadata_context(
|
||||
|
||||
@@ -1,44 +1,45 @@
|
||||
<%page expression_filter="h"/>
|
||||
{% load i18n %}
|
||||
|
||||
<%include file="_underscore_templates.html" />
|
||||
<%include file="_thread_list_template.html" />
|
||||
{% include "discussion/_underscore_templates.html" %}
|
||||
{% include "discussion/_thread_list_template.html" %}
|
||||
|
||||
<%!
|
||||
from django.utils.translation import gettext as _
|
||||
from json import dumps as json_dumps
|
||||
from openedx.core.djangolib.js_utils import js_escaped_string
|
||||
%>
|
||||
|
||||
<div class="discussion-module" data-discussion-id="${discussion_id}"
|
||||
data-user-create-comment="${json_dumps(can_create_comment)}"
|
||||
data-user-create-subcomment="${json_dumps(can_create_subcomment)}"
|
||||
data-read-only="${'false' if can_create_thread else 'true'}">
|
||||
% if not user.is_authenticated:
|
||||
<div class="discussion-module" data-discussion-id="{{ discussion_id }}"
|
||||
data-user-create-comment="{{ can_create_comment|yesno:"true,false" }}"
|
||||
data-user-create-subcomment="{{ can_create_subcomment|yesno:"true,false" }}"
|
||||
data-read-only="{% if can_create_thread %}false{% else %}true{% endif %}">
|
||||
{% if not user.is_authenticated %}
|
||||
<div class="page-banner">
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<span class="icon icon-alert fa fa fa-warning" aria-hidden="true"></span>
|
||||
<div class="message-content">${login_msg}</div>
|
||||
<span class="icon icon-alert fa fa-warning" aria-hidden="true"></span>
|
||||
<div class="message-content">{{ login_msg }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
% endif
|
||||
{% endif %}
|
||||
|
||||
<div class="discussion-module-header">
|
||||
<h3 class="hd hd-3 discussion-module-title">${_(display_name)}</h3>
|
||||
<div class="inline-discussion-topic"><span class="inline-discussion-topic-title">${_("Topic:")}</span> ${discussion_category}
|
||||
% if discussion_target:
|
||||
/ ${discussion_target}
|
||||
%endif
|
||||
</div>
|
||||
<h3 class="hd hd-3 discussion-module-title">
|
||||
{% filter force_escape %}
|
||||
{% blocktrans with title=display_name %}{{ title }}{% endblocktrans %}
|
||||
{% endfilter %}
|
||||
</h3>
|
||||
<div class="inline-discussion-topic">
|
||||
<span class="inline-discussion-topic-title">{% trans "Topic:" as tmsg %} {{tmsg|force_escape}}</span>
|
||||
{{ discussion_category }}
|
||||
{% if discussion_target %}
|
||||
/ {{ discussion_target }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<button class="discussion-show btn"
|
||||
data-discussion-id="${discussion_id}"
|
||||
${"disabled=disabled" if not user.is_authenticated else ""}>
|
||||
<span class="button-text">${_("Show Discussion")}</span>
|
||||
data-discussion-id="{{ discussion_id }}"
|
||||
{% if not user.is_authenticated %}disabled="disabled"{% endif %}>
|
||||
<span class="button-text">{% trans "Show Discussion" as tmsg %} {{tmsg|force_escape}}</span>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var $$course_id = "${course_id | n, js_escaped_string}";
|
||||
var $$course_id = "{{ course_id|escapejs }}";
|
||||
|
||||
function DiscussionInlineBlock(runtime, element) {
|
||||
'use strict';
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<%! from django.utils.translation import gettext as _ %>
|
||||
<%page expression_filter="h"/>
|
||||
{% load i18n %}
|
||||
|
||||
<div class="discussion-module" data-discussion-id="${discussion_id}">
|
||||
<div class="discussion-module" data-discussion-id="{{ discussion_id }}">
|
||||
<p>
|
||||
<span class="discussion-preview">
|
||||
<span class="icon fa fa-comment"/>
|
||||
${_("To view live discussions, click Preview or View Live in Unit Settings.")}<br />
|
||||
${_("Discussion ID: {discussion_id}").format(discussion_id=discussion_id)}
|
||||
% if not is_visible:
|
||||
<br /><b>${_('The discussion block is disabled for this course as it is not using a compatible discussion provider.')}</b>
|
||||
% endif
|
||||
<span class="icon fa fa-comment"></span>
|
||||
{% trans "To view live discussions, click Preview or View Live in Unit Settings." as tmsg %} {{tmsg|force_escape}}<br />
|
||||
{% filter force_escape %}
|
||||
{% blocktrans with discussion_id=discussion_id %}Discussion ID: {{ discussion_id }}{% endblocktrans %}
|
||||
{% endfilter %}
|
||||
{% if not is_visible %}
|
||||
<br /><b>{% trans "The discussion block is disabled for this course as it is not using a compatible discussion provider." as tmsg %} {{tmsg|force_escape}}</b>
|
||||
{% endif %}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
12
lms/templates/discussion/_dropdown_category.html
Normal file
12
lms/templates/discussion/_dropdown_category.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<li class="forum-nav-browse-menu-item"
|
||||
id='{{ category_name|force_escape }}'
|
||||
role="option">
|
||||
<span class="forum-nav-browse-title">{{ category_name|force_escape }}</span>
|
||||
<ul class="forum-nav-browse-submenu" role="presentation">
|
||||
{% if topic_list %}
|
||||
{% with new_topic_list=topic_list|add:", "|add:category_name %}
|
||||
{% include "discussion/_dropdown_items.html" with category_map=category topic_list=new_topic_list %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
</li>
|
||||
14
lms/templates/discussion/_dropdown_entry.html
Normal file
14
lms/templates/discussion/_dropdown_entry.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<li class="forum-nav-browse-menu-item"
|
||||
data-discussion-id='{{ entry.id|force_escape }}'
|
||||
id='{{ entry.id|force_escape }}'
|
||||
data-divided="{{ entry.is_divided|yesno:'true,false' }}"
|
||||
role="option">
|
||||
{% if entry_name %}
|
||||
<span class="forum-nav-browse-title">
|
||||
{% if topic_list %}
|
||||
<span class="sr">{{ topic_list|force_escape }}, </span>
|
||||
{% endif %}
|
||||
{{ entry_name|force_escape }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</li>
|
||||
15
lms/templates/discussion/_dropdown_items.html
Normal file
15
lms/templates/discussion/_dropdown_items.html
Normal file
@@ -0,0 +1,15 @@
|
||||
{% for child, c_type in map.children %}
|
||||
{% if c_type == "entry" %}
|
||||
{% for entry_key, entry_value in map.entries.items %}
|
||||
{% if entry_key == child %}
|
||||
{% include "discussion/_dropdown_entry.html" with entry_name=child entry=entry_value topic_list=topic_list %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for category_key, category_value in map.subcategories.items %}
|
||||
{% if category_key == child %}
|
||||
{% include "discussion/_dropdown_category.html" with category_name=child category=category_value topic_list=topic_list %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
@@ -1,71 +1,36 @@
|
||||
<%page expression_filter="h"/>
|
||||
<%!
|
||||
from django.utils.translation import gettext as _
|
||||
from lms.djangoapps.discussion.django_comment_client.constants import TYPE_ENTRY
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
%>
|
||||
{% load i18n %}
|
||||
|
||||
<%def name="render_dropdown(map, topic_list)">
|
||||
% for child, c_type in map["children"]:
|
||||
% 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))}
|
||||
%endif
|
||||
%endfor
|
||||
</%def>
|
||||
<div class="forum-nav-browse-menu-wrapper"
|
||||
style="display: none"
|
||||
aria-label="{% trans 'Discussion topics list' as tmsg %} {{tmsg|force_escape}}">
|
||||
|
||||
<%def name="render_entry(entries, entry, topic_list)">
|
||||
<li
|
||||
class="forum-nav-browse-menu-item"
|
||||
data-discussion-id='${entries[entry]["id"]}'
|
||||
id='${entries[entry]["id"]}'
|
||||
data-divided="${str(entries[entry]['is_divided']).lower()}"
|
||||
role="option"
|
||||
>
|
||||
%if entry:
|
||||
<span class="forum-nav-browse-title">
|
||||
%if topic_list:
|
||||
<span class="sr">
|
||||
${', '.join(topic_list)},
|
||||
</span>
|
||||
%endif
|
||||
${entry}
|
||||
</span>
|
||||
%endif
|
||||
</li>
|
||||
</%def>
|
||||
|
||||
<%def name="render_category(categories, category, topic_list)">
|
||||
<li class="forum-nav-browse-menu-item"
|
||||
id='${category | n, decode.utf8}'
|
||||
role="option"
|
||||
>
|
||||
<span class="forum-nav-browse-title">${category}</span>
|
||||
<ul class="forum-nav-browse-submenu" role="presentation">
|
||||
<% topic_list.append(category) %>
|
||||
${HTML(render_dropdown(categories[category], topic_list))}
|
||||
<% topic_list.remove(category) %>
|
||||
</ul>
|
||||
</li>
|
||||
</%def>
|
||||
|
||||
<div class="forum-nav-browse-menu-wrapper" style="display: none" aria-label="${_("Discussion topics list")}">
|
||||
<form class="forum-nav-browse-filter" autocomplete="off">
|
||||
<label for="forum-nav-browse-filter-input" aria-label='${_("Filter Topics")}' class="field-label">
|
||||
<span class="field-label-text">${_("Filter Topics")}</span>
|
||||
<input type="text" id="forum-nav-browse-filter-input" role="combobox" aria-expanded="true" aria-owns="discussion_topics_listbox" aria-autocomplete="list" class="forum-nav-browse-filter-input" placeholder="${_("filter topics")}">
|
||||
<label for="forum-nav-browse-filter-input"
|
||||
aria-label="{% trans 'Filter Topics' as tmsg %} {{tmsg|force_escape}}"
|
||||
class="field-label">
|
||||
|
||||
<span class="field-label-text">{% trans "Filter Topics" as tmsg %} {{tmsg|force_escape}}</span>
|
||||
|
||||
<input type="text"
|
||||
id="forum-nav-browse-filter-input"
|
||||
role="combobox"
|
||||
aria-expanded="true"
|
||||
aria-owns="discussion_topics_listbox"
|
||||
aria-autocomplete="list"
|
||||
class="forum-nav-browse-filter-input"
|
||||
placeholder="{% trans 'filter topics' as tmsg %} {{tmsg|force_escape}}">
|
||||
|
||||
<span class="icon fa fa-filter" aria-hidden="true"></span>
|
||||
</label>
|
||||
</form>
|
||||
<ul class="forum-nav-browse-menu" role="listbox" id="discussion_topics_listbox">
|
||||
<li class="forum-nav-browse-menu-item forum-nav-browse-menu-all" role="option" id="all_discussions">
|
||||
<span class="forum-nav-browse-title">${_("All Discussions")}</span>
|
||||
<span class="forum-nav-browse-title">{% trans "All Discussions" as tmsg %} {{tmsg|force_escape}}</span>
|
||||
</li>
|
||||
<li class="forum-nav-browse-menu-item forum-nav-browse-menu-following" role="option" id="posts_following">
|
||||
<span class="icon fa fa-star" aria-hidden="true"></span>
|
||||
<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, []))}
|
||||
{% include "discussion/_dropdown_items.html" with map=category_map topic_list="" %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -1,47 +1,51 @@
|
||||
<%page expression_filter="h"/>
|
||||
<%! from django.utils.translation import gettext as _ %>
|
||||
{% load i18n %}
|
||||
|
||||
<script type="text/template" id="thread-list-template">
|
||||
<div class="forum-nav-thread-list-wrapper" id="sort-filter-wrapper" tabindex="-1">
|
||||
<div class="forum-nav-refine-bar">
|
||||
<label class="forum-nav-filter-main">
|
||||
## Translators: This labels a filter menu in forum navigation
|
||||
<span class="sr">${_("Filter:")}</span>
|
||||
{# Translators: This labels a filter menu in forum navigation #}
|
||||
<span class="sr">{% trans "Filter:" as tmsg %} {{tmsg|force_escape}}</span>
|
||||
<select class="forum-nav-filter-main-control">
|
||||
## Translators: This is a menu option for showing all forum threads unfiltered
|
||||
<option value="all">${_("Show all posts")}</option>
|
||||
## Translators: This is a menu option for showing only unread forum threads
|
||||
<option value="unread">${_("Unread posts")}</option>
|
||||
## Translators: This is a menu option for showing only unanswered forum
|
||||
## question threads
|
||||
<option value="unanswered">${_("Unanswered posts")}</option>
|
||||
%if flag_moderator:
|
||||
## Translators: This is a menu option for showing only forum threads flagged
|
||||
## for abuse
|
||||
<option value="flagged">${_("Flagged")}</option>
|
||||
%endif
|
||||
{# Translators: This is a menu option for showing all forum threads unfiltered #}
|
||||
<option value="all">{% trans "Show all posts" as tmsg %} {{tmsg|force_escape}}</option>
|
||||
{# Translators: This is a menu option for showing only unread forum threads #}
|
||||
<option value="unread">{% trans "Unread posts" as tmsg %} {{tmsg|force_escape}}</option>
|
||||
{# Translators: This is a menu option for showing only unanswered forum #}
|
||||
{# question threads #}
|
||||
<option value="unanswered">{% trans "Unanswered posts" as tmsg %} {{tmsg|force_escape}}</option>
|
||||
{% if flag_moderator %}
|
||||
{# Translators: This is a menu option for showing only forum threads flagged #}
|
||||
{# for abuse #}
|
||||
<option value="flagged">{% trans "Flagged" as tmsg %} {{tmsg|force_escape}}</option>
|
||||
{% endif %}
|
||||
</select>
|
||||
## xss-lint: disable=python-parse-error,python-wrap-html
|
||||
</label>${"<% if (isDiscussionDivisionEnabled && isPrivilegedUser) { %>" | n, decode.utf8}<label class="forum-nav-filter-cohort">
|
||||
## Translators: This labels a group menu in forum navigation
|
||||
<span class="sr">${_("Group:")}</span>
|
||||
<select class="forum-nav-filter-cohort-control">
|
||||
<option value="">${_("in all groups")}</option>
|
||||
## groups is not iterable sometimes because inline discussions xmodule doesn't pass it
|
||||
%for group in (groups or []):
|
||||
<option value="${group['id']}">${group['name']}</option>
|
||||
%endfor
|
||||
</select>
|
||||
## xss-lint: disable=python-parse-error,python-wrap-html
|
||||
</label>${"<% } %>" | n, decode.utf8}<label class="forum-nav-sort">
|
||||
## Translators: This labels a sort menu in forum navigation
|
||||
<span class="sr">${_("Sort:")}</span>
|
||||
</label>
|
||||
{% if isDiscussionDivisionEnabled and isPrivilegedUser %}
|
||||
<label class="forum-nav-filter-cohort">
|
||||
{# Translators: This labels a group menu in forum navigation #}
|
||||
<span class="sr">{% trans "Group:" as tmsg %} {{tmsg|force_escape}}</span>
|
||||
<select class="forum-nav-filter-cohort-control">
|
||||
<option value="">{% trans "in all groups" as tmsg %} {{tmsg|force_escape}}</option>
|
||||
{% if groups %}
|
||||
{% for group in groups %}
|
||||
<option value="{{ group.id|force_escape }}">{{ group.name|force_escape }}</option>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</select>
|
||||
</label>
|
||||
{% endif %}
|
||||
|
||||
<label class="forum-nav-sort">
|
||||
{# Translators: This labels a sort menu in forum navigation #}
|
||||
<span class="sr">{% trans "Sort:" as tmsg %} {{tmsg|force_escape}}</span>
|
||||
<select class="forum-nav-sort-control">
|
||||
## Translators: This is a menu option for sorting forum threads
|
||||
<option value="activity">${_("by recent activity")}</option>
|
||||
## Translators: This is a menu option for sorting forum threads
|
||||
<option value="comments">${_("by most activity")}</option>
|
||||
## Translators: This is a menu option for sorting forum threads
|
||||
<option value="votes">${_("by most votes")}</option>
|
||||
{# Translators: This is a menu option for sorting forum threads #}
|
||||
<option value="activity">{% trans "by recent activity" as tmsg %} {{tmsg|force_escape}}</option>
|
||||
{# Translators: This is a menu option for sorting forum threads #}
|
||||
<option value="comments">{% trans "by most activity" as tmsg %} {{tmsg|force_escape}}</option>
|
||||
{# Translators: This is a menu option for sorting forum threads #}
|
||||
<option value="votes">{% trans "by most votes" as tmsg %} {{tmsg|force_escape}}</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
<%page expression_filter="h"/>
|
||||
<%namespace name='static' file='../static_content.html'/>
|
||||
<%
|
||||
from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string
|
||||
enable_discussion_home_panel = settings.FEATURES.get('ENABLE_DISCUSSION_HOME_PANEL', False)
|
||||
%>
|
||||
{% load static %}
|
||||
|
||||
<script type="text/javascript">
|
||||
window.PLATFORM_NAME = "${settings.PLATFORM_NAME | n, js_escaped_string}";
|
||||
% if enable_discussion_home_panel:
|
||||
window.ENABLE_DISCUSSION_HOME_PANEL = true;
|
||||
% else:
|
||||
window.ENABLE_DISCUSSION_HOME_PANEL = false;
|
||||
% endif
|
||||
window.PLATFORM_NAME = "{{ PLATFORM_NAME|escapejs }}";
|
||||
|
||||
% if enable_daily_digest:
|
||||
window.ENABLE_FORUM_DAILY_DIGEST = true;
|
||||
% else:
|
||||
window.ENABLE_FORUM_DAILY_DIGEST = false;
|
||||
% endif
|
||||
{% if enable_discussion_home_panel %}
|
||||
window.ENABLE_DISCUSSION_HOME_PANEL = true;
|
||||
{% else %}
|
||||
window.ENABLE_DISCUSSION_HOME_PANEL = false;
|
||||
{% endif %}
|
||||
|
||||
{% if enable_daily_digest %}
|
||||
window.ENABLE_FORUM_DAILY_DIGEST = true;
|
||||
{% else %}
|
||||
window.ENABLE_FORUM_DAILY_DIGEST = false;
|
||||
{% endif %}
|
||||
</script>
|
||||
<%static:include path="common/templates/discussion/templates.underscore" />
|
||||
|
||||
{% include "common/templates/discussion/templates.underscore" %}
|
||||
|
||||
@@ -6,6 +6,7 @@ import logging
|
||||
import urllib
|
||||
from django.conf import settings
|
||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||
from django.template.loader import render_to_string
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import get_language_bidi
|
||||
from web_fragments.fragment import Fragment
|
||||
@@ -23,7 +24,7 @@ from openedx.core.lib.xblock_utils import get_css_dependencies, get_js_dependenc
|
||||
from xmodule.xml_block import XmlMixin
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
loader = ResourceLoader(__name__) # pylint: disable=invalid-name
|
||||
loader = ResourceLoader("lms") # pylint: disable=invalid-name
|
||||
|
||||
|
||||
def _(text):
|
||||
@@ -204,9 +205,11 @@ class _BuiltInDiscussionXBlock(XBlock, StudioEditableXBlockMixin,
|
||||
'can_create_comment': self.has_permission("create_comment"),
|
||||
'can_create_subcomment': self.has_permission("create_sub_comment"),
|
||||
'login_msg': login_msg,
|
||||
'PLATFORM_NAME': settings.PLATFORM_NAME,
|
||||
'enable_discussion_home_panel': settings.FEATURES.get("ENABLE_DISCUSSION_HOME_PANEL", False),
|
||||
}
|
||||
fragment.add_content(
|
||||
self.runtime.service(self, 'mako').render_lms_template('discussion/_discussion_inline.html', context)
|
||||
render_to_string('discussion/_discussion_inline.html', context)
|
||||
)
|
||||
|
||||
fragment.initialize_js('DiscussionInlineBlock')
|
||||
@@ -219,13 +222,13 @@ class _BuiltInDiscussionXBlock(XBlock, StudioEditableXBlockMixin,
|
||||
"""
|
||||
fragment = Fragment()
|
||||
# For historic reasons, this template is in the LMS templates folder:
|
||||
fragment.add_content(self.runtime.service(self, 'mako').render_lms_template(
|
||||
'discussion/_discussion_inline_studio.html',
|
||||
{
|
||||
'discussion_id': self.discussion_id,
|
||||
'is_visible': self.is_visible,
|
||||
}
|
||||
))
|
||||
context = {
|
||||
'discussion_id': self.discussion_id,
|
||||
'is_visible': self.is_visible,
|
||||
}
|
||||
fragment.add_content(
|
||||
loader.render_django_template('templates/discussion/_discussion_inline_studio.html', context)
|
||||
)
|
||||
return fragment
|
||||
|
||||
def student_view_data(self):
|
||||
|
||||
Reference in New Issue
Block a user