Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
93d18651
Commit
93d18651
authored
12 years ago
by
Chris Dodge
Browse files
Options
Downloads
Patches
Plain Diff
clean up templates that were removed from disk - we need to remove from DB as well
parent
46a7f742
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/lib/xmodule/xmodule/templates.py
+13
-0
13 additions, 0 deletions
common/lib/xmodule/xmodule/templates.py
with
13 additions
and
0 deletions
common/lib/xmodule/xmodule/templates.py
+
13
−
0
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment