Skip to content
Snippets Groups Projects
Commit 5ea77433 authored by Calen Pennington's avatar Calen Pennington
Browse files

Only extract published dates into edx-when

parent fe22e770
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment