Discssions as a plugin

This commit is contained in:
Bill DeRusha
2018-02-16 14:39:59 -05:00
parent 15e07d7cc5
commit 4fba472139
12 changed files with 51 additions and 32 deletions

View File

@@ -262,9 +262,6 @@ FEATURES = {
# Enable credit eligibility feature
'ENABLE_CREDIT_ELIGIBILITY': ENABLE_CREDIT_ELIGIBILITY,
# Can the visibility of the discussion tab be configured on a per-course basis?
'ALLOW_HIDING_DISCUSSION_TAB': False,
# Special Exams, aka Timed and Proctored Exams
'ENABLE_SPECIAL_EXAMS': False,

View File

@@ -1,11 +0,0 @@
"""
Discussion settings and flags.
"""
from openedx.core.djangoapps.waffle_utils import WaffleFlag, WaffleFlagNamespace
# Namespace for course experience waffle flags.
WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='edx_discussions')
# Waffle flag to enable the use of Bootstrap
USE_BOOTSTRAP_FLAG = WaffleFlag(WAFFLE_FLAG_NAMESPACE, 'use_bootstrap')

View File

@@ -6,12 +6,30 @@ Signal handlers are connected here.
from django.apps import AppConfig
from openedx.core.constants import COURSE_ID_PATTERN
from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType, PluginURLs, PluginSettings
class DiscussionConfig(AppConfig):
"""
Application Configuration for Grades.
"""
name = u'lms.djangoapps.discussion'
plugin_app = {
PluginURLs.CONFIG: {
ProjectType.LMS: {
PluginURLs.NAMESPACE: u'',
PluginURLs.REGEX: r'^courses/{}/discussion/forum/'.format(COURSE_ID_PATTERN),
PluginURLs.RELATIVE_PATH: u'urls',
}
},
PluginSettings.CONFIG: {
ProjectType.LMS: {
SettingsType.COMMON: {PluginSettings.RELATIVE_PATH: u'settings.common'},
}
}
}
def ready(self):
"""

View File

@@ -0,0 +1,11 @@
"""
Discussion settings and flags.
"""
from openedx.core.djangoapps.waffle_utils import WaffleFlag, WaffleFlagNamespace
# Namespace for course experience waffle flags.
WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='edx_discussions')
# Waffle flag to enable the use of Bootstrap
USE_BOOTSTRAP_FLAG = WaffleFlag(WAFFLE_FLAG_NAMESPACE, 'use_bootstrap')

View File

@@ -9,7 +9,7 @@ import django_comment_client.utils as utils
from courseware.tabs import EnrolledTab
from xmodule.tabs import TabFragmentViewMixin
from . import USE_BOOTSTRAP_FLAG
from .config import USE_BOOTSTRAP_FLAG
class DiscussionTab(TabFragmentViewMixin, EnrolledTab):

View File

@@ -0,0 +1,6 @@
"""Common environment variables unique to the discussion plugin."""
def plugin_settings(settings):
"""Settings for the discussions plugin. """
settings.FEATURES['ALLOW_HIDING_DISCUSSION_TAB'] = False

View File

@@ -49,7 +49,7 @@ from student.models import CourseEnrollment
from util.json_request import JsonResponse, expect_json
from xmodule.modulestore.django import modulestore
from . import USE_BOOTSTRAP_FLAG
from .config import USE_BOOTSTRAP_FLAG
log = logging.getLogger("edx.discussions")

View File

@@ -37,6 +37,7 @@ import django
from path import Path as path
from django.utils.translation import ugettext_lazy as _
from openedx.core.constants import COURSE_KEY_REGEX, COURSE_KEY_PATTERN, COURSE_ID_PATTERN
from openedx.core.djangoapps.theming.helpers_dirs import (
get_themes_unchecked,
get_theme_base_dirs_from_settings
@@ -709,15 +710,6 @@ COURSE_MODE_DEFAULTS = {
# TODO (vshnayder): Will probably need to change as we get real access control in.
LMS_MIGRATION_ALLOWED_IPS = []
# These are standard regexes for pulling out info like course_ids, usage_ids, etc.
# They are used so that URLs with deprecated-format strings still work.
# Note: these intentionally greedily grab all chars up to the next slash including any pluses
# DHM: I really wanted to ensure the separators were the same (+ or /) but all patts I tried had
# too many inadvertent side effects :-(
COURSE_KEY_PATTERN = r'(?P<course_key_string>[^/+]+(/|\+)[^/+]+(/|\+)[^/?]+)'
COURSE_ID_PATTERN = COURSE_KEY_PATTERN.replace('course_key_string', 'course_id')
COURSE_KEY_REGEX = COURSE_KEY_PATTERN.replace('P<course_key_string>', ':')
USAGE_KEY_PATTERN = r'(?P<usage_key_string>(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))'
ASSET_KEY_PATTERN = r'(?P<asset_key_string>(?:/?c4x(:/)?/[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))'
USAGE_ID_PATTERN = r'(?P<usage_id>(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))'
@@ -2189,7 +2181,6 @@ INSTALLED_APPS = [
'django_comment_client',
'django_comment_common',
'discussion_api',
'lms.djangoapps.discussion.apps.DiscussionConfig',
# Notes
'notes',

View File

@@ -734,12 +734,6 @@ if settings.FEATURES.get('ENABLE_DISCUSSION_SERVICE'):
),
include('django_comment_client.urls')
),
url(
r'^courses/{}/discussion/forum/'.format(
settings.COURSE_ID_PATTERN,
),
include('discussion.urls')
),
url(
r'^notification_prefs/enable/',
notification_prefs_views.ajax_enable

12
openedx/core/constants.py Normal file
View File

@@ -0,0 +1,12 @@
"""
Constants that are relevant all of Open edX
"""
# These are standard regexes for pulling out info like course_ids, usage_ids, etc.
# They are used so that URLs with deprecated-format strings still work.
# Note: these intentionally greedily grab all chars up to the next slash includingny pluses
# DHM: I really wanted to ensure the separators were the same (+ or /) but all patts tried had
# too many inadvertent side effects :-(
COURSE_KEY_PATTERN = r'(?P<course_key_string>[^/+]+(/|\+)[^/+]+(/|\+)[^/?]+)'
COURSE_ID_PATTERN = COURSE_KEY_PATTERN.replace('course_key_string', 'course_id')
COURSE_KEY_REGEX = COURSE_KEY_PATTERN.replace('P<course_key_string>', ':')

View File

@@ -65,6 +65,7 @@ setup(
],
"lms.djangoapp": [
"ace_common = openedx.core.djangoapps.ace_common.apps:AceCommonConfig",
"discussion = lms.djangoapps.discussion.apps:DiscussionConfig",
"grades = lms.djangoapps.grades.apps:GradesConfig",
"plugins = openedx.core.djangoapps.plugins.apps:PluginsConfig",
"schedules = openedx.core.djangoapps.schedules.apps:SchedulesConfig",