annotate forums/search_indexes.py @ 693:ad69236e8501

For issue #52, update many 3rd party Javascript libraries. Updated to jquery 1.10.2, jquery ui 1.10.3. This broke a lot of stuff. - Found a newer version of the jquery cycle all plugin (3.0.3). - Updated JPlayer to 2.4.0. - Updated to MarkItUp 1.1.14. This also required me to add multiline attributes set to true on various buttons in the markdown set. - As per a stackoverflow post, added some code to get multiline titles in a jQuery UI dialog. They removed that functionality but allow you to put it back. Tweaked the MarkItUp preview CSS to show blockquotes in italic. Did not update TinyMCE at this time. I'm not using the JQuery version and this version appears to work ok for now. What I should do is make a repo for MarkItUp and do a vendor branch thing so I don't have to futz around diffing directories to figure out if I'll lose changes when I update.
author Brian Neal <bgneal@gmail.com>
date Wed, 04 Sep 2013 19:55:20 -0500
parents ee87ea74d46b
children ad53d929281a
rev   line source
bgneal@222 1 """Haystack search index for the weblinks application."""
bgneal@222 2 from haystack.indexes import *
bgneal@222 3 from haystack import site
bgneal@469 4 from custom_search.indexes import CondQueuedSearchIndex
bgneal@222 5
bgneal@414 6 from forums.models import Forum, Topic, Post
bgneal@469 7 from forums.signals import topic_content_update, post_content_update
bgneal@414 8
bgneal@414 9
bgneal@467 10 class TopicIndex(CondQueuedSearchIndex):
bgneal@414 11 text = CharField(document=True, use_template=True)
bgneal@414 12 author = CharField(model_attr='user')
bgneal@414 13 pub_date = DateTimeField(model_attr='creation_date')
bgneal@414 14
bgneal@533 15 def index_queryset(self):
bgneal@414 16 return Topic.objects.filter(forum__in=Forum.objects.public_forum_ids())
bgneal@414 17
bgneal@414 18 def get_updated_field(self):
bgneal@414 19 return 'update_date'
bgneal@222 20
bgneal@469 21 def _setup_save(self, model):
bgneal@469 22 topic_content_update.connect(self.enqueue_save)
bgneal@469 23
bgneal@469 24 def _teardown_save(self, model):
bgneal@469 25 topic_content_update.disconnect(self.enqueue_save)
bgneal@469 26
bgneal@470 27 def enqueue_save(self, sender, **kwargs):
bgneal@470 28 return self.enqueue('update', sender)
bgneal@470 29
bgneal@467 30 def can_index(self, instance):
bgneal@467 31 return instance.forum.id in Forum.objects.public_forum_ids()
bgneal@222 32
bgneal@467 33
bgneal@467 34 class PostIndex(CondQueuedSearchIndex):
bgneal@222 35 text = CharField(document=True, use_template=True)
bgneal@222 36 author = CharField(model_attr='user')
bgneal@222 37 pub_date = DateTimeField(model_attr='creation_date')
bgneal@222 38
bgneal@533 39 def index_queryset(self):
bgneal@222 40 return Post.objects.filter(
bgneal@414 41 topic__forum__in=Forum.objects.public_forum_ids())
bgneal@222 42
bgneal@277 43 def get_updated_field(self):
bgneal@277 44 return 'update_date'
bgneal@277 45
bgneal@469 46 def _setup_save(self, model):
bgneal@469 47 post_content_update.connect(self.enqueue_save)
bgneal@469 48
bgneal@469 49 def _teardown_save(self, model):
bgneal@469 50 post_content_update.disconnect(self.enqueue_save)
bgneal@469 51
bgneal@470 52 def enqueue_save(self, sender, **kwargs):
bgneal@470 53 return self.enqueue('update', sender)
bgneal@470 54
bgneal@467 55 def can_index(self, instance):
bgneal@467 56 return instance.topic.forum.id in Forum.objects.public_forum_ids()
bgneal@467 57
bgneal@222 58
bgneal@414 59 site.register(Topic, TopicIndex)
bgneal@222 60 site.register(Post, PostIndex)