Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-wiki
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
OpenEdx
django-wiki
Commits
e20b2d66
Commit
e20b2d66
authored
Feb 25, 2013
by
tschmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clear ancestor cache on save and delete article so that things like article_lists are refreshed
parent
9ca892d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
wiki/models/urlpath.py
+10
-0
No files found.
wiki/models/urlpath.py
View file @
e20b2d66
...
@@ -236,6 +236,13 @@ class URLPath(MPTTModel):
...
@@ -236,6 +236,13 @@ class URLPath(MPTTModel):
# SIGNAL HANDLERS
# SIGNAL HANDLERS
######################################################
######################################################
# clear the ancestor cache when saving or deleting articles so things like
# article_lists will be refreshed
def
_clear_ancestor_cache
(
article
):
for
urlpath
in
article
.
urlpath_set
.
all
():
for
ancestor
in
urlpath
.
get_ancestors
():
ancestor
.
article
.
clear_cache
()
# Just get this once
# Just get this once
urlpath_content_type
=
None
urlpath_content_type
=
None
...
@@ -246,6 +253,7 @@ def on_article_relation_save(**kwargs):
...
@@ -246,6 +253,7 @@ def on_article_relation_save(**kwargs):
urlpath_content_type
=
ContentType
.
objects
.
get_for_model
(
URLPath
)
urlpath_content_type
=
ContentType
.
objects
.
get_for_model
(
URLPath
)
if
instance
.
content_type
==
urlpath_content_type
:
if
instance
.
content_type
==
urlpath_content_type
:
URLPath
.
objects
.
filter
(
id
=
instance
.
object_id
)
.
update
(
article
=
instance
.
article
)
URLPath
.
objects
.
filter
(
id
=
instance
.
object_id
)
.
update
(
article
=
instance
.
article
)
_clear_ancestor_cache
(
instance
.
article
)
post_save
.
connect
(
on_article_relation_save
,
ArticleForObject
)
post_save
.
connect
(
on_article_relation_save
,
ArticleForObject
)
...
@@ -287,5 +295,7 @@ def on_article_delete(instance, *args, **kwargs):
...
@@ -287,5 +295,7 @@ def on_article_delete(instance, *args, **kwargs):
for
child
in
urlpath
.
get_children
():
for
child
in
urlpath
.
get_children
():
child
.
move_to
(
get_lost_and_found
())
child
.
move_to
(
get_lost_and_found
())
# ...and finally delete the path itself
# ...and finally delete the path itself
_clear_ancestor_cache
(
instance
)
pre_delete
.
connect
(
on_article_delete
,
Article
)
pre_delete
.
connect
(
on_article_delete
,
Article
)
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