forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 2
/
templates.py
33 lines (24 loc) · 897 Bytes
/
templates.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
This module handles loading xmodule templates
These templates are used by the CMS to provide content that overrides xmodule defaults for
samples.
``Template``s are defined in x_module. They contain 2 attributes:
:metadata: A dictionary with the template metadata
:data: A JSON value that defines the template content
"""
# should this move to cms since it's really only for module crud?
import logging
from collections import defaultdict
from xblock.core import XBlock
log = logging.getLogger(__name__)
def all_templates():
"""
Returns all templates for enabled modules, grouped by block type
"""
# TODO use memcache to memoize w/ expiration
templates = defaultdict(list)
for category, block in XBlock.load_classes():
if not hasattr(block, 'templates'):
continue
templates[category] = block.templates()
return templates