def suggest_tags(request): "Returns suggested tags" tags = Tag.objects.all().order_by('-count')[:10] data = [ x.lower() for x in settings.NAVBAR_SPECIAL_TAGS ] + \ [ "software error" ] + [ t.name for t in tags ] return json_response(data)
def suggest_tags(request): "Returns suggested tags" tags = Tag.objects.all().order_by('-count')[:10] data = settings.POST_TAG_LIST + [t.name for t in tags] data = filter(None, data) return json_response(data)
def search_title(request): "Handles title searches" q = request.GET.get("q", "") results = SearchQuerySet().filter(content=q).highlight()[:50] items = [] for row in results: ob = row.object context = join_highlights(row) context = context or slow_highlight(query=q, text=row.content) text = "%s" % row.title items.append(dict(id=ob.id, text=text, context=context, author=row.author)) payload = dict(items=items) return json_response(payload)
def search_title(request): "Handles title searches" q = request.GET.get('q', '') results = SearchQuerySet().filter(content=q).highlight()[:50] items = [] for row in results: ob = row.object context = join_highlights(row) context = context or slow_highlight(query=q, text=row.content) text = "%s" % row.title items.append( dict(id=ob.id, text=text, context=context, author=row.author), ) payload = dict(items=items) return json_response(payload)
#@ajax_error_wrapper def search_title(request): "Handles title searches" q = request.GET.get('q', '') content = AutoQuery(q) results = SearchQuerySet().filter(content=content).highlight()[:50] items = [] for row in results: try: ob = row.object # Why can this happen? if not ob: continue context = join_highlights(row) context = context or slow_highlight(query=q, text=row.content) text = "%s" % row.title items.append( dict(id=ob.get_absolute_url(), text=text, context=context, author=row.author, url=ob.get_absolute_url()), ) except Exception, exc: logger.error(content) logger.error(exc) pass payload = dict(items=items) return json_response(payload)
"Handles title searches" q = request.GET.get('q', '') content = AutoQuery(q) results = SearchQuerySet().filter(content=content).highlight()[:50] items = [] for row in results: try: ob = row.object # Why can this happen? if not ob: continue context = join_highlights(row) context = context or slow_highlight(query=q, text=row.content) text = "%s" % row.title items.append( dict(id=ob.get_absolute_url(), text=text, context=context, author=row.author, url=ob.get_absolute_url()), ) except Exception, exc: logger.error(content) logger.error(exc) pass payload = dict(items=items) return json_response(payload)
def _f(*args, **kwargs): result = func(*args, **kwargs) return ajax.json_response(result)