Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
d8011fff
Commit
d8011fff
authored
Feb 12, 2016
by
Gabe Mulley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command to dump all xblock fields
parent
239c3822
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
lms/djangoapps/courseware/management/commands/dump_xblocks.py
+31
-0
No files found.
lms/djangoapps/courseware/management/commands/dump_xblocks.py
0 → 100644
View file @
d8011fff
# pylint: disable=missing-docstring
from
textwrap
import
dedent
from
django.core.management.base
import
BaseCommand
,
CommandError
from
xblock.core
import
XBlock
from
xblock.fields
import
Scope
import
yaml
class
Command
(
BaseCommand
):
"""
Produce a YAML description of all XBlocks the platform knows about and their fields.
"""
help
=
dedent
(
__doc__
)
.
strip
()
option_list
=
BaseCommand
.
option_list
def
handle
(
self
,
*
args
,
**
options
):
blocks
=
{}
for
block_type
,
block_class
in
XBlock
.
load_classes
():
block_struct
=
blocks
.
setdefault
(
block_type
,
{})
block_struct
[
'fields'
]
=
[]
if
getattr
(
block_class
,
'has_children'
,
False
):
block_struct
[
'has_children'
]
=
True
for
field_name
,
field
in
block_class
.
fields
.
items
():
if
field_name
==
'xml_attributes'
:
continue
if
field
.
scope
==
Scope
.
settings
:
block_struct
[
'fields'
]
.
append
(
field_name
)
return
yaml
.
dump
(
blocks
,
default_flow_style
=
False
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment