Add haystack index, and a view for forum search (WIP)

This commit is contained in:
Grégoire Duvauchelle
2018-10-02 12:39:55 +02:00
committed by Skia
parent a96aeba1fa
commit 9b8a881914
8 changed files with 67 additions and 1 deletions

View File

@ -27,7 +27,7 @@ from django.conf import settings
from django.utils.functional import SimpleLazyObject
from django.contrib.auth import get_user
from django.contrib.auth.middleware import (
AuthenticationMiddleware as DjangoAuthenticationMiddleware,
AuthenticationMiddleware as DjangoAuthenticationMiddleware
)
module, klass = settings.AUTH_ANONYMOUS_MODEL.rsplit(".", 1)

View File

@ -27,6 +27,7 @@ from django.db import models
from haystack import indexes, signals
from core.models import User
from forum.models import ForumMessage
class UserIndex(indexes.SearchIndex, indexes.Indexable):
@ -54,3 +55,10 @@ class UserOnlySignalProcessor(signals.BaseSignalProcessor):
# Disconnect only for the ``User`` model.
models.signals.post_save.disconnect(self.handle_save, sender=User)
models.signals.post_delete.disconnect(self.handle_delete, sender=User)
class ForumMessageIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
def get_model(self):
return ForumMessage

View File

@ -1476,6 +1476,24 @@ textarea {
}
}
}
.search-results {
width: 100%;
.result-box {
width: 100%;
}
.result-topic {
display: inline-block;
background: #9f9f9f;
width: 19%;
}
.result-message {
display: inline-block;
background: #dbdbdb;
width: 80%;
}
}
}
/*------------------------------SAS------------------------------------*/

View File

@ -0,0 +1 @@
{{ object.message }}