refactor: refactor discussions_xblock (#30636)
JIRA: https://openedx.atlassian.net/browse/BOM-2580 This PR aims at refactoring the discussion xblock sub project and moving it within the xmodule directory effectively removing its position as a sub project within edx-platform
This commit is contained in:
committed by
GitHub
parent
8ef261fe07
commit
44fa09eba5
@@ -25,7 +25,7 @@ from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from xblock.fields import Scope
|
||||
|
||||
from xblock_discussion import DiscussionXBlock
|
||||
from xmodule.discussion_block import DiscussionXBlock
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore.inheritance import compute_inherited_metadata, own_metadata
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ 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 xblock_discussion import DiscussionXBlock, loader
|
||||
from xmodule.discussion_block import DiscussionXBlock, loader
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.tests.django_utils import TEST_DATA_MONGO_AMNESTY_MODULESTORE, SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import ItemFactory, ToyCourseFactory
|
||||
|
||||
@@ -11,7 +11,7 @@ from openedx.core.djangoapps.course_groups.cohorts import get_cohort_names, is_c
|
||||
from openedx.core.djangoapps.django_comment_common.models import CourseDiscussionSettings
|
||||
from openedx.core.lib.cache_utils import request_cached
|
||||
from openedx.core.lib.courses import get_course_by_id
|
||||
from openedx.core.lib.xblock_builtin.xblock_discussion.xblock_discussion import DiscussionXBlock
|
||||
from xmodule.discussion_block import DiscussionXBlock
|
||||
from openedx.core.types import User
|
||||
from xmodule.course_module import CourseBlock # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
@@ -18,7 +18,7 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from xmodule.modulestore.tests.test_asides import AsideTestType
|
||||
|
||||
from openedx.core.lib.url_utils import quote_slashes
|
||||
from openedx.core.lib.xblock_builtin import get_css_dependencies, get_js_dependencies
|
||||
from openedx.core.lib.xblock_utils import get_css_dependencies, get_js_dependencies
|
||||
from openedx.core.lib.xblock_utils import (
|
||||
get_aside_from_xblock,
|
||||
is_xblock_aside,
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
Open edX: Built-in XBlocks
|
||||
--------------------------
|
||||
|
||||
This area is meant for exceptional and hopefully temporary cases where an
|
||||
XBlock is integral to the functionality of the Open edX platform.
|
||||
|
||||
This is not a pattern we wish for normal XBlocks to follow; they should live in
|
||||
their own repo.
|
||||
|
||||
Discussion XBlock
|
||||
=================
|
||||
|
||||
This XBlock was converted from an XModule, and will hopefully be pulled out of
|
||||
edx-platform into its own repo at some point. From discussions, it's not too
|
||||
difficult to move the server-side code , but the client-side code is used by
|
||||
the discussion board tab and the team discussion, so for now, must remain in
|
||||
edx-platform.
|
||||
@@ -1,31 +0,0 @@
|
||||
"""
|
||||
Helper functions shared by built-in XBlocks.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
def get_css_dependencies(group):
|
||||
"""
|
||||
Returns list of CSS dependencies belonging to `group` in settings.PIPELINE['STYLESHEETS'].
|
||||
|
||||
Respects `PIPELINE['PIPELINE_ENABLED']` setting.
|
||||
"""
|
||||
if settings.PIPELINE['PIPELINE_ENABLED']:
|
||||
return [settings.PIPELINE['STYLESHEETS'][group]['output_filename']]
|
||||
else:
|
||||
return settings.PIPELINE['STYLESHEETS'][group]['source_filenames']
|
||||
|
||||
|
||||
def get_js_dependencies(group):
|
||||
"""
|
||||
Returns list of JS dependencies belonging to `group` in settings.PIPELINE['JAVASCRIPT'].
|
||||
|
||||
Respects `PIPELINE['PIPELINE_ENABLED']` setting.
|
||||
"""
|
||||
if settings.PIPELINE['PIPELINE_ENABLED']:
|
||||
return [settings.PIPELINE['JAVASCRIPT'][group]['output_filename']]
|
||||
else:
|
||||
return settings.PIPELINE['JAVASCRIPT'][group]['source_filenames']
|
||||
@@ -1 +0,0 @@
|
||||
See ``lms/djangoapps/discussion/README.rst``
|
||||
@@ -1,37 +0,0 @@
|
||||
"""
|
||||
Setup for discussion-forum XBlock.
|
||||
"""
|
||||
|
||||
|
||||
import os
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
|
||||
def package_data(pkg, root_list):
|
||||
"""
|
||||
Generic function to find package_data for `pkg` under `root`.
|
||||
"""
|
||||
data = []
|
||||
for root in root_list:
|
||||
for dirname, _, files in os.walk(os.path.join(pkg, root)):
|
||||
for fname in files:
|
||||
data.append(os.path.relpath(os.path.join(dirname, fname), pkg))
|
||||
|
||||
return {pkg: data}
|
||||
|
||||
|
||||
setup(
|
||||
name='xblock-discussion',
|
||||
version='0.1',
|
||||
description='XBlock - Discussion',
|
||||
install_requires=[
|
||||
'XBlock',
|
||||
],
|
||||
entry_points={
|
||||
'xblock.v1': [
|
||||
'discussion = xblock_discussion:DiscussionXBlock'
|
||||
]
|
||||
},
|
||||
packages=find_packages(exclude=['tests.*']),
|
||||
package_data=package_data("xblock_discussion", ["static"]),
|
||||
)
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Functions that can are used to modify XBlock fragments for use in the LMS and Studio
|
||||
Functions that are used to modify XBlock fragments for use in the LMS and Studio
|
||||
"""
|
||||
|
||||
|
||||
@@ -32,7 +32,10 @@ from xmodule.seq_module import SequenceBlock # lint-amnesty, pylint: disable=wr
|
||||
from xmodule.util.xmodule_django import add_webpack_to_fragment # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.vertical_block import VerticalBlock # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.x_module import ( # lint-amnesty, pylint: disable=wrong-import-order
|
||||
PREVIEW_VIEWS, STUDENT_VIEW, STUDIO_VIEW, shim_xmodule_js,
|
||||
PREVIEW_VIEWS,
|
||||
STUDENT_VIEW,
|
||||
STUDIO_VIEW,
|
||||
shim_xmodule_js
|
||||
)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -510,3 +513,27 @@ def get_icon(block):
|
||||
It can be overridden by setting `OVERRIDE_GET_UNIT_ICON` to an alternative implementation.
|
||||
"""
|
||||
return block.get_icon_class()
|
||||
|
||||
|
||||
def get_css_dependencies(group):
|
||||
"""
|
||||
Returns list of CSS dependencies belonging to `group` in settings.PIPELINE['STYLESHEETS'].
|
||||
|
||||
Respects `PIPELINE['PIPELINE_ENABLED']` setting.
|
||||
"""
|
||||
if settings.PIPELINE['PIPELINE_ENABLED']:
|
||||
return [settings.PIPELINE['STYLESHEETS'][group]['output_filename']]
|
||||
else:
|
||||
return settings.PIPELINE['STYLESHEETS'][group]['source_filenames']
|
||||
|
||||
|
||||
def get_js_dependencies(group):
|
||||
"""
|
||||
Returns list of JS dependencies belonging to `group` in settings.PIPELINE['JAVASCRIPT'].
|
||||
|
||||
Respects `PIPELINE['PIPELINE_ENABLED']` setting.
|
||||
"""
|
||||
if settings.PIPELINE['PIPELINE_ENABLED']:
|
||||
return [settings.PIPELINE['JAVASCRIPT'][group]['output_filename']]
|
||||
else:
|
||||
return settings.PIPELINE['JAVASCRIPT'][group]['source_filenames']
|
||||
|
||||
@@ -14,7 +14,7 @@ click==8.1.3
|
||||
# nltk
|
||||
codejail-includes==1.0.0
|
||||
# via -r requirements/edx-sandbox/py38.in
|
||||
cryptography==37.0.2
|
||||
cryptography==37.0.3
|
||||
# via -r requirements/edx-sandbox/py38.in
|
||||
cycler==0.11.0
|
||||
# via matplotlib
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
# via -r requirements/edx/local.in
|
||||
-e git+https://github.com/edx/RateXBlock.git@2.0.1#egg=rate-xblock
|
||||
# via -r requirements/edx/github.in
|
||||
-e openedx/core/lib/xblock_builtin/xblock_discussion
|
||||
# via -r requirements/edx/local.in
|
||||
-e git+https://github.com/edx-solutions/xblock-google-drive.git@2d176468e33c0713c911b563f8f65f7cf232f5b6#egg=xblock-google-drive
|
||||
# via -r requirements/edx/github.in
|
||||
acid-xblock==0.2.1
|
||||
@@ -578,7 +576,7 @@ future==0.18.2
|
||||
# via
|
||||
# edx-celeryutils
|
||||
# pyjwkest
|
||||
geoip2==4.5.0
|
||||
geoip2==4.6.0
|
||||
# via -r requirements/edx/base.in
|
||||
glob2==0.7
|
||||
# via -r requirements/edx/base.in
|
||||
@@ -1128,7 +1126,6 @@ xblock==1.6.1
|
||||
# ora2
|
||||
# rate-xblock
|
||||
# staff-graded-xblock
|
||||
# xblock-discussion
|
||||
# xblock-drag-and-drop-v2
|
||||
# xblock-google-drive
|
||||
# xblock-poll
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
# via -r requirements/edx/testing.txt
|
||||
-e git+https://github.com/edx/RateXBlock.git@2.0.1#egg=rate-xblock
|
||||
# via -r requirements/edx/testing.txt
|
||||
-e openedx/core/lib/xblock_builtin/xblock_discussion
|
||||
# via -r requirements/edx/testing.txt
|
||||
-e git+https://github.com/edx-solutions/xblock-google-drive.git@2d176468e33c0713c911b563f8f65f7cf232f5b6#egg=xblock-google-drive
|
||||
# via -r requirements/edx/testing.txt
|
||||
acid-xblock==0.2.1
|
||||
@@ -727,7 +725,7 @@ future==0.18.2
|
||||
# -r requirements/edx/testing.txt
|
||||
# edx-celeryutils
|
||||
# pyjwkest
|
||||
geoip2==4.5.0
|
||||
geoip2==4.6.0
|
||||
# via -r requirements/edx/testing.txt
|
||||
glob2==0.7
|
||||
# via -r requirements/edx/testing.txt
|
||||
@@ -1607,7 +1605,6 @@ xblock==1.6.1
|
||||
# ora2
|
||||
# rate-xblock
|
||||
# staff-graded-xblock
|
||||
# xblock-discussion
|
||||
# xblock-drag-and-drop-v2
|
||||
# xblock-google-drive
|
||||
# xblock-poll
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Python libraries to install that are local to the edx-platform repo
|
||||
-e .
|
||||
-e common/lib/capa
|
||||
|
||||
-e openedx/core/lib/xblock_builtin/xblock_discussion
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
# via -r requirements/edx/base.txt
|
||||
-e git+https://github.com/edx/RateXBlock.git@2.0.1#egg=rate-xblock
|
||||
# via -r requirements/edx/base.txt
|
||||
-e openedx/core/lib/xblock_builtin/xblock_discussion
|
||||
# via -r requirements/edx/base.txt
|
||||
-e git+https://github.com/edx-solutions/xblock-google-drive.git@2d176468e33c0713c911b563f8f65f7cf232f5b6#egg=xblock-google-drive
|
||||
# via -r requirements/edx/base.txt
|
||||
acid-xblock==0.2.1
|
||||
@@ -702,7 +700,7 @@ future==0.18.2
|
||||
# -r requirements/edx/base.txt
|
||||
# edx-celeryutils
|
||||
# pyjwkest
|
||||
geoip2==4.5.0
|
||||
geoip2==4.6.0
|
||||
# via -r requirements/edx/base.txt
|
||||
glob2==0.7
|
||||
# via -r requirements/edx/base.txt
|
||||
@@ -1488,7 +1486,6 @@ xblock==1.6.1
|
||||
# ora2
|
||||
# rate-xblock
|
||||
# staff-graded-xblock
|
||||
# xblock-discussion
|
||||
# xblock-drag-and-drop-v2
|
||||
# xblock-google-drive
|
||||
# xblock-poll
|
||||
|
||||
1
setup.py
1
setup.py
@@ -15,6 +15,7 @@ XBLOCKS = [
|
||||
"customtag = xmodule.template_module:CustomTagBlock",
|
||||
"custom_tag_template = xmodule.template_module:CustomTagTemplateBlock",
|
||||
"discuss = xmodule.template_module:TranslateCustomTagBlock",
|
||||
"discussion = xmodule.discussion_block:DiscussionXBlock",
|
||||
"error = xmodule.error_module:ErrorBlock",
|
||||
"hidden = xmodule.hidden_module:HiddenDescriptor",
|
||||
"html = xmodule.html_module:HtmlBlock",
|
||||
|
||||
@@ -14,12 +14,10 @@ from xblock.core import XBlock
|
||||
from xblock.fields import UNIQUE_ID, Scope, String
|
||||
from xblockutils.resources import ResourceLoader
|
||||
from xblockutils.studio_editable import StudioEditableXBlockMixin
|
||||
from xmodule.xml_module import XmlParserMixin
|
||||
|
||||
from lms.djangoapps.discussion.toggles import ENABLE_DISCUSSIONS_MFE
|
||||
from openedx.core.djangoapps.discussions.url_helpers import get_discussions_mfe_topic_url
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from openedx.core.lib.xblock_builtin import get_css_dependencies, get_js_dependencies
|
||||
from openedx.core.lib.xblock_utils import get_css_dependencies, get_js_dependencies
|
||||
from xmodule.xml_module import XmlParserMixin
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
loader = ResourceLoader(__name__) # pylint: disable=invalid-name
|
||||
@@ -5,16 +5,15 @@ import itertools
|
||||
import random
|
||||
import string
|
||||
from collections import namedtuple
|
||||
from unittest import TestCase
|
||||
from unittest import mock
|
||||
from unittest import TestCase, mock
|
||||
|
||||
import ddt
|
||||
from xblock.field_data import DictFieldData
|
||||
from xblock.fields import NO_CACHE_VALUE, UNIQUE_ID, ScopeIds
|
||||
from xblock.runtime import Runtime
|
||||
|
||||
from openedx.core.lib.xblock_builtin.xblock_discussion.xblock_discussion import DiscussionXBlock
|
||||
from openedx.core.lib.safe_lxml import etree
|
||||
from xmodule.discussion_block import DiscussionXBlock
|
||||
|
||||
|
||||
def attribute_pair_repr(self):
|
||||
@@ -59,7 +58,7 @@ class DiscussionXBlockImportExportTests(TestCase):
|
||||
"""
|
||||
Import and export tests
|
||||
"""
|
||||
DISCUSSION_XBLOCK_LOCATION = "openedx.core.lib.xblock_builtin.xblock_discussion.xblock_discussion.DiscussionXBlock"
|
||||
DISCUSSION_XBLOCK_LOCATION = "xmodule.discussion_block.DiscussionXBlock"
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Reference in New Issue
Block a user