@@ -2,6 +2,8 @@
|
|||||||
This module contains various configuration settings via
|
This module contains various configuration settings via
|
||||||
waffle switches for the Block Structure framework.
|
waffle switches for the Block Structure framework.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from openedx.core.djangoapps.waffle_utils import WaffleSwitchNamespace
|
from openedx.core.djangoapps.waffle_utils import WaffleSwitchNamespace
|
||||||
from openedx.core.lib.cache_utils import request_cached
|
from openedx.core.lib.cache_utils import request_cached
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
"""
|
"""
|
||||||
Models for configuration of Block Structures.
|
Models for configuration of Block Structures.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from django.db.models import IntegerField
|
from django.db.models import IntegerField
|
||||||
from config_models.models import ConfigurationModel
|
from config_models.models import ConfigurationModel
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
"""
|
"""
|
||||||
Command to load course blocks.
|
Command to load course blocks.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
import six
|
||||||
from six import text_type
|
from six import text_type
|
||||||
from xmodule.modulestore.django import modulestore
|
from xmodule.modulestore.django import modulestore
|
||||||
|
|
||||||
@@ -136,7 +139,7 @@ class Command(BaseCommand):
|
|||||||
except Exception as ex: # pylint: disable=broad-except
|
except Exception as ex: # pylint: disable=broad-except
|
||||||
log.exception(
|
log.exception(
|
||||||
u'BlockStructure: An error occurred while generating course blocks for %s: %s',
|
u'BlockStructure: An error occurred while generating course blocks for %s: %s',
|
||||||
unicode(course_key),
|
six.text_type(course_key),
|
||||||
text_type(ex),
|
text_type(ex),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -148,7 +151,7 @@ class Command(BaseCommand):
|
|||||||
action = tasks.update_course_in_cache_v2 if options.get('force_update') else tasks.get_course_in_cache_v2
|
action = tasks.update_course_in_cache_v2 if options.get('force_update') else tasks.get_course_in_cache_v2
|
||||||
task_options = {'routing_key': options['routing_key']} if options.get('routing_key') else {}
|
task_options = {'routing_key': options['routing_key']} if options.get('routing_key') else {}
|
||||||
result = action.apply_async(
|
result = action.apply_async(
|
||||||
kwargs=dict(course_id=unicode(course_key), with_storage=options.get('with_storage')),
|
kwargs=dict(course_id=six.text_type(course_key), with_storage=options.get('with_storage')),
|
||||||
**task_options
|
**task_options
|
||||||
)
|
)
|
||||||
log.info(u'BlockStructure: ENQUEUED generating for course: %s, task_id: %s.', course_key, result.id)
|
log.info(u'BlockStructure: ENQUEUED generating for course: %s, task_id: %s.', course_key, result.id)
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
"""
|
"""
|
||||||
Tests for generate_course_blocks management command.
|
Tests for generate_course_blocks management command.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import ddt
|
import ddt
|
||||||
from django.core.management.base import CommandError
|
from django.core.management.base import CommandError
|
||||||
import itertools
|
import itertools
|
||||||
|
import six
|
||||||
|
from six.moves import range
|
||||||
from mock import patch
|
from mock import patch
|
||||||
|
|
||||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||||
@@ -82,13 +86,13 @@ class TestGenerateCourseBlocks(ModuleStoreTestCase):
|
|||||||
|
|
||||||
def test_one_course(self):
|
def test_one_course(self):
|
||||||
self._assert_courses_not_in_block_cache(*self.course_keys)
|
self._assert_courses_not_in_block_cache(*self.course_keys)
|
||||||
self.command.handle(courses=[unicode(self.course_keys[0])])
|
self.command.handle(courses=[six.text_type(self.course_keys[0])])
|
||||||
self._assert_courses_in_block_cache(self.course_keys[0])
|
self._assert_courses_in_block_cache(self.course_keys[0])
|
||||||
self._assert_courses_not_in_block_cache(*self.course_keys[1:])
|
self._assert_courses_not_in_block_cache(*self.course_keys[1:])
|
||||||
self._assert_courses_not_in_block_storage(*self.course_keys)
|
self._assert_courses_not_in_block_storage(*self.course_keys)
|
||||||
|
|
||||||
def test_with_storage(self):
|
def test_with_storage(self):
|
||||||
self.command.handle(with_storage=True, courses=[unicode(self.course_keys[0])])
|
self.command.handle(with_storage=True, courses=[six.text_type(self.course_keys[0])])
|
||||||
self._assert_courses_in_block_cache(self.course_keys[0])
|
self._assert_courses_in_block_cache(self.course_keys[0])
|
||||||
self._assert_courses_in_block_storage(self.course_keys[0])
|
self._assert_courses_in_block_storage(self.course_keys[0])
|
||||||
self._assert_courses_not_in_block_storage(*self.course_keys[1:])
|
self._assert_courses_not_in_block_storage(*self.course_keys[1:])
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.utils.timezone
|
import django.utils.timezone
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import openedx.core.djangoapps.content.block_structure.models
|
import openedx.core.djangoapps.content.block_structure.models
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import openedx.core.djangoapps.xmodule_django.models
|
import openedx.core.djangoapps.xmodule_django.models
|
||||||
|
|||||||
Reference in New Issue
Block a user