def tag_autocomplete(request): if not request.GET.has_key("term"): return HttpResponse(simplejson.dumps([])) keyword = request.GET["term"] tag_list = [] tags = Tag.objects(name__istartswith=keyword) for tag in tags: tag_dict = {} tag_dict["label"] = tag.name tag_dict["value"] = tag.name tag_list.append(tag_dict) return HttpResponse(simplejson.dumps(tag_list))
def tags(request, slug): if request.GET.has_key('addtag'): addtag = Tag().clean_tag_query(request.GET['addtag']) if not addtag in slug: return HttpResponseRedirect('/news/tags/' + slug + '|' + addtag) else: return HttpResponseRedirect('/news/tags/' + slug) if request.GET.has_key("removetag"): removetag = Tag().clean_tag_query(request.GET["removetag"]) new_slug = slug.replace("|" + removetag, "") new_slug = new_slug.replace(removetag, "") return HttpResponseRedirect("/news/tags/" + new_slug) tag_array = array_from_separator_string(slug, '|') tags = Tag.objects(name__in = tag_array[:5]) tag_array = [] for tag in tags: tag_array.append(tag.name) posts = StreamPost.objects(tags__all = tag_array).order_by('-created_date') return render_to_response("news/news_home.html", context_instance = RequestContext(request, {"stream_news" : posts, "tags" : tag_array}))