def tags(request, slug): if request.GET.has_key('addtag'): addtag = clean_tag_query(request.GET['addtag']) if not addtag in slug: return HttpResponseRedirect('/page/tags/' + slug + '|' + addtag) else: return HttpResponseRedirect('/page/tags/' + slug) if request.GET.has_key("removetag"): removetag = clean_tag_query(request.GET["removetag"]) new_slug = slug.replace("|" + removetag, "") new_slug = new_slug.replace(removetag, "") return HttpResponseRedirect("/page/tags/" + new_slug) tag_array = array_from_separator_string(slug, '|') tags = Tag.objects.filter(name__in = tag_array[:5]) posts = Post.objects.all() post_count = 0 for tag in tags: posts = posts.filter(tags = tag) post_count = post_count + 1 if post_count == 0: posts = None return render_to_response("cms/post_list.html", context_instance = RequestContext(request, {"posts" : posts, "tags" : tag_array, "extra_path" : settings.BASE_URL_PATH}))
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}))