Merge pull request #21696 from edx/ndalfonso/DISCO-1342-hide-fields

DISCO-1342 hide fields
This commit is contained in:
Nick
2019-09-19 12:35:48 -04:00
committed by GitHub
9 changed files with 48 additions and 22 deletions

View File

@@ -299,8 +299,6 @@ class CourseDetailsViewTest(CourseTestCase, MilestonesTestCaseMixin):
self.assertContains(response, "Enrollment Start Date")
self.assertContains(response, "Enrollment End Date")
self.assertContains(response, "Introducing Your Course")
self.assertContains(response, "Course Card Image")
self.assertContains(response, "Course Short Description")
self.assertNotContains(response, "Course About Sidebar HTML")
self.assertNotContains(response, "Course Title")

View File

@@ -1305,11 +1305,18 @@ def advanced_settings_handler(request, course_key_string):
with modulestore().bulk_operations(course_key):
course_module = get_course_and_check_access(course_key, request.user)
if 'text/html' in request.META.get('HTTP_ACCEPT', '') and request.method == 'GET':
publisher_enabled = configuration_helpers.get_value_for_org(
course_module.location.org,
'ENABLE_PUBLISHER',
settings.FEATURES.get('ENABLE_PUBLISHER', False)
)
return render_to_response('settings_advanced.html', {
'context_course': course_module,
'advanced_dict': CourseMetadata.fetch(course_module),
'advanced_settings_url': reverse_course_url('advanced_settings_handler', course_key)
'advanced_settings_url': reverse_course_url('advanced_settings_handler', course_key),
'publisher_enabled': publisher_enabled,
})
elif 'application/json' in request.META.get('HTTP_ACCEPT', ''):
if request.method == 'GET':

View File

@@ -178,7 +178,8 @@ class CourseMetadata(object):
'value': field.read_json(descriptor),
'display_name': _(field.display_name),
'help': field_help,
'deprecated': field.runtime_options.get('deprecated', False)
'deprecated': field.runtime_options.get('deprecated', False),
'hide_on_enabled_publisher': field.runtime_options.get('hide_on_enabled_publisher', False)
}
return result

View File

@@ -2,7 +2,7 @@ define([
'jquery', 'gettext', 'js/models/settings/advanced', 'js/views/settings/advanced'
], function($, gettext, AdvancedSettingsModel, AdvancedSettingsView) {
'use strict';
return function(advancedDict, advancedSettingsUrl) {
return function(advancedDict, advancedSettingsUrl, publisherEnabled) {
var advancedModel, editor;
$('form :input')
@@ -17,6 +17,14 @@ define([
advancedModel = new AdvancedSettingsModel(advancedDict, {parse: true});
advancedModel.url = advancedSettingsUrl;
// set the hidden property to true on relevant fields if publisher is enabled
if (publisherEnabled && advancedModel.attributes) {
Object.keys(advancedModel.attributes).forEach(function(am) {
var field = advancedModel.attributes[am];
field.hidden = field.hide_on_enabled_publisher;
});
}
editor = new AdvancedSettingsView({
el: $('.settings-advanced'),
model: advancedModel

View File

@@ -153,7 +153,7 @@ define(['js/views/validation',
var newKeyId = _.uniqueId('policy_key_'),
newEle = this.template({key: key, display_name: model.display_name, help: model.help,
value: JSON.stringify(model.value, null, 4), deprecated: model.deprecated,
keyUniqueId: newKeyId, valueUniqueId: _.uniqueId('policy_value_')});
keyUniqueId: newKeyId, valueUniqueId: _.uniqueId('policy_value_'), hidden: model.hidden});
this.fieldToSelectorMap[key] = newKeyId;
this.selectorToField[newKeyId] = key;

View File

@@ -1,14 +1,16 @@
<li class="field-group course-advanced-policy-list-item <%= deprecated ? 'is-deprecated' : '' %>">
<div class="field is-not-editable text key" id="<%= key %>">
<h3 class="title" id="<%= keyUniqueId %>"><%= display_name %></h3>
</div>
<% if (!hidden) { %>
<li class="field-group course-advanced-policy-list-item <%- deprecated ? 'is-deprecated' : '' %>">
<div class="field is-not-editable text key" id="<%- key %>">
<h3 class="title" id="<%- keyUniqueId %>"><%- display_name %></h3>
</div>
<div class="field text value">
<label class="sr" for="<%= valueUniqueId %>"><%= display_name %></label>
<textarea class="json text" id="<%= valueUniqueId %>"><%= value %></textarea>
<span class="tip tip-stacked"><%= help %></span>
</div>
<% if (deprecated) { %>
<span class="status"><%= gettext("Deprecated") %></span>
<% } %>
</li>
<div class="field text value">
<label class="sr" for="<%- valueUniqueId %>"><%- display_name %></label>
<textarea class="json text" id="<%- valueUniqueId %>"><%- value %></textarea>
<span class="tip tip-stacked"><%- help %></span>``
</div>
<% if (deprecated) { %>
<span class="status"><%- gettext("Deprecated") %></span>
<% } %>
</li>
<% } %>

View File

@@ -341,10 +341,14 @@ CMS.URL.UPLOAD_ASSET = '${upload_asset_url | n, js_escaped_string}'
<hr class="divide" />
<div class="group-settings marketing">
% if about_page_editable:
<header>
<h2 class="title-2">${_("Introducing Your Course")}</h2>
<span class="tip">${_("Information for prospective students")}</span>
</header>
% endif
<ol class="list-input">
% if enable_extended_course_details:
@@ -405,6 +409,7 @@ CMS.URL.UPLOAD_ASSET = '${upload_asset_url | n, js_escaped_string}'
% endif
% endif
% if about_page_editable:
<li class="field image" id="field-course-image">
<label for="course-image-url">${_("Course Card Image")}</label>
<div class="current current-course-image">
@@ -437,6 +442,7 @@ CMS.URL.UPLOAD_ASSET = '${upload_asset_url | n, js_escaped_string}'
<button type="button" class="action action-upload-image" id="upload-course-image">${_("Upload Course Card Image")}</button>
</div>
</li>
% endif
% if enable_extended_course_details:
<li class="field image" id="field-banner-image">

View File

@@ -25,7 +25,8 @@
require(["js/factories/settings_advanced"], function(SettingsAdvancedFactory) {
SettingsAdvancedFactory(
${advanced_dict | n, dump_js_escaped_json},
"${advanced_settings_url | n, js_escaped_string}"
"${advanced_settings_url | n, js_escaped_string}",
${publisher_enabled | n, dump_js_escaped_json}
);
});
</%block>

View File

@@ -19,6 +19,7 @@ from pytz import utc
from six import text_type
from xblock.fields import Boolean, Dict, Float, Integer, List, Scope, String
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.video_pipeline.models import VideoUploadsEnabledByDefault
from openedx.core.lib.license import LicenseMixin
from xmodule import course_metadata_utils
@@ -332,7 +333,8 @@ class CourseFields(object):
help=_("Enter the name of the course as it should appear in the edX.org course list."),
default="Empty",
display_name=_("Course Display Name"),
scope=Scope.settings
scope=Scope.settings,
hide_on_enabled_publisher=True
)
course_edit_method = String(
display_name=_("Course Editor"),
@@ -550,7 +552,8 @@ class CourseFields(object):
),
scope=Scope.settings,
# Ensure that courses imported from XML keep their image
default="images_course_image.jpg"
default="images_course_image.jpg",
hide_on_enabled_publisher=True
)
banner_image = String(
display_name=_("Course Banner Image"),