Merge pull request #23217 from cpennington/edx-when-published-only
Only extract published dates into edx-when
This commit is contained in:
@@ -6,6 +6,7 @@ import logging
|
||||
from django.dispatch import receiver
|
||||
from six import text_type
|
||||
from xblock.fields import Scope
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.django import SignalHandler, modulestore
|
||||
from .models import SelfPacedRelativeDatesConfig
|
||||
from .utils import get_expected_duration
|
||||
@@ -63,7 +64,9 @@ def extract_dates_from_course(course):
|
||||
items.extend(next_item.get_children())
|
||||
else:
|
||||
date_items = []
|
||||
items = modulestore().get_items(course.id)
|
||||
store = modulestore()
|
||||
with store.branch_setting(ModuleStoreEnum.Branch.published_only, course.id):
|
||||
items = store.get_items(course.id)
|
||||
log.info('Extracting dates from %d items in %s', len(items), course.id)
|
||||
for item in items:
|
||||
date_items.append((item.location, _field_values(FIELDS_TO_EXTRACT, item)))
|
||||
@@ -75,7 +78,9 @@ def extract_dates(sender, course_key, **kwargs): # pylint: disable=unused-argum
|
||||
"""
|
||||
Extract dates from blocks when publishing a course.
|
||||
"""
|
||||
course = modulestore().get_course(course_key)
|
||||
store = modulestore()
|
||||
with store.branch_setting(ModuleStoreEnum.Branch.published_only, course_key):
|
||||
course = store.get_course(course_key)
|
||||
|
||||
if not course:
|
||||
log.info("No course found for key %s to extract dates from", course_key)
|
||||
|
||||
Reference in New Issue
Block a user