Exemplo n.º 1
0
def default_comment_template_data(request, comment_id):
    mixergy = session. \
                query(Comment, Page, UrlMap). \
                join(Page, UrlMap). \
                filter(Comment.comment_id==comment_id). \
                first()

    if not mixergy:
        # TODO: "The requested comment was not found, here are a few latest coments"
        #       "Here are latest posts, here are most commented posts..."
        raise NotFound()

    comment, page, urlmap = mixergy

    template_data = {
        'page':                 page,
        'page_path':            urlmap.request_path,
        'comment_submit_path':  '/c/%d?reply' % comment_id,
        'comment_parent_id':    comment_id,
        'comment':              comment,
        'form':                 request.form,
        'lynx':                 lynx_browser(request),
        'captcha_nr' :          random.randint(1,20),
        'admin' : admin_cred_match(request)
    }
    return template_data
Exemplo n.º 2
0
def default_page_template_data(request, map):
    plain_old_comments = map.page.comments.all()
    if request.args.get('linear') is not None:
        comment_mode = 'linear'
        comments = linear(plain_old_comments)
    else:
        comment_mode = 'threaded'
        comments = thread(plain_old_comments)

    return {
        'display_options': MakoDict(default_display_options()),
        'page_data':       MakoDict({
            'page':                 map.page,
            'page_path':            map.request_path
        }),
        'comment_data':    MakoDict({
            'comment_count':        len(plain_old_comments),
            'comments':             comments,
            'comment_submit_path':  map.request_path,
            'comment_mode':         comment_mode,
            'form':                 request.form,
        }, ['comments', 'form']),
        'tags_data':       MakoDict({
            'tags':                 map.page.tags
        }),
        'related_posts':   related_posts(map.page),
        'lynx': lynx_browser(request)
    }
Exemplo n.º 3
0
def default_comment_template_data(request, comment_id):
    mixergy = session.query(Comment, Page, UrlMap).join(Page, UrlMap).filter(Comment.comment_id == comment_id).first()

    if not mixergy:
        # TODO: "The requested comment was not found, here are a few latest coments"
        #       "Here are latest posts, here are most commented posts..."
        raise NotFound()

    comment, page, urlmap = mixergy

    template_data = {
        "page": page,
        "page_path": urlmap.request_path,
        "comment_submit_path": "/c/%d?reply" % comment_id,
        "comment_parent_id": comment_id,
        "comment": comment,
        "form": request.form,
        "lynx": lynx_browser(request),
    }
    return template_data