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
088e2de5
Commit
088e2de5
authored
Feb 25, 2013
by
tschmidt-dev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved article save and delete clear cache signal handlers to Article model
parent
217fea9b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
wiki/models/article.py
+20
-0
wiki/models/urlpath.py
+0
-9
No files found.
wiki/models/article.py
View file @
088e2de5
...
@@ -4,6 +4,7 @@ from django.contrib.contenttypes import generic
...
@@ -4,6 +4,7 @@ from django.contrib.contenttypes import generic
from
django.contrib.auth.models
import
User
,
Group
from
django.contrib.auth.models
import
User
,
Group
from
django.core.cache
import
cache
from
django.core.cache
import
cache
from
django.db
import
models
from
django.db
import
models
from
django.db.models.signals
import
post_save
,
pre_delete
from
django.utils.safestring
import
mark_safe
from
django.utils.safestring
import
mark_safe
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
...
@@ -332,3 +333,22 @@ class ArticleRevision(BaseRevisionMixin, models.Model):
...
@@ -332,3 +333,22 @@ class ArticleRevision(BaseRevisionMixin, models.Model):
ordering
=
(
'created'
,)
ordering
=
(
'created'
,)
unique_together
=
(
'article'
,
'revision_number'
)
unique_together
=
(
'article'
,
'revision_number'
)
######################################################
# 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
ancestor
in
article
.
ancestor_objects
():
ancestor
.
article
.
clear_cache
()
def
on_article_save_clear_cache
(
instance
,
**
kwargs
):
_clear_ancestor_cache
(
instance
.
article
)
post_save
.
connect
(
on_article_save_clear_cache
,
Article
)
def
on_article_delete_clear_cache
(
instance
,
**
kwargs
):
_clear_ancestor_cache
(
instance
)
pre_delete
.
connect
(
on_article_delete_clear_cache
,
Article
)
wiki/models/urlpath.py
View file @
088e2de5
...
@@ -236,12 +236,6 @@ class URLPath(MPTTModel):
...
@@ -236,12 +236,6 @@ 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
ancestor
in
article
.
ancestor_objects
():
ancestor
.
article
.
clear_cache
()
# Just get this once
# Just get this once
urlpath_content_type
=
None
urlpath_content_type
=
None
...
@@ -252,7 +246,6 @@ def on_article_relation_save(**kwargs):
...
@@ -252,7 +246,6 @@ 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
)
...
@@ -295,6 +288,4 @@ def on_article_delete(instance, *args, **kwargs):
...
@@ -295,6 +288,4 @@ def on_article_delete(instance, *args, **kwargs):
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