|
@@ -12,6 +12,7 @@
|
|
import whoosh
|
|
import whoosh
|
|
from flask_whooshee import AbstractWhoosheer
|
|
from flask_whooshee import AbstractWhoosheer
|
|
|
|
|
|
|
|
+from flaskbb._compat import text_type
|
|
from flaskbb.forum.models import Forum, Topic, Post
|
|
from flaskbb.forum.models import Forum, Topic, Post
|
|
from flaskbb.user.models import User
|
|
from flaskbb.user.models import User
|
|
|
|
|
|
@@ -30,18 +31,18 @@ class PostWhoosheer(AbstractWhoosheer):
|
|
def update_post(cls, writer, post):
|
|
def update_post(cls, writer, post):
|
|
writer.update_document(
|
|
writer.update_document(
|
|
post_id=post.id,
|
|
post_id=post.id,
|
|
- username=post.username,
|
|
|
|
- modified_by=post.modified_by,
|
|
|
|
- content=post.content
|
|
|
|
|
|
+ username=text_type(post.username),
|
|
|
|
+ modified_by=text_type(post.modified_by),
|
|
|
|
+ content=text_type(post.content)
|
|
)
|
|
)
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
def insert_post(cls, writer, post):
|
|
def insert_post(cls, writer, post):
|
|
writer.add_document(
|
|
writer.add_document(
|
|
post_id=post.id,
|
|
post_id=post.id,
|
|
- username=post.username,
|
|
|
|
- modified_by=post.modified_by,
|
|
|
|
- content=post.content
|
|
|
|
|
|
+ username=text_type(post.username),
|
|
|
|
+ modified_by=text_type(post.modified_by),
|
|
|
|
+ content=text_type(post.content)
|
|
)
|
|
)
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
@@ -63,18 +64,18 @@ class TopicWhoosheer(AbstractWhoosheer):
|
|
def update_topic(cls, writer, topic):
|
|
def update_topic(cls, writer, topic):
|
|
writer.update_document(
|
|
writer.update_document(
|
|
topic_id=topic.id,
|
|
topic_id=topic.id,
|
|
- title=topic.title,
|
|
|
|
- username=topic.username,
|
|
|
|
- content=getattr(topic.first_post,'content',None)
|
|
|
|
|
|
+ title=text_type(topic.title),
|
|
|
|
+ username=text_type(topic.username),
|
|
|
|
+ content=text_type(getattr(topic.first_post, 'content', None))
|
|
)
|
|
)
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
def insert_topic(cls, writer, topic):
|
|
def insert_topic(cls, writer, topic):
|
|
writer.add_document(
|
|
writer.add_document(
|
|
topic_id=topic.id,
|
|
topic_id=topic.id,
|
|
- title=topic.title,
|
|
|
|
- username=topic.username,
|
|
|
|
- content=getattr(topic.first_post,'content',None)
|
|
|
|
|
|
+ title=text_type(topic.title),
|
|
|
|
+ username=text_type(topic.username),
|
|
|
|
+ content=text_type(getattr(topic.first_post, 'content', None))
|
|
)
|
|
)
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
@@ -95,16 +96,16 @@ class ForumWhoosheer(AbstractWhoosheer):
|
|
def update_forum(cls, writer, forum):
|
|
def update_forum(cls, writer, forum):
|
|
writer.update_document(
|
|
writer.update_document(
|
|
forum_id=forum.id,
|
|
forum_id=forum.id,
|
|
- title=forum.title,
|
|
|
|
- description=forum.description
|
|
|
|
|
|
+ title=text_type(forum.title),
|
|
|
|
+ description=text_type(forum.description)
|
|
)
|
|
)
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
def insert_forum(cls, writer, forum):
|
|
def insert_forum(cls, writer, forum):
|
|
writer.add_document(
|
|
writer.add_document(
|
|
forum_id=forum.id,
|
|
forum_id=forum.id,
|
|
- title=forum.title,
|
|
|
|
- description=forum.description
|
|
|
|
|
|
+ title=text_type(forum.title),
|
|
|
|
+ description=text_type(forum.description)
|
|
)
|
|
)
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
@@ -125,16 +126,16 @@ class UserWhoosheer(AbstractWhoosheer):
|
|
def update_user(cls, writer, user):
|
|
def update_user(cls, writer, user):
|
|
writer.update_document(
|
|
writer.update_document(
|
|
user_id=user.id,
|
|
user_id=user.id,
|
|
- username=user.username,
|
|
|
|
- email=user.email
|
|
|
|
|
|
+ username=text_type(user.username),
|
|
|
|
+ email=text_type(user.email)
|
|
)
|
|
)
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
def insert_user(cls, writer, user):
|
|
def insert_user(cls, writer, user):
|
|
writer.add_document(
|
|
writer.add_document(
|
|
user_id=user.id,
|
|
user_id=user.id,
|
|
- username=user.username,
|
|
|
|
- email=user.email
|
|
|
|
|
|
+ username=text_type(user.username),
|
|
|
|
+ email=text_type(user.email)
|
|
)
|
|
)
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|