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
93d18651
Commit
93d18651
authored
Feb 12, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up templates that were removed from disk - we need to remove from DB as well
parent
46a7f742
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
common/lib/xmodule/xmodule/templates.py
+13
-0
No files found.
common/lib/xmodule/xmodule/templates.py
View file @
93d18651
...
...
@@ -56,6 +56,10 @@ def update_templates():
available from the installed plugins
"""
# cdodge: build up a list of all existing templates. This will be used to determine which
# templates have been removed from disk - and thus we need to remove from the DB
templates_to_delete
=
modulestore
(
'direct'
)
.
get_items
([
'i4x'
,
'edx'
,
'templates'
,
None
,
None
,
None
])
for
category
,
templates
in
all_templates
()
.
items
():
for
template
in
templates
:
if
'display_name'
not
in
template
.
metadata
:
...
...
@@ -85,3 +89,12 @@ def update_templates():
modulestore
(
'direct'
)
.
update_item
(
template_location
,
template
.
data
)
modulestore
(
'direct'
)
.
update_children
(
template_location
,
template
.
children
)
modulestore
(
'direct'
)
.
update_metadata
(
template_location
,
template
.
metadata
)
# remove template from list of templates to delete
templates_to_delete
=
[
t
for
t
in
templates_to_delete
if
t
.
location
!=
template_location
]
# now remove all templates which appear to have removed from disk
if
len
(
templates_to_delete
)
>
0
:
logging
.
debug
(
'deleting dangling templates = {0}'
.
format
(
templates_to_delete
))
for
template
in
templates_to_delete
:
modulestore
(
'direct'
)
.
delete_item
(
template
.
location
)
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