realms-wiki/realms/modules/search/hooks.py

36 lines
826 B
Python
Raw Normal View History

2014-11-10 18:54:46 +02:00
from realms.modules.wiki.models import Wiki
2014-11-13 01:06:56 +02:00
from realms import search
2014-11-10 18:54:46 +02:00
@Wiki.after('write_page')
2014-11-12 01:06:28 +02:00
def wiki_write_page(name, content, message=None, username=None, email=None, **kwargs):
2014-11-13 01:06:56 +02:00
if not hasattr(search, 'index_wiki'):
# using simple search or none
return
2014-11-10 18:54:46 +02:00
body = dict(name=name,
2014-11-12 01:06:28 +02:00
content=content,
message=message,
email=email,
username=username)
2014-11-13 01:06:56 +02:00
return search.index_wiki(name, body)
2014-11-10 18:54:46 +02:00
@Wiki.after('rename_page')
def wiki_rename_page(old_name, *args, **kwargs):
if not hasattr(search, 'index_wiki'):
return
return search.delete_wiki(old_name)
2015-09-28 07:57:56 +03:00
@Wiki.after('delete_page')
def wiki_delete_page(name, *args, **kwargs):
if not hasattr(search, 'index_wiki'):
return
return search.delete_wiki(name)