Skip to content

Commit

Permalink
Merge branch 'master' into certificate_invalidation_view-to-drf
Browse files Browse the repository at this point in the history
  • Loading branch information
awais786 authored Oct 31, 2024
2 parents 5698565 + b20498c commit a02503d
Show file tree
Hide file tree
Showing 23 changed files with 1,006 additions and 626 deletions.
4 changes: 1 addition & 3 deletions cms/static/js/factories/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ define([
], function($, CourseDetailsModel, MainView) {
'use strict';

return function(detailsUrl, showMinGradeWarning, showCertificateAvailableDate, upgradeDeadline, useV2CertDisplaySettings) {
return function(detailsUrl, showMinGradeWarning, showCertificateAvailableDate, upgradeDeadline) {
var model;
// highlighting labels when fields are focused in
$('form :input')
Expand All @@ -23,7 +23,6 @@ define([
model = new CourseDetailsModel();
model.urlRoot = detailsUrl;
model.showCertificateAvailableDate = showCertificateAvailableDate;
model.useV2CertDisplaySettings = useV2CertDisplaySettings;
model.set('upgrade_deadline', upgradeDeadline);
model.fetch({
// eslint-disable-next-line no-shadow
Expand All @@ -33,7 +32,6 @@ define([
model: model,
showMinGradeWarning: showMinGradeWarning
});
editor.useV2CertDisplaySettings = useV2CertDisplaySettings;
editor.render();
},
reset: true,
Expand Down
54 changes: 26 additions & 28 deletions cms/static/js/models/settings/course_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,35 +84,33 @@ function(Backbone, _, gettext, ValidationHelpers, DateUtils, StringUtils) {
);
}

if (this.useV2CertDisplaySettings) {
if (
newattrs.certificates_display_behavior
&& !(Object.values(CERTIFICATES_DISPLAY_BEHAVIOR_OPTIONS).includes(newattrs.certificates_display_behavior))
) {
errors.certificates_display_behavior = StringUtils.interpolate(
gettext(
'The certificate display behavior must be one of: {behavior_options}'
),
{
behavior_options: Object.values(CERTIFICATES_DISPLAY_BEHAVIOR_OPTIONS).join(', ')
}
);
}
if (
newattrs.certificates_display_behavior
&& !(Object.values(CERTIFICATES_DISPLAY_BEHAVIOR_OPTIONS).includes(newattrs.certificates_display_behavior))
) {
errors.certificates_display_behavior = StringUtils.interpolate(
gettext(
'The certificate display behavior must be one of: {behavior_options}'
),
{
behavior_options: Object.values(CERTIFICATES_DISPLAY_BEHAVIOR_OPTIONS).join(', ')
}
);
}

// Throw error if there's a value for certificate_available_date
if (
(newattrs.certificate_available_date && newattrs.certificates_display_behavior != CERTIFICATES_DISPLAY_BEHAVIOR_OPTIONS.END_WITH_DATE)
|| (!newattrs.certificate_available_date && newattrs.certificates_display_behavior == CERTIFICATES_DISPLAY_BEHAVIOR_OPTIONS.END_WITH_DATE)
) {
errors.certificates_display_behavior = StringUtils.interpolate(
gettext(
'The certificates display behavior must be {valid_option} if certificate available date is set.'
),
{
valid_option: CERTIFICATES_DISPLAY_BEHAVIOR_OPTIONS.END_WITH_DATE
}
);
}
// Throw error if there's a value for certificate_available_date
if (
(newattrs.certificate_available_date && newattrs.certificates_display_behavior != CERTIFICATES_DISPLAY_BEHAVIOR_OPTIONS.END_WITH_DATE)
|| (!newattrs.certificate_available_date && newattrs.certificates_display_behavior == CERTIFICATES_DISPLAY_BEHAVIOR_OPTIONS.END_WITH_DATE)
) {
errors.certificates_display_behavior = StringUtils.interpolate(
gettext(
'The certificates display behavior must be {valid_option} if certificate available date is set.'
),
{
valid_option: CERTIFICATES_DISPLAY_BEHAVIOR_OPTIONS.END_WITH_DATE
}
);
}

if (newattrs.intro_video && newattrs.intro_video !== this.get('intro_video')) {
Expand Down
3 changes: 0 additions & 3 deletions cms/static/js/views/settings/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,6 @@ function(ValidatingView, CodeMirror, _, $, ui, DateUtils, FileUploadModel,
Hides and clears the certificate available date field if a display behavior that doesn't use it is
chosen. Because we are clearing it, toggling back to "end_with_date" will require re-entering the date
*/
if (!this.useV2CertDisplaySettings) {
return;
}
// eslint-disable-next-line prefer-const
let showDatepicker = this.model.get('certificates_display_behavior') == 'end_with_date';
// eslint-disable-next-line prefer-const
Expand Down
2 changes: 0 additions & 2 deletions common/djangoapps/util/tests/test_db.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Tests for util.db module."""

from io import StringIO
import unittest

import ddt
from django.core.management import call_command
Expand Down Expand Up @@ -121,7 +120,6 @@ class MigrationTests(TestCase):
Tests for migrations.
"""

@unittest.skip('Skipping temporarily to drop column in table')
@override_settings(MIGRATION_MODULES={})
def test_migrations_are_in_sync(self):
"""
Expand Down
20 changes: 20 additions & 0 deletions lms/djangoapps/courseware/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3814,6 +3814,26 @@ def test_is_mfe_search_waffle_disabled(self):
self.assertEqual(response.status_code, 200)
self.assertEqual(body, {'enabled': False})

@patch.dict('django.conf.settings.FEATURES', {'COURSEWARE_SEARCH_INCLUSION_DATE': '2020'})
@ddt.data(
(datetime(2013, 9, 18, 11, 30, 00), False),
(None, False),
(datetime(2024, 9, 18, 11, 30, 00), True),
)
@ddt.unpack
def test_inclusion_date_greater_than_course_start(self, start_date, expected_enabled):
course_with_start = CourseFactory.create(start=start_date)
api_url = reverse('courseware_search_enabled_view', kwargs={'course_id': str(course_with_start.id)})

user_staff = UserFactory(is_staff=True)

self.client.login(username=user_staff.username, password=TEST_PASSWORD)
response = self.client.get(api_url, content_type='application/json')
body = json.loads(response.content.decode('utf-8'))

self.assertEqual(response.status_code, 200)
self.assertEqual(body, {'enabled': expected_enabled})


class TestCoursewareMFENavigationSidebarTogglesAPI(SharedModuleStoreTestCase):
"""
Expand Down
7 changes: 7 additions & 0 deletions lms/djangoapps/courseware/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2317,6 +2317,13 @@ def courseware_mfe_search_enabled(request, course_id=None):
else:
enabled = True

inclusion_date = settings.FEATURES.get('COURSEWARE_SEARCH_INCLUSION_DATE')
start_date = CourseOverview.get_from_id(course_key).start

# only include courses that have a start date later than the setting-defined inclusion date
if inclusion_date:
enabled = enabled and (start_date and start_date.strftime('%Y-%m-%d') > inclusion_date)

payload = {"enabled": courseware_mfe_search_is_enabled(course_key) if enabled else False}
return JsonResponse(payload)

Expand Down
2 changes: 1 addition & 1 deletion requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ django-storages<1.14.4
# The team that owns this package will manually bump this package rather than having it pulled in automatically.
# This is to allow them to better control its deployment and to do it in a process that works better
# for them.
edx-enterprise==4.30.0
edx-enterprise==4.30.1

# Date: 2024-05-09
# This has to be constrained as well because newer versions of edx-i18n-tools need the
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ edx-drf-extensions==10.5.0
# edx-when
# edxval
# openedx-learning
edx-enterprise==4.30.0
edx-enterprise==4.30.1
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/kernel.in
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ edx-drf-extensions==10.5.0
# edx-when
# edxval
# openedx-learning
edx-enterprise==4.30.0
edx-enterprise==4.30.1
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/doc.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ edx-drf-extensions==10.5.0
# edx-when
# edxval
# openedx-learning
edx-enterprise==4.30.0
edx-enterprise==4.30.1
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ edx-drf-extensions==10.5.0
# edx-when
# edxval
# openedx-learning
edx-enterprise==4.30.0
edx-enterprise==4.30.1
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt
Expand Down
6 changes: 0 additions & 6 deletions xmodule/assets/HtmlBlockDisplay.scss

This file was deleted.

7 changes: 0 additions & 7 deletions xmodule/assets/HtmlBlockEditor.scss

This file was deleted.

3 changes: 0 additions & 3 deletions xmodule/assets/PollBlockDisplay.scss

This file was deleted.

12 changes: 6 additions & 6 deletions xmodule/assets/editor/_edit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
@include linear-gradient(top, #d4dee8, #c9d5e2);

position: relative;
padding: ($baseline/4);
padding: calc(var(--baseline)/4);
border-bottom-color: #a5aaaf;

button {
display: inline-block;

@include float(left);

padding: 3px ($baseline/2) 5px;
padding: 3px calc(var(--baseline)/2) 5px;
margin-left: 7px;
border: 0;
border-radius: 2px;
Expand All @@ -53,7 +53,7 @@

li {
@include float(left);
@include margin-right($baseline/4);
@include margin-right(calc(var(--baseline)/4));

&:last-child {
@include margin-right(0);
Expand All @@ -67,16 +67,16 @@
border: 1px solid #a5aaaf;
border-radius: 3px 3px 0 0;

@include linear-gradient(top, $transparent 87%, rgba(0, 0, 0, .06));
@include linear-gradient(top, var(--transparent) 87%, rgba(0, 0, 0, .06));

background-color: #e5ecf3;
font-size: 13px;
color: #3c3c3c;
box-shadow: 1px -1px 1px rgba(0, 0, 0, .05);

&.current {
background: $white;
border-bottom-color: $white;
background: var(--white);
border-bottom-color: var(--white);
}
}
}
Expand Down
Loading

0 comments on commit a02503d

Please sign in to comment.