summaryrefslogtreecommitdiffstats
path: root/askbot/views
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-04-23 03:36:39 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-04-23 03:36:39 -0400
commit909b1786a1b0d42e7cb39cf6b18fffe2bc020652 (patch)
treec70912668414d2940f05ba523f56305facdfc954 /askbot/views
parentd627bd6962d24d04a6cad032a86e5fc71e037ab5 (diff)
downloadaskbot-909b1786a1b0d42e7cb39cf6b18fffe2bc020652.tar.gz
askbot-909b1786a1b0d42e7cb39cf6b18fffe2bc020652.tar.bz2
askbot-909b1786a1b0d42e7cb39cf6b18fffe2bc020652.zip
refactoring of the questions title search view
Diffstat (limited to 'askbot/views')
-rw-r--r--askbot/views/commands.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/askbot/views/commands.py b/askbot/views/commands.py
index 1436d3c8..19a956ef 100644
--- a/askbot/views/commands.py
+++ b/askbot/views/commands.py
@@ -807,21 +807,22 @@ def delete_bulk_tag_subscription(request):
return HttpResponseRedirect(reverse('list_bulk_tag_subscription'))
@decorators.get_only
-def title_search(request):
+def api_get_questions(request):
"""json api for retrieving questions by title match"""
- query = request.GET.get('query_text')
-
- if query is None:
- return HttpResponseBadRequest('Invalid query')
-
- query = query.strip()
+ query = request.GET.get('query_text', '').strip()
+ tag_name = request.GET.get('tag_name', None)
if askbot_settings.GROUPS_ENABLED:
threads = models.Thread.objects.get_visible(user=request.user)
else:
threads = models.Thread.objects.all()
- threads = threads.get_for_title_query(query)
+ if tag_name:
+ threads = threads.filter(tags__name=tag_name)
+
+ if query:
+ threads = threads.get_for_title_query(query)
+
#todo: filter out deleted threads, for now there is no way
threads = threads.distinct()[:30]