def add_filhos_and_comments_to_post(post_type, lista_de_posts, total_artigos, total_comentarios, comentarios_separados): if type(lista_de_posts) in (tuple,list): for post in lista_de_posts: total_artigos.append(1) cmts = wordpress.getComments(status='approve',post_id=post['id'], number=1000) if cmts: post['_comments'] = cmts comentarios_separados.append({'post_id':post['id'],'post_title':post['title'],'comments':cmts}) total_comentarios.append(len(cmts)) filhos = wordpress.getCustomPostByParent(post_type, post['id'] ) if filhos: post['filhos'] = filhos add_filhos_and_comments_to_post(post_type, filhos, total_artigos, total_comentarios, comentarios_separados) else: post = lista_de_posts total_artigos.append(1) cmts = wordpress.getComments(status='approve',post_id=post['id'], number=1000) if cmts: post['_comments'] = cmts comentarios_separados.append({'post_id':post['id'],'post_title':post['title'],'comments':cmts}) total_comentarios.append(len(cmts)) filhos = wordpress.getCustomPostByParent(post_type, post['id'] ) if filhos: post['filhos'] = filhos add_filhos_and_comments_to_post(post_type, filhos, total_artigos, total_comentarios, comentarios_separados)
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)
def add_filhos_and_comments_to_post(post_type, lista_de_posts, total_artigos, total_comentarios, comentarios_separados): if type(lista_de_posts) in (tuple, list): for post in lista_de_posts: total_artigos.append(1) cmts = wordpress.getComments(status='approve', post_id=post['id'], number=1000) if cmts: post['_comments'] = cmts comentarios_separados.append({ 'post_id': post['id'], 'post_title': post['title'], 'comments': cmts }) total_comentarios.append(len(cmts)) filhos = wordpress.getCustomPostByParent(post_type, post['id']) if filhos: post['filhos'] = filhos add_filhos_and_comments_to_post(post_type, filhos, total_artigos, total_comentarios, comentarios_separados) else: post = lista_de_posts total_artigos.append(1) cmts = wordpress.getComments(status='approve', post_id=post['id'], number=1000) if cmts: post['_comments'] = cmts comentarios_separados.append({ 'post_id': post['id'], 'post_title': post['title'], 'comments': cmts }) total_comentarios.append(len(cmts)) filhos = wordpress.getCustomPostByParent(post_type, post['id']) if filhos: post['filhos'] = filhos add_filhos_and_comments_to_post(post_type, filhos, total_artigos, total_comentarios, comentarios_separados)
def resultado_detalhe(postid): """Renders a contribution detail""" principal = fromcache("res-detalhe-{0}".format(postid)) or \ tocache("res-detalhe-{0}".format(postid),wordpress.wpgovp.getContribuicoes(principal='S',postID=postid)) # print "PRINCIPAL +++++++++++++++++++++", principal[1][0] retorno = fromcache("contribs-detalhe-{0}".format(postid)) or \ tocache("contribs-detalhe-{0}".format(postid),wordpress.wpgovp.getContribuicoes(principal='N',postID=postid)) # print "RETORNO +++++++++++++++++++++", retorno comts = fromcache("com-res-detalhe-{0}".format(postid)) or \ tocache("com-res-detalhe-{0}".format(postid),wordpress.getComments(status='approve',post_id=postid)) qtd = retorno[0] detalhes = retorno[1] return render_template('resultados-detalhes.html', agregadas=detalhes, qtd_agregadas=qtd, principal=principal[1][0], comments=comts, postid=postid)
def resultado_detalhe(postid): """Renders a contribution detail""" principal = fromcache("res-detalhe-{0}".format(postid)) or \ tocache("res-detalhe-{0}".format(postid),wordpress.wpgovp.getContribuicoes(principal='S',postID=postid)) # print "PRINCIPAL +++++++++++++++++++++", principal[1][0] retorno = fromcache("contribs-detalhe-{0}".format(postid)) or \ tocache("contribs-detalhe-{0}".format(postid),wordpress.wpgovp.getContribuicoes(principal='N',postID=postid)) # print "RETORNO +++++++++++++++++++++", retorno comts = fromcache("com-res-detalhe-{0}".format(postid)) or \ tocache("com-res-detalhe-{0}".format(postid),wordpress.getComments(status='approve',post_id=postid)) qtd = retorno[0] detalhes = retorno[1] return render_template( 'resultados-detalhes.html', agregadas=detalhes, qtd_agregadas=qtd, principal=principal[1][0], comments=comts, postid=postid )
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 )
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)
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)
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, comments=cmts, show_comment_form=is_authenticated(), recent_posts=recent_posts) ) resp.set_cookie('live_comment_save', "" ) return resp