Commit 764eeb8d authored by fred's avatar fred
Browse files

index news items

parent 07037b05
from haystack import indexes from haystack import indexes
from .models import Emission, Episode from .models import Emission, Episode, NewsItem
class EmissionIndex(indexes.SearchIndex, indexes.Indexable): class EmissionIndex(indexes.SearchIndex, indexes.Indexable):
...@@ -13,6 +13,7 @@ class EmissionIndex(indexes.SearchIndex, indexes.Indexable): ...@@ -13,6 +13,7 @@ class EmissionIndex(indexes.SearchIndex, indexes.Indexable):
def prepare_categories(self, obj): def prepare_categories(self, obj):
return [category.title for category in obj.categories.all()] return [category.title for category in obj.categories.all()]
class EpisodeIndex(indexes.SearchIndex, indexes.Indexable): class EpisodeIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True) text = indexes.CharField(document=True, use_template=True)
tags = indexes.MultiValueField(faceted=True) tags = indexes.MultiValueField(faceted=True)
...@@ -22,3 +23,14 @@ class EpisodeIndex(indexes.SearchIndex, indexes.Indexable): ...@@ -22,3 +23,14 @@ class EpisodeIndex(indexes.SearchIndex, indexes.Indexable):
def prepare_tags(self, obj): def prepare_tags(self, obj):
return [tag.name for tag in obj.tags.all()] return [tag.name for tag in obj.tags.all()]
class NewsItemIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
tags = indexes.MultiValueField(faceted=True)
def get_model(self):
return NewsItem
def prepare_tags(self, obj):
return [tag.name for tag in obj.tags.all()]
{{ object.title }}
{{ object.text|striptags }}
{% if object.emission %}
{{ object.emission.title }}
{% endif %}
{% for tag in object.tags.all %} {{ tag.name }} {% endfor %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment