Better indexing of help suggestions with lunr, better display

This commit is contained in:
Griatch 2020-04-11 09:42:22 +02:00
parent a8a5453a97
commit 2a18cb0a2d
8 changed files with 287 additions and 72 deletions

View file

@ -73,7 +73,8 @@ class HelpEntry(SharedMemoryModel):
db_tags = models.ManyToManyField(
Tag,
blank=True,
help_text="tags on this object. Tags are simple string markers to identify, group and alias objects.",
help_text="tags on this object. Tags are simple string markers to "
"identify, group and alias objects.",
)
# (deprecated, only here to allow MUX helpfile load (don't use otherwise)).
# TODO: remove this when not needed anymore.
@ -123,6 +124,19 @@ class HelpEntry(SharedMemoryModel):
"""
return self.locks.check(accessing_obj, access_type=access_type, default=default)
@property
def search_index_entry(self):
"""
Property for easily retaining a search index entry for this object.
"""
return {
"key": self.db_key,
"aliases": " ".join(self.aliases.all()),
"category": self.db_help_category,
"text": self.db_entrytext,
"tags": " ".join(str(tag) for tag in self.tags.all())
}
#
# Web/Django methods
#