Commit 2121548f by Braden MacDonald

Remove "components" directory, fix duplicate CSS/JS files

parent 77c94472
from .mentoring import MentoringBlock
from .answer import AnswerBlock, AnswerRecapBlock
from .choice import ChoiceBlock
from .mcq import MCQBlock, RatingBlock
from .mrq import MRQBlock
from .message import MentoringMessageBlock
from .table import MentoringTableBlock, MentoringTableColumn
from .tip import TipBlock
......@@ -26,7 +26,7 @@
import logging
from lazy import lazy
from mentoring.models import Answer
from .models import Answer
from xblock.core import XBlock
from xblock.fields import Scope, Float, Integer, String
......
from .answer import AnswerBlock, AnswerRecapBlock
from .choice import ChoiceBlock
from .mcq import MCQBlock, RatingBlock
from .mrq import MRQBlock
from .message import MentoringMessageBlock
from .table import MentoringTableBlock, MentoringTableColumn
from .tip import TipBlock
......@@ -33,8 +33,8 @@ from xblock.fields import Boolean, Scope, String, Integer, Float, List
from xblock.fragment import Fragment
from xblock.validation import ValidationMessage
from components import MentoringMessageBlock
from components.step import StepParentMixin, StepMixin
from .message import MentoringMessageBlock
from .step import StepParentMixin, StepMixin
from xblockutils.resources import ResourceLoader
from xblockutils.studio_editable import StudioEditableXBlockMixin, StudioContainerXBlockMixin
......
......@@ -33,6 +33,7 @@ from xblockutils.resources import ResourceLoader
from xblockutils.studio_editable import StudioEditableXBlockMixin, StudioContainerXBlockMixin
from .choice import ChoiceBlock
from .mentoring import MentoringBlock
from .step import StepMixin
from .tip import TipBlock
......@@ -125,8 +126,13 @@ class QuestionnaireAbstractBlock(StudioEditableXBlockMixin, StudioContainerXBloc
context['custom_choices'] = self.custom_choices
fragment = Fragment(loader.render_template(template_path, context))
fragment.add_css_url(self.runtime.local_resource_url(self, 'public/css/questionnaire.css'))
fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/questionnaire.js'))
# If we use local_resource_url(self, ...) the runtime may insert many identical copies
# of questionnaire.[css/js] into the DOM. So we use the mentoring block here if possible
block_with_resources = self.get_parent()
if not isinstance(block_with_resources, MentoringBlock):
block_with_resources = self
fragment.add_css_url(self.runtime.local_resource_url(block_with_resources, 'public/css/questionnaire.css'))
fragment.add_javascript_url(self.runtime.local_resource_url(block_with_resources, 'public/js/questionnaire.js'))
fragment.initialize_js(name)
return fragment
......
import unittest
from mentoring.components.step import StepMixin, StepParentMixin
from mentoring.step import StepMixin, StepParentMixin
from mock import Mock
......
......@@ -45,16 +45,16 @@ def package_data(pkg, root_list):
BLOCKS = [
'mentoring = mentoring:MentoringBlock',
'mentoring-table = mentoring.components:MentoringTableBlock',
'mentoring-column = mentoring.components:MentoringTableColumn',
'mentoring-answer = mentoring.components:AnswerBlock',
'mentoring-answer-recap = mentoring.components:AnswerRecapBlock',
'mentoring-mcq = mentoring.components:MCQBlock',
'mentoring-rating = mentoring.components:RatingBlock',
'mentoring-mrq = mentoring.components:MRQBlock',
'mentoring-message = mentoring.components:MentoringMessageBlock',
'mentoring-tip = mentoring.components:TipBlock',
'mentoring-choice = mentoring.components:ChoiceBlock',
'mentoring-table = mentoring:MentoringTableBlock',
'mentoring-column = mentoring:MentoringTableColumn',
'mentoring-answer = mentoring:AnswerBlock',
'mentoring-answer-recap = mentoring:AnswerRecapBlock',
'mentoring-mcq = mentoring:MCQBlock',
'mentoring-rating = mentoring:RatingBlock',
'mentoring-mrq = mentoring:MRQBlock',
'mentoring-message = mentoring:MentoringMessageBlock',
'mentoring-tip = mentoring:TipBlock',
'mentoring-choice = mentoring:ChoiceBlock',
]
setup(
......@@ -70,5 +70,5 @@ setup(
entry_points={
'xblock.v1': BLOCKS,
},
package_data=package_data("mentoring", ["components", "templates", "public", "migrations"]),
package_data=package_data("mentoring", ["templates", "public", "migrations"]),
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment