# Path: mentoring/light_children.py
# class LightChild(Plugin, LightChildrenMixin):
#     """
#     Base class for the light children
#     """
#     entry_point = 'xblock.light_children'
# 
#     def __init__(self, parent):
#         self.parent = parent
#         self.xblock_container = parent.xblock_container
# 
#     @property
#     def runtime(self):
#         return self.parent.runtime
# 
#     @property
#     def xmodule_runtime(self):
#         try:
#             xmodule_runtime = self.parent.xmodule_runtime
#         except AttributeError:
#             # TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench
#             class xmodule_runtime(object):
#                 course_id = 'sample-course'
#                 anonymous_student_id = 'student1'
#             xmodule_runtime = xmodule_runtime()
#         return xmodule_runtime
# 
#     def save(self):
#         pass
# 
# class Scope(object):
#     content = None
#     user_state = None
# 
# class String(LightChildField):
#     def __init__(self, *args, **kwargs):
#         self.value = kwargs.get('default', '') or ''
# 
#     def __str__(self):
#         return self.value
# 
#     def split(self, *args, **kwargs):
#         return self.value.split(*args, **kwargs)
# 
# Path: mentoring/utils.py
# def render_template(template_path, context={}):
#     """
#     Evaluate a template by resource path, applying the provided context
#     """
#     template_str = load_resource(template_path)
#     template = Template(template_str)
#     return template.render(Context(context))


import logging
from .light_children import LightChild, Scope, String
from .utils import render_template
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program in a file in the toplevel directory called
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
#

# Imports ###########################################################




# Globals ###########################################################

log = logging.getLogger(__name__)


# Classes ###########################################################

class MentoringMessageBlock(LightChild):
    """
    A message which can be conditionally displayed at the mentoring block level,
    for example upon completion of the block
    """
    content = String(help="Message to display upon completion", scope=Scope.content, default="")
    type = String(help="Type of message", scope=Scope.content, default="completed")
    has_children = True

    def mentoring_view(self, context=None):
        fragment, named_children = self.get_children_fragment(context, view_name='mentoring_view')

# Path: mentoring/light_children.py
# class LightChild(Plugin, LightChildrenMixin):
#     """
#     Base class for the light children
#     """
#     entry_point = 'xblock.light_children'
# 
#     def __init__(self, parent):
#         self.parent = parent
#         self.xblock_container = parent.xblock_container
# 
#     @property
#     def runtime(self):
#         return self.parent.runtime
# 
#     @property
#     def xmodule_runtime(self):
#         try:
#             xmodule_runtime = self.parent.xmodule_runtime
#         except AttributeError:
#             # TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench
#             class xmodule_runtime(object):
#                 course_id = 'sample-course'
#                 anonymous_student_id = 'student1'
#             xmodule_runtime = xmodule_runtime()
#         return xmodule_runtime
# 
#     def save(self):
#         pass
# 
# class Scope(object):
#     content = None
#     user_state = None
# 
# class String(LightChildField):
#     def __init__(self, *args, **kwargs):
#         self.value = kwargs.get('default', '') or ''
# 
#     def __str__(self):
#         return self.value
# 
#     def split(self, *args, **kwargs):
#         return self.value.split(*args, **kwargs)
# 
# Path: mentoring/utils.py
# def render_template(template_path, context={}):
#     """
#     Evaluate a template by resource path, applying the provided context
#     """
#     template_str = load_resource(template_path)
#     template = Template(template_str)
#     return template.render(Context(context))


# Path: mentoring/message.py
import logging
from .light_children import LightChild, Scope, String
from .utils import render_template

# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program in a file in the toplevel directory called
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
#

# Imports ###########################################################




# Globals ###########################################################

log = logging.getLogger(__name__)


# Classes ###########################################################

class MentoringMessageBlock(LightChild):
    """
    A message which can be conditionally displayed at the mentoring block level,
    for example upon completion of the block
    """
    content = String(help="Message to display upon completion", scope=Scope.content, default="")
    type = String(help="Type of message", scope=Scope.content, default="completed")
    has_children = True

    def mentoring_view(self, context=None):
        fragment, named_children = self.get_children_fragment(context, view_name='mentoring_view')

        fragment.add_content(render_template('templates/html/message.html', {