Beispiel #1
0
def ajax_show_posts(request, topicID=None, postID=None):

    if topicID:
        posts = Post.objects.filter(topic=topicID, parent=None).order_by("created")
        # posts = Post.objects.filter(topic=topicID).order_by('created')
    elif postID:
        posts = [get_object_or_404(Post, pk=postID)]
    else:
        return HttpResponse(u"显示 posts 出错")

    HTML = ""
    #    HTML = '''
    # <script type="text/javascript">
    #  $(document).ready(function () {
    #    $(".post-item").draggable();
    #  })
    # </script>
    #'''
    for p in posts:
        HTML += render_post(request.user, p)
    return HttpResponse(HTML)
Beispiel #2
0
def topic(request, id):

    try:
        topic = Topic.objects.get(pk=id)
    except Topic.DoesNotExist:
        url = reverse("wiki:topic_not_exist", args=[id])
        return HttpResponseRedirect(url)

    parents = get_parents(Catalog, topic.catalog.id)
    edit_topic_perm = request.user.has_perm("ydata.edit_topic")

    posts = Post.objects.filter(topic=id, parent=None).order_by("created")
    POST_HTML = ""
    for p in posts:
        POST_HTML += render_post(request.user, p)

    return {
        "parents": parents,
        "topic": topic,
        "edit_topic_perm": edit_topic_perm,
        "title": u"[知识库]%s" % topic.name,
        "POST_HTML": POST_HTML,
        "posts": posts,
    }
Beispiel #3
0
def topic(request, id):

    try:
        topic = Topic.objects.get(pk=id)
    except Topic.DoesNotExist:
        url = reverse('wiki:topic_not_exist', args=[id])
        return HttpResponseRedirect(url)

    parents = get_parents(Catalog, topic.catalog.id)
    edit_topic_perm = request.user.has_perm('ydata.edit_topic')

    posts = Post.objects.filter(topic=id, parent=None).order_by('created')
    POST_HTML = ''
    for p in posts:
        POST_HTML += render_post(request.user, p)

    return {
        'parents': parents,
        'topic': topic,
        'edit_topic_perm': edit_topic_perm,
        'title': u"[知识库]%s" % topic.name,
        'POST_HTML': POST_HTML,
        'posts': posts
    }
Beispiel #4
0
def ajax_show_posts(request, topicID=None, postID=None):

    if topicID:
        posts = Post.objects.filter(topic=topicID,
                                    parent=None).order_by('created')
        #posts = Post.objects.filter(topic=topicID).order_by('created')
    elif postID:
        posts = [
            get_object_or_404(Post, pk=postID),
        ]
    else:
        return HttpResponse(u'显示 posts 出错')

    HTML = ''
    #    HTML = '''
    #<script type="text/javascript">
    #  $(document).ready(function () {
    #    $(".post-item").draggable();
    #  })
    #</script>
    #'''
    for p in posts:
        HTML += render_post(request.user, p)
    return HttpResponse(HTML)