mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Add haystack index, and a view for forum search (WIP)
This commit is contained in:
committed by
Skia
parent
a96aeba1fa
commit
9b8a881914
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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------------------------------------*/
|
||||
|
@ -0,0 +1 @@
|
||||
{{ object.message }}
|
Reference in New Issue
Block a user