@login_required
def view_tag(request, tagname):
    context = {}

    approved_questions = Question.objects.filter(status__exact="Approved")
    pending_questions = Question.objects.filter(status__exact="Pending")
    banned_questions = Question.objects.filter(status__exact="Banned")

    settings = Settings.get_by_user(request.user)
    if settings.group:
        approved_questions = approved_questions.filter(groups__id=settings.group.id)
        pending_questions = pending_questions.filter(groups__id=settings.group.id)
        banned_questions = banned_questions.filter(groups__id=settings.group.id)

    context["tagname"] = tagname
    tagname = '"%s"' % tagname
    context["approved_questions"] = TaggedItem.objects.get_by_model(approved_questions, tagname)
    context["pending_questions"] = TaggedItem.objects.get_by_model(pending_questions, tagname)
    context["banned_questions"] = TaggedItem.objects.get_by_model(banned_questions, tagname)
    context["settings"] = settings

    return r2r(request, "view_tag", context)
dataset/ETHPy150Open dropbox/questions/questions/views.py/view_tag/original