diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-07-09 20:59:24 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-13 18:26:03 +0200 |
commit | a2e2e57d792c8ad9f1ced7f3807b97635f38c36d (patch) | |
tree | 59990ede30849daf44a9323d7e9a18e17d707285 /ishtar_common/models.py | |
parent | f642961947a1a4fb79e49ff764d93b3f0ab474db (diff) | |
download | Ishtar-a2e2e57d792c8ad9f1ced7f3807b97635f38c36d.tar.bz2 Ishtar-a2e2e57d792c8ad9f1ced7f3807b97635f38c36d.zip |
Save search queries
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index d65c08f93..016883abe 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1110,6 +1110,8 @@ class FullSearch(models.Model): :param save: True if you want to save the object immediately :return: True if modified """ + if not hasattr(self, 'search_vector'): + return if not self.pk: logger.warning("Cannot update search vector before save or " "after deletion.") @@ -1555,6 +1557,23 @@ def post_delete_record_relation(sender, instance, **kwargs): q.delete() +class SearchQuery(models.Model): + label = models.TextField(_(u"Label"), blank=True) + query = models.TextField(_(u"Query"), blank=True) + content_type = models.ForeignKey(ContentType, + verbose_name=_(u"Content type")) + profile = models.ForeignKey("UserProfile", verbose_name=_(u"Profile")) + is_alert = models.BooleanField(_(u"Is an alert"), default=False) + + class Meta: + verbose_name = _(u"Search query") + verbose_name_plural = _(u"Search queries") + ordering = ['label'] + + def __unicode__(self): + return unicode(self.label) + + class ShortMenuItem(object): @classmethod def get_short_menu_class(cls, pk): |