def category(cid, page=0): """List posts of a given category""" menus = fromcache('menuprincipal') or tocache( 'menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal')) pagination, posts = fromcache("pag_posts_cat") or tocache( "pag_posts_cat", wordpress.getPostsByCategory(cat=cid, 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, twitter_hash_cabecalho=twitter_hash_cabecalho, # picday=picday, pagination=pagination, posts=psearch, menu=menus)
def category(cid, page=0): """List posts of a given category""" menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') ) pagination, posts = fromcache("pag_posts_cat") or tocache("pag_posts_cat", wordpress.getPostsByCategory(cat=cid, 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, twitter_hash_cabecalho=twitter_hash_cabecalho, # picday=picday, pagination=pagination, posts=psearch, menu=menus )
def govescuta_details(aid): """Renders an audience with its public template""" pagination, inst = fromcache('audiencia-escuta-%s' %str(aid)) or \ tocache('audiencia-escuta-%s' %str(aid),wordpress.wpgove.getAudiencias(postID=aid)) how_to = fromcache('how-to-use-governo-escuta') or tocache( 'how-to-use-governo-escuta', 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 = "" category = None tag = None for cat in inst: category = cat['category'] try: tag = cat['category_slug'] except: tag = "" if category: pagination, posts = fromcache('audiencia-category-%s' % category) or \ tocache('audiencia-category-%s' % category,wordpress.getPostsByCategory( cat=category)) else: pagination, posts = None, [] try: if tag: photos = get_instagram_photos(tag) else: photos = None except: photos = None buzzes = AudiencePosts.query.get(aid).get_moderated_buzz() buzzesSelec = AudiencePosts.query.get(aid).get_last_published_notice() govescuta = True video_sources = {} audience = inst[0] if audience['video_sources']: for s in audience['video_sources']: if (s['format'].find(';') > 0): f = s['format'][0:s['format'].find(';')] else: f = s['format'] video_sources[f] = s['url'] return render_template( 'audience.html', #this template is from gd/audience # 'govescuta_edicaoanter.html', sources=video_sources, audiences=inst, referrals=posts, pagination=pagination, buzzes=buzzes, buzzesSelec=buzzesSelec, menu=menus, tag=tag, twitter_hash_cabecalho=twitter_hash_cabecalho, govescuta=govescuta, photos=photos, how_to=getattr(how_to, 'content', ''), )
def index(): """Returns the last published audience page""" try: # current_app.logger.debug( "================================================ AUDIENCE" ) # current_app.logger.debug( request.args ) # current_app.logger.debug( 'facebook' in request.args ) pagination, inst = fromcache("audiencia_ativa") or tocache( "audiencia_ativa", wordpress.wpgove.getAudiencias(ativa='s', perpage=1)) how_to = fromcache("how_to_audience") or tocache( "how_to_audience", wordpress.getPageByPath('how-to-use-governo-escuta')) menus = fromcache('menuprincipal') or tocache( 'menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal')) if pagination == '0': pagination, inst = fromcache("audiencias") or tocache( "audiencias", wordpress.wpgove.getAudiencias(perpage=1)) for postid in inst: aid = postid['ID'] return redirect(url_for('govescuta.govescuta_details', aid=aid)) for postid in inst: aid = postid['ID'] buzzes = AudiencePosts.query.get(aid).get_moderated_buzz() buzzesSelec = AudiencePosts.query.get(aid).get_last_published_notice() govescuta = False category = None for cat in inst: category = cat['category'] if category: pagination, posts = wordpress.getPostsByCategory(cat=category) else: pagination, posts = None, [] try: facebook_comment_url = current_app.config['FACEBOOK_COMMENT_URL'] except: facebook_comment_url = "" try: facebook_app_id = current_app.config['FACEBOOK_APP_ID'] except: facebook_app_id = "" try: facebook_comment_moderators = current_app.config[ 'FACEBOOK_COMMENT_MODERATORS'] except: facebook_comment_moderators = "" return render_template( 'audience.html', audiences=inst, pagination=pagination, referrals=posts, buzzes=buzzes, govescuta=govescuta, menu=menus, facebook='facebook' in request.args, FACEBOOK_COMMENT_URL=facebook_comment_url, FACEBOOK_APP_ID=facebook_app_id, FACEBOOK_COMMENT_MODERATORS=facebook_comment_moderators, buzzesSelec=buzzesSelec, how_to=getattr(how_to, 'content', ''), #notice=inst.get_last_published_notice(), ) except (AttributeError, NoResultFound): abort(404)
def govescuta_details(aid): """Renders an audience with its public template""" pagination, inst = fromcache('audiencia-escuta-%s' %str(aid)) or \ tocache('audiencia-escuta-%s' %str(aid),wordpress.wpgove.getAudiencias(postID=aid)) how_to = fromcache('how-to-use-governo-escuta') or tocache('how-to-use-governo-escuta', 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 = "" category = None tag = None for cat in inst: category = cat['category'] try: tag = cat['category_slug'] except: tag = "" if category: pagination, posts = fromcache('audiencia-category-%s' % category) or \ tocache('audiencia-category-%s' % category,wordpress.getPostsByCategory( cat=category)) else: pagination, posts = None, [] try: if tag: photos = get_instagram_photos(tag) else: photos = None except: photos = None buzzes = AudiencePosts.query.get(aid).get_moderated_buzz() buzzesSelec = AudiencePosts.query.get(aid).get_last_published_notice() govescuta = True video_sources = {} audience = inst[0] if audience['video_sources']: for s in audience['video_sources']: if(s['format'].find(';') > 0): f = s['format'][0:s['format'].find(';')] else: f = s['format'] video_sources[f] = s['url'] return render_template( 'audience.html', #this template is from gd/audience # 'govescuta_edicaoanter.html', sources=video_sources, audiences=inst, referrals=posts, pagination=pagination, buzzes = buzzes, buzzesSelec = buzzesSelec, menu=menus, tag=tag, twitter_hash_cabecalho=twitter_hash_cabecalho, govescuta=govescuta, photos=photos, how_to=getattr(how_to, 'content', ''), )
def index(): """Returns the last published audience page""" try: # current_app.logger.debug( "================================================ AUDIENCE" ) # current_app.logger.debug( request.args ) # current_app.logger.debug( 'facebook' in request.args ) pagination, inst = fromcache("audiencia_ativa") or tocache("audiencia_ativa", wordpress.wpgove.getAudiencias(ativa='s',perpage=1)) how_to = fromcache("how_to_audience") or tocache("how_to_audience", wordpress.getPageByPath('how-to-use-governo-escuta')) menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') ) if pagination == '0': pagination, inst = fromcache("audiencias") or tocache("audiencias", wordpress.wpgove.getAudiencias(perpage=1)) for postid in inst: aid = postid['ID'] return redirect(url_for('govescuta.govescuta_details', aid=aid)) for postid in inst: aid = postid['ID'] buzzes = AudiencePosts.query.get(aid).get_moderated_buzz() buzzesSelec = AudiencePosts.query.get(aid).get_last_published_notice() govescuta = False category = None for cat in inst: category = cat['category'] if category: pagination, posts = wordpress.getPostsByCategory( cat=category) else: pagination, posts = None, [] try: facebook_comment_url = current_app.config['FACEBOOK_COMMENT_URL'] except: facebook_comment_url = "" try: facebook_app_id = current_app.config['FACEBOOK_APP_ID'] except: facebook_app_id = "" try: facebook_comment_moderators = current_app.config['FACEBOOK_COMMENT_MODERATORS'] except: facebook_comment_moderators = "" return render_template( 'audience.html', audiences=inst, pagination=pagination, referrals=posts, buzzes = buzzes, govescuta = govescuta, menu=menus, facebook = 'facebook' in request.args, FACEBOOK_COMMENT_URL = facebook_comment_url, FACEBOOK_APP_ID = facebook_app_id, FACEBOOK_COMMENT_MODERATORS = facebook_comment_moderators, buzzesSelec = buzzesSelec, how_to=getattr(how_to, 'content', ''), #notice=inst.get_last_published_notice(), ) except (AttributeError, NoResultFound): abort(404)