Beispiel #1
0
def index(page=0):
    sortby = request.values.get('sortby') or 'date'
    pagination, posts = fromcache('govescuta-posts-%s' % sortby) or \
                        tocache('govescuta-posts-%s' %sortby,
                                    wordpress.wpgove.getAudiencias(
                                            page=page,
                                            sortby=sortby,
                                            totalporpage='10'))
    how_to = fromcache('howtouse') or tocache('howtouse', wordpress.getPageByPath('how-to-use-governo-escuta'))

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

    return render_template(
        'govescuta.html',
        menu=menus,
        # sidebar=wordpress.getSidebar,
        pagination=pagination,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        audiences=posts,
        sortby=sortby,
        how_to=getattr(how_to, 'content', ''),)
Beispiel #2
0
def profile():
    """Shows the user profile form"""

    if not authapi.is_authenticated():
        return redirect(url_for("index"))

    data = authapi.authenticated_user().metadata()
    print "DATA FOR PROFILE", data

    profile = social(ProfileForm, default=data)
    passwd = ChangePasswordForm()
    menus = fromcache("menuprincipal") or tocache(
        "menuprincipal", wordpress.exapi.getMenuItens(menu_slug="menu-principal")
    )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template(
        "profile.html",
        profile=profile,
        passwd=passwd,
        sidebar=wordpress.getSidebar,
        menu=menus,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
    )
Beispiel #3
0
def conselho():
    """Renders a wordpress page special"""
    path = 'conselho-comunicacao'
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)
    page = fromcache("page-%s" % path) or tocache(
        "page-%s" % path, wordpress.getPageByPath(path))
    cmts = fromcache("cmts-page-%s" % path) or tocache(
        "cmts-page-%s" % path,
        wordpress.getComments(
            status='approve', post_id=page.data['id'], number=1000))
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))
    return render_template(
        'post.html',
        post=page,
        sidebar=wordpress.getSidebar,
        # picday=picday,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        comments=cmts,
        show_comment_form=is_authenticated(),
        categoria_contribuicao_text=categoria_contribuicao_text,
        menu=menus)
Beispiel #4
0
def login():
    """Renders the login form"""
    if authapi.is_authenticated():
        return redirect(url_for('.profile'))
    # signup_process = g.signup_process

    if 'twitter_token' in session:
        del session['twitter_token']

    next = request.args.get('next') or request.referrer
    if next and '/auth/' in next :
        next = ""
    print 'NEXT=', request.args.get('next')
    print 'NEXT=', next
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    resp = make_response(
     render_template('login.html', next=next,
        # signup_process=signup_process,
        menu=menus,
        twitter_hash_cabecalho=twitter_hash_cabecalho
     )
    )
    resp.set_cookie('connect_type', '')
    return resp
Beispiel #5
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)
Beispiel #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)
Beispiel #7
0
def search(page=0):
    """Renders the search template"""

    query = request.values.get('s', '') or request.values.get('buscatop', '')
    #posttype = ['audiencia_govesc', 'clippinggd_clipping', 'equipegd_equipe', 'oquegd_oque', 'post']
    pagination, posts = wordpress.search(s=query, page=page, thumbsizes=['newsbox', 'widenewsbox'])
    #Retorna a ultima foto inserida neste album.
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)

    psearch = _format_postsearch(posts)
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    return render_template(
        'archive.html',
        sidebar=wordpress.getSidebar,
        # picday=picday,
        pagination=pagination,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        search_term=query,
        posts=psearch,
        menu=menus)
Beispiel #8
0
def index(page=0):
    sortby = request.values.get('sortby') or 'date'
    pagination, posts = fromcache('govescuta-posts-%s' % sortby) or \
                        tocache('govescuta-posts-%s' %sortby,
                                    wordpress.wpgove.getAudiencias(
                                            page=page,
                                            sortby=sortby,
                                            totalporpage='10'))
    how_to = fromcache('howtouse') or tocache(
        'howtouse', wordpress.getPageByPath('how-to-use-governo-escuta'))

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

    return render_template(
        'govescuta.html',
        menu=menus,
        # sidebar=wordpress.getSidebar,
        pagination=pagination,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        audiences=posts,
        sortby=sortby,
        how_to=getattr(how_to, 'content', ''),
    )
Beispiel #9
0
def search(page=0):
    """Renders the search template"""

    query = request.values.get('s', '') or request.values.get('buscatop', '')
    #posttype = ['audiencia_govesc', 'clippinggd_clipping', 'equipegd_equipe', 'oquegd_oque', 'post']
    pagination, posts = wordpress.search(s=query,
                                         page=page,
                                         thumbsizes=['newsbox', 'widenewsbox'])
    #Retorna a ultima foto inserida neste album.
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)

    psearch = _format_postsearch(posts)
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))
    return render_template(
        'archive.html',
        sidebar=wordpress.getSidebar,
        # picday=picday,
        pagination=pagination,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        search_term=query,
        posts=psearch,
        menu=menus)
Beispiel #10
0
def timelineitem(slug, itemid):
	obra = fromcache("obra-" + slug) or tocache("obra-" + slug, _get_obras(slug)[0])
	if not obra:
		return abort(404)

	cacheid = "obratl%s-%s"%(obra['id'],itemid)
	timeline = fromcache(cacheid) or tocache(cacheid, wordpress.monitoramento.getObraTimeline(obra['id'], int(itemid) ))
	timeline = adjustCf(timeline)
	update = timeline[0]

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

	return render_template('timeline-item.html',
		menu=menus,
		obra=obra,
		howto=howto,
		tos=tos,
		update=update,
		twitter_hash_cabecalho=twitter_hash_cabecalho
	)
Beispiel #11
0
def timelineitem(slug, itemid):
	obra = fromcache("obra-" + slug) or tocache("obra-" + slug, _get_obras(slug)[0])
	if not obra:
		return abort(404)

	cacheid = "obratl%s-%s"%(obra['id'],itemid)
	timeline = fromcache(cacheid) or tocache(cacheid, wordpress.monitoramento.getObraTimeline(obra['id'], int(itemid) ))
	timeline = adjustCf(timeline)
	update = timeline[0]

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

	cacheid = "cmts-item-obra-%s" % itemid
	cmts = fromcache(cacheid) or tocache(cacheid, wordpress.getComments(status='approve',post_id=itemid, number=1000))

	return render_template('timeline-item.html',
		base_url = current_app.config['BASE_URL'],
		menu=menus,
		obra=obra,
		howto=howto,
		tos=tos,
		update=update,
		comentarios=cmts[::-1],
		twitter_hash_cabecalho=twitter_hash_cabecalho
	)
Beispiel #12
0
def login():
    """Renders the login form"""
    if authapi.is_authenticated():
        return redirect(url_for(".profile"))
    # signup_process = g.signup_process

    if "twitter_token" in session:
        del session["twitter_token"]

    next = request.args.get("next") or request.referrer
    if next and "/auth/" in next:
        next = ""
    print "NEXT=", request.args.get("next")
    print "NEXT=", next
    menus = fromcache("menuprincipal") or tocache(
        "menuprincipal", wordpress.exapi.getMenuItens(menu_slug="menu-principal")
    )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    resp = make_response(
        render_template(
            "login.html",
            next=next,
            # signup_process=signup_process,
            menu=menus,
            twitter_hash_cabecalho=twitter_hash_cabecalho,
            sidebar=wordpress.getSidebar,
        )
    )
    resp.set_cookie("connect_type", "")
    return resp
Beispiel #13
0
def obra(slug):
	obra = fromcache("obra-" + slug) or tocache("obra-" + slug, _get_obras(slug)[0])
	if not obra:
		return abort(404)

	cacheid = "obratl-%s"%slug
	timeline = fromcache(cacheid) or tocache(cacheid,wordpress.monitoramento.getObraTimeline(obra['id']))
	timeline = adjustCf(timeline)
	statuses = [ s for s in timeline if s['format'] == 'status' ]

	cacheid = "page-more-"+slug
	more = fromcache(cacheid) or tocache(cacheid,wordpress.getPageByPath('more-'+slug))
	if more:
		more = more.content

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

	tos = fromcache('tosobras') or tocache('tosobras',wordpress.getPageByPath('tos-obras'))
	howto = fromcache('howtoobras') or tocache('howtoobras',wordpress.getPageByPath('howto-obras'))
	return render_template('obra.html',
		menu=menus,
		obra=obra,
		tos=tos,
		howto=howto,
		more=more,
		timeline=timeline,
		statuses=statuses,
		twitter_hash_cabecalho=twitter_hash_cabecalho
	)
Beispiel #14
0
def news(page=0):
    """List posts in chronological order"""
    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))

    pagination, posts = fromcache('pag_posts_%s' % page) or tocache(
        "pag_posts_%s" % page,
        wordpress.getPosts(page=page, thumbsizes=['newsbox', 'widenewsbox']))

    #Retorna a ultima foto inserida neste album.
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)

    psearch = _format_postsearch(posts)
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    return render_template(
        'archive.html',
        sidebar=wordpress.getSidebar,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        # picday=picday,
        pagination=pagination,
        menu=menus,
        posts=psearch)
Beispiel #15
0
def tag(slug, page=0):
    """List posts of a given tag"""
    pagination, posts = fromcache(
        "pag_posts_tag_%s_%s" % (slug, page)) or tocache(
            "pag_posts_tag_%s_%s" %
            (slug, page), wordpress.getPostsByTag(tag=slug, page=page))
    #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'))

    psearch = _format_postsearch(posts)
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    return render_template(
        'archive.html',
        sidebar=wordpress.getSidebar,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        # picday=picday,
        pagination=pagination,
        posts=psearch,
        menu=menus)
Beispiel #16
0
def login():
    """Renders the login form"""
    if authapi.is_authenticated():
        return redirect(url_for('.profile'))
    # signup_process = g.signup_process

    if 'twitter_token' in session:
        del session['twitter_token']

    next = request.args.get('next') or request.referrer
    if next and '/auth/' in next :
        next = ""
    print 'NEXT=', request.args.get('next')
    print 'NEXT=', next
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    resp = make_response(
     render_template('login.html', next=next,
        # signup_process=signup_process,
        menu=menus,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        sidebar=wordpress.getSidebar,
     )
    )
    resp.set_cookie('connect_type', '')
    return resp
Beispiel #17
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
    )
Beispiel #18
0
def artigo_hierarquico(slug):
    """Renders a wordpress page special"""
    path = slug
    post_type = 'artigo-herarquico'
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)
    post = fromcache("artigo-%s" % slug) or tocache("artigo-%s" % slug, wordpress.getCustomPostByPath(post_type,path))

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

    if not post['id']:
        return abort(404)

    total_artigos = []
    total_comentarios = []
    comentarios_separados = []
    add_filhos_and_comments_to_post(post_type, post, total_artigos, total_comentarios, comentarios_separados)

    HABILITAR_SANFONA="false"
    HABILITAR_ABAS="false"
    HABILITAR_COMENTARIO_MESTRE="false"
    HABILITAR_COMENTARIO_FILHOS="false"

    TEMPLATE = "artigo_hierarquico.html"
    for cf in post['custom_fields']:
        if cf['key'] == 'artigo_hierarquico_comentario_master' and cf['value'] == '1':
           HABILITAR_COMENTARIO_MESTRE = 'true'
        if cf['key'] == 'artigo_hierarquico_comentarios_filhos' and cf['value'] == '1':
           HABILITAR_COMENTARIO_FILHOS = 'true'
        if cf['key'] == 'artigo_hierarquico_sanfona' and cf['value'] == '1':
           HABILITAR_SANFONA = 'true'
        if cf['key'] == 'artigo_hierarquico_abas' and cf['value'] == '1':
           HABILITAR_ABAS = 'true'
           TEMPLATE = "artigo_hierarquico_aba.html"

    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )

    return render_template(
        TEMPLATE,
        post=post,
        wp=wordpress,
        total_artigos=sum(total_artigos),
        total_comentarios=sum(total_comentarios),
        todos_comentarios=comentarios_separados,
        sidebar=wordpress.getSidebar,
        HABILITAR_SANFONA=HABILITAR_SANFONA,
        HABILITAR_ABAS=HABILITAR_ABAS,
        HABILITAR_COMENTARIO_MESTRE=HABILITAR_COMENTARIO_MESTRE,
        HABILITAR_COMENTARIO_FILHOS=HABILITAR_COMENTARIO_FILHOS,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        show_comment_form=is_authenticated(),
        categoria_contribuicao_text=categoria_contribuicao_text
        ,menu=menus
    )
Beispiel #19
0
def logout():
    """Logs the user out and returns """
    if not authapi.is_authenticated():
        return redirect(url_for("index"))
    authapi.logout()
    next = request.values.get("next")
    app = request.values.get("app")
    menus = fromcache("menuprincipal") or tocache(
        "menuprincipal", wordpress.exapi.getMenuItens(menu_slug="menu-principal")
    )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    if next:
        print "NEXTT=", next
        return redirect(next)
    else:
        return render_template(
            "logout.html",
            menu=menus,
            app=app,
            twitter_hash_cabecalho=twitter_hash_cabecalho,
            voltar=request.referrer or "/",
            sidebar=wordpress.getSidebar,
        )
Beispiel #20
0
def details(vid):
    video = fromcache("video_%s" % str(vid))

    if not video:
        # print "Video do wordpress...", vid
        video = tocache("video_%s" % str(vid), treat_categories(wordpress.wpgd.getVideo(vid))[0] )

    sources = fromcache("video_src_%s" % str(vid)) or tocache("video_src_%s" % str(vid),wordpress.wpgd.getVideoSources(vid))

    base_url = current_app.config['BASE_URL']
    base_url = base_url if base_url[-1:] != '/' else base_url[:-1] #corta a barra final
    video_sources = {}
    for s in sources:
        if(s['format'].find(';') > 0):
            f = s['format'][0:s['format'].find(';')]
        else:
            f = s['format']
        video_sources[f] = s['url']
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    return render_template('video.html', video=video, sources=video_sources
        ,menu=menus
        ,twitter_hash_cabecalho=twitter_hash_cabecalho
        ,base_url=base_url, sidebar=wordpress.getSidebar,)
Beispiel #21
0
def timelineitem(slug, itemid):
    obra = fromcache("obra-" + slug) or tocache("obra-" + slug,
                                                _get_obras(slug)[0])
    if not obra:
        return abort(404)

    cacheid = "obratl%s-%s" % (obra['id'], itemid)
    timeline = fromcache(cacheid) or tocache(
        cacheid,
        wordpress.monitoramento.getObraTimeline(obra['id'], int(itemid)))
    timeline = adjustCf(timeline)
    update = timeline[0]

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

    return render_template('timeline-item.html',
                           menu=menus,
                           obra=obra,
                           howto=howto,
                           tos=tos,
                           update=update,
                           twitter_hash_cabecalho=twitter_hash_cabecalho)
Beispiel #22
0
def lost_password():
    """Renders the lost password form"""
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template('lost_password.html', menu=menus, twitter_hash_cabecalho=twitter_hash_cabecalho)
Beispiel #23
0
def lost_password():
    """Renders the lost password form"""
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template('lost_password.html', menu=menus, sidebar=wordpress.getSidebar, twitter_hash_cabecalho=twitter_hash_cabecalho)
Beispiel #24
0
def listing():

    page = int(request.args.get('page') or 1)
    page -= 1

    # page = wordpress.wpgd.getHighlightedVideos()
    hvideos = fromcache("h_videos_root") or tocache("h_videos_root",
        treat_categories(wordpress.wpgd.getHighlightedVideos()) )

    # print "========================================================"
    # print dir(request)
    # print request.url
    # print request.url_rule
    # print "========================================================"

    canalclass=""
    if 'populares' in str(request.url_rule):
        order = "views" #recents
        nome_canal = "Populares"
        canalclass="fa-star"
    else :
        order = "date"
        nome_canal = "Recentes"
        canalclass="fa fa-clock-o"

    order_by = "%s desc" % order

    videos_json = {}
    allvideos = fromcache("all_videos_root_") or \
                tocache("all_videos_root_" ,
                        treat_categories(wordpress.wpgd.getVideos(where='status=true'), orderby="date") )

    categories = fromcache("all_videos_categories") or \
        tocache("all_videos_categories",wordpress.wpgd.getVideosCategories())

    for v in allvideos:
        videos_json[v['title']] = v['id']

    # print "Buscando", current_app.config['VIDEO_PAGINACAO'], "vídeos por página!"
    cacheid = "videos_root_%s_page_%s" % (order,page)
    pagging = int(current_app.config['VIDEO_PAGINACAO'])
    offset = page * pagging
    page_total = int( round( Decimal( len(allvideos) ) / pagging ) )
    # print "PAGINACAO", len(allvideos), page, pagging, offset
    videos = fromcache(cacheid) or tocache(cacheid,
        paginate(treat_categories(wordpress.wpgd.getVideos(where='v.status=true'),orderby=order_by), pagging, offset) )

    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    return render_template('videos.html', videos=videos
        ,twitter_hash_cabecalho=twitter_hash_cabecalho
        ,menu=menus, titulos=videos_json, categories=categories, hvideos=hvideos
        ,canal=nome_canal, canalclass=canalclass, page=page+1, page_total=page_total,
        sidebar=wordpress.getSidebar,)
Beispiel #25
0
def questions():
    ctx = _get_context()
    theme = ctx['theme']
    questions = []
    sortby = request.values.get('sortby') or '?rand'
    #sortby = '?rand'

    # Looking for the authenticated user
    user_id = auth.is_authenticated() and \
        auth.authenticated_user().id or ''

    # Discovering the theme id
    theme_id = theme and \
         theme['id'] or ''

    # Finally, listing the questions that are able to receive votes.
    pagination = {}

    pagination['page'] = int(request.values.get('page', 0))

    print "=================> wordpress.govr.getVotingContribs INI"
    questions_raw, count = wordpress.govr.getVotingContribs(
        theme_id,               # theme id
        user_id,                # user id
        pagination['page'],     # page number
        sortby,                 # sortby
        '',                     # to
        '',                     # from
        CONTRIBS_PER_PAGE,      # perpage
    )
    print "=================> wordpress.govr.getVotingContribs FIM"
    # Pagination stuff
    count = int(count)
    pagination['pages'] = int(ceil(float(count) / CONTRIBS_PER_PAGE))
    pagination['count'] = count

    # Small fix for the date value in the question content
    for i in questions_raw:
        question = _format_contrib(i)
        questions.append(question)

    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    ctx.update({
        'menu':wordpress.exapi.getMenuItens(menu_slug='menu-principal'),
        'twitter_hash_cabecalho':twitter_hash_cabecalho,
        'questions': questions,
        'pagination': pagination,
        'sortby': sortby,
        'statusedicao': statusedicao
    })

    return render_template('govresponde_questions.html', **ctx)
Beispiel #26
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
Beispiel #27
0
def index():
    # app.logger.error( " ######################################################################## BASE " )
    """Renders the index template"""
    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))
    try:
        vote_url = app.config['VOTACAO_URL']
    except KeyError:
        vote_url = ""
    try:
        vote_root = app.config['VOTACAO_ROOT']
    except KeyError:
        vote_root = ""
    try:
        vote_altura = app.config['VOTACAO_ALTURA']
    except KeyError:
        vote_altura = ""

    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    # pagepri = fromcache('pagepri')      or tocache('pagepri', wordpress.getPageByPath('prioridades'))
    pagepq = fromcache('pagepq') or tocache('pagepq',
                                            wordpress.getPageByPath('por-que'))
    # pageproc = fromcache('pageproc')    or tocache('pageproc', wordpress.getPageByPath('processo'))
    pagevot = fromcache('pagevot') or tocache(
        'pagevot', wordpress.getPageByPath('votacao'))
    pagehow = fromcache('pagehow') or tocache(
        'pagehow', wordpress.getPageByPath('como-funciona'))
    pageseg = fromcache('pageseg') or tocache(
        'pageseg', wordpress.getPageByPath('seguranca-2'))
    # pagesobre = fromcache('pagesobre')  or tocache('pagesobre', wordpress.getPageByPath('sobre'))

    return render_template(
        'index.html',
        wp=wordpress,
        sidebar=wordpress.getSidebar,
        # page_about=pagesobre,
        # page_pri=pagepri,
        page_pq=pagepq,
        pagevot=pagevot,
        # page_pro=pageproc,
        page_como=pagehow,
        page_seg=pageseg,
        menu=menus,
        reforma_voted=request.cookies.get('reforma_voted') or False,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        VOTACAO_URL=vote_url,
        VOTACAO_ROOT=vote_root,
        VOTACAO_ALTURA=vote_altura,
    )
Beispiel #28
0
def gallery():
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template(
        'gallerys.html',
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        menu=menus,
    )
Beispiel #29
0
def resultados_gd():
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template(
        'resultados-capa.html', wp=wordpress,
        menu=menus,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        sidebar=wordpress.getSidebar
    )
Beispiel #30
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
Beispiel #31
0
def gallery():
    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template(
        'gallerys.html',
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        menu=menus,
    )
Beispiel #32
0
def resultados_gd():
    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template('resultados-capa.html',
                           wp=wordpress,
                           menu=menus,
                           twitter_hash_cabecalho=twitter_hash_cabecalho,
                           sidebar=wordpress.getSidebar)
Beispiel #33
0
def sobre_gd():
    pagesobre = fromcache('pagesobre')  or tocache('pagesobre', wordpress.getPageByPath('sobre'))
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template(
        'sobre.html', wp=wordpress,
        menu=menus,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        sidebar=wordpress.getSidebar,
        page_about=pagesobre
    )
Beispiel #34
0
def comite_transito():
    """Renders a wordpress page special"""
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    return render_template(
        'comite-transito.html',
        menu=menus,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        wp=wordpress,
        sidebar=wordpress.getSidebar,
    )
Beispiel #35
0
def sobre_gd():
    pagesobre = fromcache('pagesobre') or tocache(
        'pagesobre', wordpress.getPageByPath('sobre'))
    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template('sobre.html',
                           wp=wordpress,
                           menu=menus,
                           twitter_hash_cabecalho=twitter_hash_cabecalho,
                           sidebar=wordpress.getSidebar,
                           page_about=pagesobre)
Beispiel #36
0
def index():
    # app.logger.error( " ######################################################################## BASE " )
    """Renders the index template"""
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        vote_url = app.config['VOTACAO_URL']
    except KeyError:
        vote_url = ""
    try:
        vote_root = app.config['VOTACAO_ROOT']
    except KeyError:
        vote_root = ""
    try:
        vote_altura = app.config['VOTACAO_ALTURA']
    except KeyError:
        vote_altura = ""

    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    # pagepri = fromcache('pagepri')      or tocache('pagepri', wordpress.getPageByPath('prioridades'))
    pagepq = fromcache('pagepq')        or tocache('pagepq', wordpress.getPageByPath('por-que'))
    # pageproc = fromcache('pageproc')    or tocache('pageproc', wordpress.getPageByPath('processo'))
    pagevot = fromcache('pagevot')    or tocache('pagevot', wordpress.getPageByPath('votacao'))
    pagehow = fromcache('pagehow')      or tocache('pagehow', wordpress.getPageByPath('como-funciona'))
    pageseg = fromcache('pageseg')      or tocache('pageseg', wordpress.getPageByPath('seguranca-2'))
    # pagesobre = fromcache('pagesobre')  or tocache('pagesobre', wordpress.getPageByPath('sobre'))

    return render_template(
        'index.html', wp=wordpress,
        sidebar=wordpress.getSidebar,
        # page_about=pagesobre,
        # page_pri=pagepri,
        page_pq=pagepq,
        pagevot=pagevot,
        # page_pro=pageproc,
        page_como=pagehow,
        page_seg=pageseg,
        menu=menus,
        reforma_voted=request.cookies.get('reforma_voted') or False,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        VOTACAO_URL=vote_url,
        VOTACAO_ROOT=vote_root,
        VOTACAO_ALTURA=vote_altura,
    )
Beispiel #37
0
def index(slug=None):
    search_terms = ''
    if 's' in request.args and request.args.get('s', ''):
        search_terms = request.args.get('s', '')
        galleries = wordpress.wpgd.searchGalleries('%s' % search_terms)
        if len(galleries) == 1:
            return redirect(url_for('.galerias', slug=galleries[0]['slug']))
    else:
        galleries = wordpress.wpgd.getGalleries()
        if not galleries:
            abort(404)
    current = None

    titulos = [(g['slug'], g['title']) for g in galleries]

    galerias_destacadas = []
    try:
        if current_app.config['GALERIAS_DESTACADAS_ID']:
            ids = [
                int(id) for id in
                current_app.config['GALERIAS_DESTACADAS_ID'].split(',')
            ]
            galerias_destacadas = [
                gal for gal in galleries if int(gal['gid']) in ids
            ]
            galleries = [
                gal for gal in galleries if int(gal['gid']) not in ids
            ]
            #ordenada = <- Gerar a lista da galeria destacada ordenada pelo que está configurada.
    except KeyError:
        pass

    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    return render_template(
        'gallerys.html',
        galleries=galleries,
        galerias_especiais=galerias_destacadas,
        s=search_terms,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        menu=wordpress.exapi.getMenuItens(menu_slug='menu-principal'),
        titulos=titulos,
        sidebar=wordpress.getSidebar)
Beispiel #38
0
def logon():
    """Logs the user in and returns the user object in
    JSON format"""
    username = request.values.get("username")
    password = request.values.get("password")
    gonext = True
    if username and password:
        try:
            user = authapi.login(username, password)
        except authapi.UserNotFound:
            flash(_(u"Wrong user or password"), "alert-error")
            gonext = False
        except authapi.UserAndPasswordMissmatch:
            flash(_(u"Wrong user or password"), "alert-error")
            gonext = False
        # else:
        # msg.ok({ 'user': user })
        # flash(_(u'Login successfuly!'), 'alert-success')
    else:
        flash(_(u"Username or password missing"), "alert-error")
        gonext = False
    formcad = social(SignupForm)

    next = request.values.get("next", default="")
    if next is not None and gonext:
        return redirect(next)
    else:
        menus = fromcache("menuprincipal") or tocache(
            "menuprincipal", wordpress.exapi.getMenuItens(menu_slug="menu-principal")
        )
        try:
            twitter_hash_cabecalho = utils.twitts()
        except KeyError:
            twitter_hash_cabecalho = ""
        # if request.referrer:
        #     return redirect(request.referrer)
        # else:
        #     return render_template('login.html', form=formcad, next=next)
        return render_template(
            "login.html",
            form=formcad,
            next=next,
            sidebar=wordpress.getSidebar,
            menu=menus,
            twitter_hash_cabecalho=twitter_hash_cabecalho,
        )
Beispiel #39
0
def pages(path):
    """Renders a wordpress page"""
    #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') )
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template(
        'page.html',
        page=wordpress.getPageByPath(path),
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        sidebar=wordpress.getSidebar,
        # picday=picday
        menu=menus
    )
Beispiel #40
0
def galerias(slug=None):
    galleries = wordpress.wpgd.getGalleries()
    if slug and (str(slug) not in [i['slug'] for i in galleries]):
        abort(404)
    current = wordpress.wpgd.getGallery(slug or galleries[0]['slug'])
    titulos = [ (g['slug'],g['title']) for g in galleries ]
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    return render_template(
        'gallery.html',
        current=current,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        menu=wordpress.exapi.getMenuItens(menu_slug='menu-principal'),
        titulos=titulos,
    )
Beispiel #41
0
def galerias(slug=None):
    galleries = wordpress.wpgd.getGalleries()
    if slug and (str(slug) not in [i['slug'] for i in galleries]):
        abort(404)
    current = wordpress.wpgd.getGallery(slug or galleries[0]['slug'])
    titulos = [(g['slug'], g['title']) for g in galleries]
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    return render_template(
        'gallery.html',
        current=current,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        menu=wordpress.exapi.getMenuItens(menu_slug='menu-principal'),
        titulos=titulos,
        sidebar=wordpress.getSidebar)
Beispiel #42
0
def profile():
    """Shows the user profile form"""

    if not authapi.is_authenticated():
        return redirect(url_for('index'))

    data = authapi.authenticated_user().metadata()
    print "DATA FOR PROFILE", data

    profile = social(ProfileForm, default=data)
    passwd = ChangePasswordForm()
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template(
        'profile.html', profile=profile, passwd=passwd, sidebar=wordpress.getSidebar, menu=menus, twitter_hash_cabecalho=twitter_hash_cabecalho)
Beispiel #43
0
def pages(path):
    """Renders a wordpress page"""
    #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'))
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template(
        'page.html',
        page=wordpress.getPageByPath(path),
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        sidebar=wordpress.getSidebar,
        # picday=picday
        menu=menus)
Beispiel #44
0
def archive(m, page=0):
    """List posts of the archive given yyyymm format"""
    pagination, posts = fromcache("archive-%s-%s" % (str(m), str(page)) ) or tocache("archive-%s-%s" % (str(m), str(page))
        ,wordpress.getArchivePosts(m=m, page=page))
    #Retorna a ultima foto inserida neste album.
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)

    psearch = _format_postsearch(posts)
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template(
        'archive.html',
        sidebar=wordpress.getSidebar,
        # picday=picday,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        pagination=pagination,
        posts=psearch)
Beispiel #45
0
def listing():
    videos_json = {}
    allvideos = fromcache("all_videos_root") or tocache("all_videos_root",wordpress.wpgd.getVideos(
        where='status=true', orderby='title'))

    for v in allvideos:
        videos_json[v['title']] = v['id']

    print "Buscando", current_app.config['VIDEO_PAGINACAO'], "vídeos por página!"
    videos = fromcache("videos_root") or tocache("videos_root",wordpress.wpgd.getVideos(
        where='status=true', orderby='date DESC', limit=current_app.config['VIDEO_PAGINACAO']))
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    return render_template('videos.html', videos=videos
        ,twitter_hash_cabecalho=twitter_hash_cabecalho
        ,menu=menus, titulos=videos_json)
Beispiel #46
0
def logout():
    """Logs the user out and returns """
    if not authapi.is_authenticated():
        return redirect(url_for('index'))
    authapi.logout()
    next = request.values.get('next')
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    if next:
        print "NEXTT=", next
        return redirect(next)
    else:
        return render_template('logout.html',
            menu=menus,
            twitter_hash_cabecalho=twitter_hash_cabecalho,
            voltar=request.referrer or "/"
            )
Beispiel #47
0
def tag(slug, page=0):
    """List posts of a given tag"""
    pagination, posts = fromcache("pag_posts_tag_%s_%s" % (slug,page)) or tocache("pag_posts_tag_%s_%s" % (slug,page), wordpress.getPostsByTag(tag=slug, page=page) )
    #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') )

    psearch = _format_postsearch(posts)
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    return render_template(
        'archive.html',
        sidebar=wordpress.getSidebar,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        # picday=picday,
        pagination=pagination,
        posts=psearch
        ,menu=menus)
Beispiel #48
0
def archive(m, page=0):
    """List posts of the archive given yyyymm format"""
    pagination, posts = fromcache(
        "archive-%s-%s" % (str(m), str(page))) or tocache(
            "archive-%s-%s" %
            (str(m), str(page)), wordpress.getArchivePosts(m=m, page=page))
    #Retorna a ultima foto inserida neste album.
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)

    psearch = _format_postsearch(posts)
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    return render_template(
        'archive.html',
        sidebar=wordpress.getSidebar,
        # picday=picday,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        pagination=pagination,
        posts=psearch)
Beispiel #49
0
def conselho():
    """Renders a wordpress page special"""
    path = 'conselho-comunicacao'
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)
    page = fromcache("page-%s" %path) or tocache("page-%s" %path,  wordpress.getPageByPath(path) )
    cmts = fromcache("cmts-page-%s" %path) or tocache("cmts-page-%s" %path, wordpress.getComments(status='approve',post_id=page.data['id'], number=1000))
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    return render_template(
        'post.html',
        post=page,
        sidebar=wordpress.getSidebar,
        # picday=picday,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        comments=cmts,
        show_comment_form=is_authenticated(),
        categoria_contribuicao_text=categoria_contribuicao_text
        ,menu=menus
    )
Beispiel #50
0
def obra(slug):
    obra = fromcache("obra-" + slug) or tocache("obra-" + slug,
                                                _get_obras(slug)[0])
    if not obra:
        return abort(404)

    cacheid = "obratl-%s" % slug
    timeline = fromcache(cacheid) or tocache(
        cacheid, wordpress.monitoramento.getObraTimeline(obra['id']))
    timeline = adjustCf(timeline)
    statuses = [s for s in timeline if s['format'] == 'status']

    cacheid = "page-more-" + slug
    more = fromcache(cacheid) or tocache(
        cacheid, wordpress.getPageByPath('more-' + slug))
    if more:
        more = more.content

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

    tos = fromcache('tosobras') or tocache(
        'tosobras', wordpress.getPageByPath('tos-obras'))
    howto = fromcache('howtoobras') or tocache(
        'howtoobras', wordpress.getPageByPath('howto-obras'))
    return render_template('obra.html',
                           menu=menus,
                           obra=obra,
                           tos=tos,
                           howto=howto,
                           more=more,
                           timeline=timeline,
                           statuses=statuses,
                           twitter_hash_cabecalho=twitter_hash_cabecalho)
Beispiel #51
0
def details(vid):
    video = fromcache("video_%s" % str(vid))

    if not video:
        # print "Video do wordpress...", vid
        video = tocache("video_%s" % str(vid),
                        treat_categories(wordpress.wpgd.getVideo(vid))[0])

    sources = fromcache("video_src_%s" % str(vid)) or tocache(
        "video_src_%s" % str(vid), wordpress.wpgd.getVideoSources(vid))

    base_url = current_app.config['BASE_URL']
    base_url = base_url if base_url[
        -1:] != '/' else base_url[:-1]  #corta a barra final
    video_sources = {}
    for s in sources:
        if (s['format'].find(';') > 0):
            f = s['format'][0:s['format'].find(';')]
        else:
            f = s['format']
        video_sources[f] = s['url']
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))
    return render_template(
        'video.html',
        video=video,
        sources=video_sources,
        menu=menus,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        base_url=base_url,
        sidebar=wordpress.getSidebar,
    )
Beispiel #52
0
def logon():
    """Logs the user in and returns the user object in
    JSON format"""
    username = request.values.get('username')
    password = request.values.get('password')
    gonext = True
    if username and password:
        try:
            user = authapi.login(username, password)
        except authapi.UserNotFound:
            flash(_(u'Wrong user or password'), 'alert-error')
            gonext = False
        except authapi.UserAndPasswordMissmatch:
            flash(_(u'Wrong user or password'), 'alert-error')
            gonext = False
        # else:
            # msg.ok({ 'user': user })
            # flash(_(u'Login successfuly!'), 'alert-success')
    else:
        flash(_(u'Username or password missing'), 'alert-error')
        gonext = False
    formcad = social(SignupForm)

    next = request.values.get('next',default="")
    if next is not None and gonext:
        return redirect(next)
    else:
        menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
        try:
            twitter_hash_cabecalho = utils.twitts()
        except KeyError:
            twitter_hash_cabecalho = ""
        # if request.referrer:
        #     return redirect(request.referrer)
        # else:
        #     return render_template('login.html', form=formcad, next=next)
        return render_template('login.html', form=formcad, next=next, sidebar=wordpress.getSidebar, menu=menus, twitter_hash_cabecalho=twitter_hash_cabecalho)
Beispiel #53
0
def logout():
    """Logs the user out and returns """
    if not authapi.is_authenticated():
        return redirect(url_for('index'))
    authapi.logout()
    next = request.values.get('next')
    app = request.values.get('app')
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    if next:
        print "NEXTT=", next
        return redirect(next)
    else:
        return render_template('logout.html',
            menu=menus,
            app=app,
            twitter_hash_cabecalho=twitter_hash_cabecalho,
            voltar=request.referrer or "/",
            sidebar=wordpress.getSidebar,
            )
Beispiel #54
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)
Beispiel #55
0
def signup():
    """Renders the signup form"""

    if authapi.is_authenticated():
        return redirect(url_for('.profile'))

    # default_data=None
    ret_code = -1
    form = social(SignupForm)
    print "CADASTRANDO"
    #form = SignupForm()
    fromsocial = request.cookies.get('connect_type') in ('social_f','social_t')
    form.social = fromsocial

    print "VALIDANDO"
    if request.method == 'POST' and form.validate_on_submit():
        print "VALIDADO!"
        try:
            meta = form.meta
            dget = meta.pop
            if fromsocial:
                print "\nsenha fromsocial"
                password = ""
            else:
                password = dget('password')
                print "\nsenha", password

            # Finally, it's time to create the user
            email = dget('email')

            username = email
            if request.cookies.get('connect_type') == 'social_t':
                username = session['tmp_twitter_id']
            # if request.cookies.get('connect_type') == 'social_f':
            #     username = dget('fbid')
            #     print "FACEBOOK ID =", username

            user = authapi.create_user(
                dget('name'), username, password,
                email, form.meta,
                dget('receive_sms'), dget('receive_email') )

            if fromsocial:
                if request.cookies.get('connect_type') == 'social_t':
                    user.set_meta('twitter', session['tmp_twitter_id'])
                    user.set_meta('twitteruser', True)
                    dbsession.commit()
                if request.cookies.get('connect_type') == 'social_f':
                    user.set_meta('facebookuser', True)
                    dbsession.commit()

            utils.send_welcome_email(user)

            flash(_(u'Your user was registered with successful!'), 'alert-success')
            ret_code = 0
        except authapi.UserExists:
            flash( _(u'User already exists'), 'alert-error')
            ret_code = 1
        except authapi.UserExistsUnconfirmed:
            flash( _(u'User already exists, but need confirmation'), 'alert-error')
            ret_code = 4
        except authapi.EmailAddressExists:
            flash(_(u'The email address informed is being used by another person'), 'alert-error')
            ret_code = 2
    else:
        if request.method == 'POST' :
            print form.errors
            # for errorMessages, fieldName in enumerate(form.errors):
            #     print errorMessages, fieldName
            #     for err in errorMessages:
            #         # do something with your errorMessages for fieldName
            #         flash( "%s - %s" % (fieldName,err),'alert-error')
            flash(_(u'Correct the validation errors and resend'),'alert-error')
            ret_code = 3

    tos = fromcache('tossigin') or tocache('tossigin',wordpress.getPageByPath('tos'))
    rm = fromcache('moresigin') or tocache('moresigin',wordpress.getPageByPath('signup-read-more'))
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    return render_template(
        'signup.html', form=form,
        readmore=rm,tos=tos, menu=menus,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        sidebar=wordpress.getSidebar,
        ret_code=ret_code
    )
Beispiel #56
0
def signup_continuation():
    '''Show the second part of registration'''
    print "/signup/continuation/ ==========================="
    user = None
    username = None
    if authapi.is_authenticated() and not 'byconfirm' in session:
        print "esta logado, indo pro profile ==========================="
        return redirect(url_for('.profile'))

    elif 'byconfirm' in session:
        print "byconfirm in session =========================== ", session['byconfirm']
        user = User.query.filter_by(username=session['byconfirm']).one()
        # if user.get_meta('twitteruser'):
        #     username = user.get_meta('twitter')
        # else:
        #     username = user.username
        username = user.username
        del session['byconfirm']

    elif request.method == 'POST':
        print "vindo do post ===========================", request.form['email'], request.form['username']
        if request.form['username']:
            user = User.query.filter_by(username=request.form['username']).one()
        else:
            user = User.query.filter_by(username=request.form['email']).one()
        username = user.username

    if user:
        print "tem user ============================", user
        data = user.metadata()
        data['social'] = ('facebookuser' in data and data['facebookuser']) or \
                         ('twitteruser' in data and data['twitteruser'])
        print "DATA DEFAULT", data
        form = social(SignupForm, default=data)
    else:
        print "NAO tem user ============================"
        return redirect(url_for('auth.login'))
        form = social(SignupForm)

    if 'password_confirmation' in form:
        #Remove not needed field
        del form.password_confirmation
    if request.method == 'POST' and form.validate_on_submit():
        # user = authapi.authenticated_user()
        print "form validado ============================"

        meta = form.meta
        dget = meta.pop

        password = dget('password')
        fromsocial = form.social or \
                     ('facebookuser' in data and data['facebookuser']) or \
                     ('twitteruser' in data and data['twitteruser'])
        try:
            print "FROMSOCIAL", fromsocial
            authapi.login(user.username, password, fromsocial)
        except authapi.UserNotFound:
            flash(_(u'Wrong user or password'), 'alert-error')
        except authapi.UserAndPasswordMissmatch:
            flash(_(u'Wrong password'), 'alert-error')
        else:
            user = authapi.authenticated_user()
            # First, the specific ones
            # user.name = mget('name')
            # user.email = mget('email')

            # And then, the meta ones, stored in `UserMeta'
            for key, val in form.meta.items():
                user.set_meta(key, val)

            flash(_(u'Your registration is complete'), 'alert-success')
            return redirect(url_for('auth.profile'))
    else:
        print "ERRO NO FORM VALIDATION", form.errors

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

    return render_template(
        'signup_second.html', form=form,
        menu=menus,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        sidebar=wordpress.getSidebar,
        username=username
    )
Beispiel #57
0
def listing():

    page = int(request.args.get('page') or 1)
    page -= 1

    # page = wordpress.wpgd.getHighlightedVideos()
    hvideos = fromcache("h_videos_root") or tocache(
        "h_videos_root", treat_categories(
            wordpress.wpgd.getHighlightedVideos()))

    # print "========================================================"
    # print dir(request)
    # print request.url
    # print request.url_rule
    # print "========================================================"

    canalclass = ""
    if 'populares' in str(request.url_rule):
        order = "views"  #recents
        nome_canal = "Populares"
        canalclass = "fa-star"
    else:
        order = "date"
        nome_canal = "Recentes"
        canalclass = "fa fa-clock-o"

    order_by = "%s desc" % order

    videos_json = {}
    allvideos = fromcache("all_videos_root_") or \
                tocache("all_videos_root_" ,
                        treat_categories(wordpress.wpgd.getVideos(where='status=true'), orderby="date") )

    categories = fromcache("all_videos_categories") or \
        tocache("all_videos_categories",wordpress.wpgd.getVideosCategories())

    for v in allvideos:
        videos_json[v['title']] = v['id']

    # print "Buscando", current_app.config['VIDEO_PAGINACAO'], "vídeos por página!"
    cacheid = "videos_root_%s_page_%s" % (order, page)
    pagging = int(current_app.config['VIDEO_PAGINACAO'])
    offset = page * pagging
    page_total = int(round(Decimal(len(allvideos)) / pagging))
    # print "PAGINACAO", len(allvideos), page, pagging, offset
    videos = fromcache(cacheid) or tocache(
        cacheid,
        paginate(
            treat_categories(wordpress.wpgd.getVideos(where='v.status=true'),
                             orderby=order_by), pagging, offset))

    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))
    return render_template(
        'videos.html',
        videos=videos,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        menu=menus,
        titulos=videos_json,
        categories=categories,
        hvideos=hvideos,
        canal=nome_canal,
        canalclass=canalclass,
        page=page + 1,
        page_total=page_total,
        sidebar=wordpress.getSidebar,
    )
Beispiel #58
0
def artigo_hierarquico(slug):
    """Renders a wordpress page special"""
    path = slug
    post_type = 'artigo-herarquico'
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)
    post = fromcache("artigo-%s" % slug) or tocache(
        "artigo-%s" % slug, wordpress.getCustomPostByPath(post_type, path))

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

    if not post['id']:
        return abort(404)

    total_artigos = []
    total_comentarios = []
    comentarios_separados = []
    add_filhos_and_comments_to_post(post_type, post, total_artigos,
                                    total_comentarios, comentarios_separados)

    HABILITAR_SANFONA = "false"
    HABILITAR_ABAS = "false"
    HABILITAR_COMENTARIO_MESTRE = "false"
    HABILITAR_COMENTARIO_FILHOS = "false"

    TEMPLATE = "artigo_hierarquico.html"
    for cf in post['custom_fields']:
        if cf['key'] == 'artigo_hierarquico_comentario_master' and cf[
                'value'] == '1':
            HABILITAR_COMENTARIO_MESTRE = 'true'
        if cf['key'] == 'artigo_hierarquico_comentarios_filhos' and cf[
                'value'] == '1':
            HABILITAR_COMENTARIO_FILHOS = 'true'
        if cf['key'] == 'artigo_hierarquico_sanfona' and cf['value'] == '1':
            HABILITAR_SANFONA = 'true'
        if cf['key'] == 'artigo_hierarquico_abas' and cf['value'] == '1':
            HABILITAR_ABAS = 'true'
            TEMPLATE = "artigo_hierarquico_aba.html"

    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))

    return render_template(
        TEMPLATE,
        post=post,
        wp=wordpress,
        total_artigos=sum(total_artigos),
        total_comentarios=sum(total_comentarios),
        todos_comentarios=comentarios_separados,
        sidebar=wordpress.getSidebar,
        HABILITAR_SANFONA=HABILITAR_SANFONA,
        HABILITAR_ABAS=HABILITAR_ABAS,
        HABILITAR_COMENTARIO_MESTRE=HABILITAR_COMENTARIO_MESTRE,
        HABILITAR_COMENTARIO_FILHOS=HABILITAR_COMENTARIO_FILHOS,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        show_comment_form=is_authenticated(),
        categoria_contribuicao_text=categoria_contribuicao_text,
        menu=menus)
Beispiel #59
0
def cobertura():
    nome = request.cookies.get('cobertura_nome') or ""
    email = request.cookies.get('cobertura_email') or ""
    twitter_tag = conf.SEMINARIO_TWITTER_TAG
    cid = conf.SEMINARIO_CATEGORIA_ID
    pagination, posts = fromcache("seminario_posts") or tocache(
        "seminario_posts", wordpress.getPostsByCategory(cat=cid))

    twites = []
    try:
        twites = fromcache("seminario_twitts") or tocache(
            "seminario_twitts", twitts(hashtag=twitter_tag, count=5))
    except Exception as e:
        print "ERRO AO BUSCAR OS TWITTS"
        print e

    # photos = fromcache('seminario_flickr') or tocache('seminario_flickr',get_flickr_photos())
    instaphotos = fromcache('seminario_insta') or tocache(
        'seminario_insta', get_instagram_photos())
    links = LinkColaborativo.query.order_by(LinkColaborativo.id.desc())

    y = re.compile("http[s]*:.*youtube.com/watch.*")
    f = re.compile("http[s]*:.*flickr.com/.*")

    # pdb.set_trace()
    totallist = []
    for link in links:
        link.objeto = "link"
        if y.match(link.link):
            link.tipo = 'youtube'
        elif f.match(link.link):
            link.tipo = 'flickr'
        else:
            link.tipo = 'normal'
        totallist.append(link)
    # pdb.set_trace()
    for photo in instaphotos:
        photo['objeto'] = "instagram"
        #             item_id, objeto, url, user_id, datetime
        t = Historico(photo['link'], "instagram", photo['link'], "",
                      photo['datetime'], "", scoped_dbsesion)
        t.setDaemon(True)
        t.start()
        totallist.append(photo)
    # pdb.set_trace()
    for tw in twites:
        tw['objeto'] = "twitter"
        tw['datetime'] = tw['created_at']
        l = "http://twitter.com/%s/status/%s" % (tw['user']['screen_name'],
                                                 tw['id'])
        t = Historico(tw['id'], "twitter", l, tw['user']['screen_name'],
                      tw['datetime'], tw['text'], scoped_dbsesion)
        t.setDaemon(True)
        t.start()
        totallist.append(tw)
    # pdb.set_trace()
    for post in posts:
        post.objeto = "post"
        post.datetime = post.the_date
        totallist.append(post)

    # print posts
    totallist = sorted(totallist,
                       key=lambda i: i['datetime']
                       if type(i) is dict else i.datetime,
                       reverse=True)

    return render_template('cobertura.html',
                           posts=posts,
                           twitts=twites,
                           instaphotos=instaphotos,
                           nome=nome,
                           email=email,
                           links=links,
                           totallist=totallist,
                           ismoderador=ismod())