summaryrefslogtreecommitdiffstats
path: root/askbot/models/question.py
diff options
context:
space:
mode:
Diffstat (limited to 'askbot/models/question.py')
-rw-r--r--askbot/models/question.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/askbot/models/question.py b/askbot/models/question.py
index 597a95ae..7d1c3758 100644
--- a/askbot/models/question.py
+++ b/askbot/models/question.py
@@ -190,8 +190,31 @@ class ThreadManager(models.Manager):
qs = qs.filter(posts__post_type='question', posts__author__in=query_users) # TODO: unify with search_state.author ?
tags = search_state.unified_tags()
- for tag in tags:
- qs = qs.filter(tags__name=tag) # Tags or AND-ed here, not OR-ed (i.e. we fetch only threads with all tags)
+ if len(tags) > 0:
+
+ if askbot_settings.TAG_SEARCH_INPUT_ENABLED:
+ #todo: this may be gone or disabled per option
+ #"tag_search_box_enabled"
+ existing_tags = set(
+ Tag.objects.filter(
+ name__in = tags
+ ).values_list(
+ 'name',
+ flat = True
+ )
+ )
+
+ non_existing_tags = set(tags) - existing_tags
+ meta_data['non_existing_tags'] = list(non_existing_tags)
+ tags = existing_tags
+ else:
+ meta_data['non_existing_tags'] = list()
+
+ #construct filter for the tag search
+ for tag in tags:
+ qs = qs.filter(tags__name=tag) # Tags or AND-ed here, not OR-ed (i.e. we fetch only threads with all tags)
+ else:
+ meta_data['non_existing_tags'] = list()
if search_state.scope == 'unanswered':
qs = qs.filter(closed = False) # Do not show closed questions in unanswered section