Commit bcf736a6 by dragonfi

Refactor: Reduce repetition with FLOATING_BLOCKS constant

parent 9d0e771a
...@@ -91,6 +91,8 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -91,6 +91,8 @@ class MentoringBlock(XBlockWithLightChildren):
MENTORING_MODES = ('standard', 'assessment') MENTORING_MODES = ('standard', 'assessment')
FLOATING_BLOCKS = (TitleBlock, MentoringMessageBlock, SharedHeaderBlock)
@property @property
def is_assessment(self): def is_assessment(self):
return self.mode == 'assessment' return self.mode == 'assessment'
...@@ -98,7 +100,7 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -98,7 +100,7 @@ class MentoringBlock(XBlockWithLightChildren):
@property @property
def steps(self): def steps(self):
return [child for child in self.get_children_objects() if return [child for child in self.get_children_objects() if
not isinstance(child, (HTMLBlock, TitleBlock, MentoringMessageBlock, SharedHeaderBlock))] not isinstance(child, self.FLOATING_BLOCKS + (HTMLBlock,))]
@property @property
def score(self): def score(self):
...@@ -131,7 +133,7 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -131,7 +133,7 @@ class MentoringBlock(XBlockWithLightChildren):
fragment, named_children = self.get_children_fragment( fragment, named_children = self.get_children_fragment(
context, view_name='mentoring_view', context, view_name='mentoring_view',
not_instance_of=(MentoringMessageBlock, TitleBlock, SharedHeaderBlock) not_instance_of=self.FLOATING_BLOCKS,
) )
...@@ -292,7 +294,7 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -292,7 +294,7 @@ class MentoringBlock(XBlockWithLightChildren):
completed = False completed = False
current_child = None current_child = None
children = [child for child in self.get_children_objects() \ children = [child for child in self.get_children_objects() \
if not isinstance(child, (TitleBlock, SharedHeaderBlock))] if not isinstance(child, self.FLOATING_BLOCKS)]
for child in children: for child in children:
if child.name and child.name in submissions: if child.name and child.name in submissions:
......
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