import djapian from apps.jsjtbb.models import Post class PostIndexer(djapian.Indexer): fields=['body'] tags=[ ('user', 'user.username' ), ('topic', 'topic.name' ), ('forum', 'topic.forum.pk' ), ('body', 'body' ), ('created', 'created' ), ] trigger = lambda indexer, post: not post.topic.forum.category.groups.count() post_indexer = djapian.add_index(Post, PostIndexer)
"title": "subject", "author": "user", } trigger = lambda indexer, obj: obj.is_active def _get_stem_language(self, obj=None): return 'none' class CommentIndexer(djapian.Indexer): fields = ['text'] tags = [ ('author', 'author.name') ] def _get_stem_language(self, obj=None): return 'none' djapian.add_index(Entry, EntryIndexer, attach_as='indexer') djapian.add_index(Comment, CommentIndexer, attach_as='indexer') class BaseTestCase(TestCase): def tearDown(self): Entry.indexer.clear() Comment.indexer.clear() class BaseIndexerTest(object): def setUp(self): self.person = Person.objects.create(name="Alex") self.entries = [ Entry.objects.create( author=self.person, title="Test entry",
month = CharField(tr(u'Month'), max_length=16) pages = CharField(tr(u'Pages'), max_length=32) doi = CharField(tr(u'DOI'), max_length=128) url = CharField(tr(u'url'), max_length=128) class BibTexEntryIndexer(djapian.Indexer): fields=[] tags=[ ('title','title'), ('author','author') ] def trigger(self,obj): return True if not hasattr(BibTexEntry,'indexer'): djapian.add_index(BibTexEntry, BibTexEntryIndexer, attach_as='indexer') class BibTexField(Model): entry = ForeignKey(BibTexEntry) name = CharField('name', max_length=64) value = CharField('value', max_length=256) class Revision(Model): entry = ForeignKey(BibTexEntry) editor = ForeignKey(User, verbose_name=tr(u'Editor'), null=True) editor_ip = IPAddressField(tr(u"IP Address of the Editor")) revision = IntegerField(tr(u"Revision Number")) modified = DateTimeField(tr(u"Modified at"), default=datetime.datetime.now) reverted = BooleanField(tr(u"Reverted Revision"), default=False)
("editors", "editors"), ('rating', 'rating'), ] aliases = { "title": "subject", "author": "user", } trigger = lambda indexer, obj: obj.is_active class CommentIndexer(Indexer): fields = ['text'] tags = [ ('author', 'author.name') ] djapian.add_index(Entry, EntryIndexer, attach_as='indexer') djapian.add_index(Comment, CommentIndexer, attach_as='indexer') class BaseTestCase(TestCase): def tearDown(self): Entry.indexer.clear() class BaseIndexerTest(object): def setUp(self): self.person = Person.objects.create(name="Alex") self.entries= [ Entry.objects.create( author=self.person, title="Test entry", rating=4.5,
class Deed(models.Model): """ Who said what when as reported by someone. ``text`` - what is to be recorded ``speaker`` - who said the ``text`` ``user`` - the authenticated user responsible for creating the db record ``deed_date`` - when the Deed was took place ``create_date`` - when the Deed was created in the database """ text = models.TextField() speaker = models.CharField(max_length=100, db_index=True) user = models.ForeignKey(auth_models.User) deed_date = models.DateTimeField(default=datetime.utcnow, db_index=True) create_date = models.DateTimeField(default=datetime.utcnow) class Meta: ordering = ['deed_date'] def dispatch(self, dispatch_list): if dispatch_list: for d in dispatch_list: dispatch.dispatch_to(d, self.text) class DeedIndexer(djapian.Indexer): fields=["text"] if not hasattr(Deed, 'indexer'): djapian.add_index(Deed, DeedIndexer, attach_as="indexer")
import djapian from turbion.bits.blogs.models import Post, Comment class PostIndexer(djapian.Indexer): fields = ("text",) tags = [("status", "status"), ("title", "title"), ("author", "created_by"), ("date", "created_on")] trigger = lambda indexer, post: post.is_published class CommentIndexer(djapian.Indexer): fields = ("text",) tags = [("author", "created_by")] djapian.add_index(Post, PostIndexer, attach_as="indexer") djapian.add_index(Comment, CommentIndexer, attach_as="indexer")
("editors", "editors"), ('rating', 'rating'), ] aliases = { "title": "subject", "author": "user", } trigger = lambda indexer, obj: obj.is_active class CommentIndexer(djapian.Indexer): fields = ['text'] tags = [('author', 'author.name')] djapian.add_index(Entry, EntryIndexer, attach_as='indexer') djapian.add_index(Comment, CommentIndexer, attach_as='indexer') class BaseTestCase(TestCase): def tearDown(self): Entry.indexer.clear() Comment.indexer.clear() class BaseIndexerTest(object): def setUp(self): self.person = Person.objects.create(name="Alex") self.entries = [ Entry.objects.create(