Exemplo n.º 1
0
def resultados(ano=2012):
    """Renders a wordpress page special"""
    cn = 'results-{0}'.format(ano)
    slideshow = fromcache(cn) or tocache(
        cn,
        wordpress.getRecentPosts(
            category_name='destaque-govpergunta-%s' % str(ano),
            post_status='publish',
            numberposts=4,
            thumbsizes=['slideshow']))

    categoria = 'resultados-gov-pergunta-%s' % str(ano)
    retorno = fromcache("contribs-{0}".format(ano)) or \
              tocache("contribs-{0}".format(ano) ,wordpress.wpgovp.getContribuicoes(principal='S',category=categoria))

    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    questions = None
    for q in retorno:
        if isinstance(q, list):
            questions = q
    return render_template('resultados.html',
                           menu=menus,
                           questions=questions,
                           sidebar=wordpress.getSidebar,
                           twitter_hash_cabecalho=twitter_hash_cabecalho,
                           ano=ano,
                           slideshow=slideshow,
                           wp=wordpress)
Exemplo n.º 2
0
def post(pid):
    try:
        p = fromcache("post-%s" % str(pid)) or tocache("post-%s" % str(pid),wordpress.getPost(pid))
    except:
        return abort(404)
    """View that renders a post template"""
    recent_posts = fromcache("recent_posts") or tocache("recent_posts", wordpress.getRecentPosts(
        post_status='publish',
        numberposts=4))
    #Retorna a ultima foto inserida neste album.
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    cmts = fromcache("comentarios%s" % str(pid)) or tocache("comentarios%s" % str(pid),  wordpress.getComments(status='approve',post_id=pid))
    tags = fromcache("tags") or tocache("tags", wordpress.getTagCloud())
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    # live_comment_ = request.cookies.get('live_comment_save')
    return render_template(
        'post.html',
        post=p,
        tags=tags,
        sidebar=wordpress.getSidebar,
        # live_comment_save=live_comment_,
        # picday=picday,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        menu=menus,
        comments=cmts,
        show_comment_form=is_authenticated(),
        recent_posts=recent_posts)
Exemplo n.º 3
0
def resultados(ano=2012):
    """Renders a wordpress page special"""
    cn = 'results-{0}'.format(ano)
    slideshow = fromcache(cn) or tocache(cn,wordpress.getRecentPosts(
        category_name='destaque-govpergunta-%s' % str(ano),
        post_status='publish',
        numberposts=4,
        thumbsizes=['slideshow']))

    categoria = 'resultados-gov-pergunta-%s' % str(ano)
    retorno = fromcache("contribs-{0}".format(ano)) or \
              tocache("contribs-{0}".format(ano) ,wordpress.wpgovp.getContribuicoes(principal='S',category=categoria))

    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    questions = None
    for q in retorno:
        if isinstance(q, list):
            questions = q
    return render_template(
        'resultados.html',
        menu=menus,
        questions=questions,
        sidebar=wordpress.getSidebar,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        ano=ano,
        slideshow=slideshow,
        wp=wordpress
    )
Exemplo n.º 4
0
def post_slug(slug):
    try:
        post = fromcache("post-%s" % slug) or tocache(
            "post-%s" % slug, wordpress.getPostByPath(slug))
        if not post['id']:
            abort(404)
    except:
        abort(404)

    print '=============================================================================='
    print post
    print '=============================================================================='

    pid = post['id']

    if 'the_date' not in post.keys():
        # post['the_date'] = post['date']['date'].value
        post['the_date'] = datetime.datetime.strptime(
            post['date']['date'].value, '%Y%m%dT%H:%M:%S')
    """View that renders a post template"""
    recent_posts = fromcache("recent_posts") or tocache(
        "recent_posts",
        wordpress.getRecentPosts(post_status='publish', numberposts=4))
    #Retorna a ultima foto inserida neste album.
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)
    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))
    # cmts = fromcache("comentarios_post_slug-%s"%slug) or tocache("comentarios_post_slug-%s"%slug, wordpress.getComments(status='approve',post_id=pid))
    tags = fromcache("tags") or tocache("tags", wordpress.getTagCloud())
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    # live_comment_ = request.cookies.get('live_comment_save')
    # if live_comment_:
    #     live_comment_ = live_comment_.replace('<br/>','\n')

    resp = make_response(
        render_template(
            'post.html',
            post=post,
            tags=tags,
            # live_comment_save=live_comment_,
            sidebar=wordpress.getSidebar,
            # picday=picday,
            twitter_hash_cabecalho=twitter_hash_cabecalho,
            menu=menus,
            base_url=app.config['BASE_URL'],
            # comments=cmts,
            show_comment_form=is_authenticated(),
            recent_posts=recent_posts))
    # resp.set_cookie('live_comment_save', "" )
    return resp
Exemplo n.º 5
0
def post_slug(slug):
    try:
        post = fromcache("post-%s" % slug) or tocache("post-%s" % slug, wordpress.getPostByPath(slug))
        if not post['id']:
            abort(404)
    except:
        abort(404)

    print '=============================================================================='
    print post
    print '=============================================================================='

    pid = post['id']

    if 'the_date' not in post.keys():
        # post['the_date'] = post['date']['date'].value
        post['the_date'] = datetime.datetime.strptime(post['date']['date'].value,'%Y%m%dT%H:%M:%S')

    """View that renders a post template"""
    recent_posts = fromcache("recent_posts") or tocache("recent_posts", wordpress.getRecentPosts(
        post_status='publish',
        numberposts=4))
    #Retorna a ultima foto inserida neste album.
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    # cmts = fromcache("comentarios_post_slug-%s"%slug) or tocache("comentarios_post_slug-%s"%slug, wordpress.getComments(status='approve',post_id=pid))
    tags = fromcache("tags") or tocache("tags", wordpress.getTagCloud())
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    # live_comment_ = request.cookies.get('live_comment_save')
    # if live_comment_:
    #     live_comment_ = live_comment_.replace('<br/>','\n')

    resp = make_response(
     render_template(
        'post.html',
        post=post,
        tags=tags,
        # live_comment_save=live_comment_,
        sidebar=wordpress.getSidebar,
        # picday=picday,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        menu=menus,
        base_url=app.config['BASE_URL'],
        # comments=cmts,
        show_comment_form=is_authenticated(),
        recent_posts=recent_posts)
    )
    # resp.set_cookie('live_comment_save', "" )
    return resp
Exemplo n.º 6
0
def post(pid):
    try:
        p = fromcache("post-%s" % str(pid)) or tocache("post-%s" % str(pid),
                                                       wordpress.getPost(pid))
    except:
        return abort(404)
    """View that renders a post template"""
    recent_posts = fromcache("recent_posts") or tocache(
        "recent_posts",
        wordpress.getRecentPosts(post_status='publish', numberposts=4))
    #Retorna a ultima foto inserida neste album.
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)
    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))
    cmts = fromcache("comentarios%s" % str(pid)) or tocache(
        "comentarios%s" % str(pid),
        wordpress.getComments(status='approve', post_id=pid))
    tags = fromcache("tags") or tocache("tags", wordpress.getTagCloud())
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    # live_comment_ = request.cookies.get('live_comment_save')
    return render_template(
        'post.html',
        post=p,
        tags=tags,
        sidebar=wordpress.getSidebar,
        # live_comment_save=live_comment_,
        # picday=picday,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        menu=menus,
        comments=cmts,
        show_comment_form=is_authenticated(),
        recent_posts=recent_posts)