Ejemplo n.º 1
0
def results(rid, page=0):
    """Shows results about a single answer
    """

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

    # Getting the contrib itself and all its related theme_idposts. The page
    # parameter is used to paginate referral query result.
    contrib = _format_contrib(wordpress.govr.getContrib(rid, user_id))
    if contrib['category']:
        pagination, posts = wordpress.getPostsByCategory(
            cat=contrib['category'], page=page)
    else:
        pagination, posts = None, []

    # Building the context to return the template
    return render_template(
        'govresponde_results.html',
        **_get_context({
            'contrib': contrib,
            'hidesidebar': True,
            'rclass': 'result',
            'referrals': posts,
            'pagination': pagination,
            'statusedicao': statusedicao,
            'sidebar':wordpress.getSidebar
        })
    )
Ejemplo n.º 2
0
def results(rid, page=0):
    """Shows results about a single answer
    """

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

    # Getting the contrib itself and all its related theme_idposts. The page
    # parameter is used to paginate referral query result.
    contrib = _format_contrib(wordpress.govr.getContrib(rid, user_id))
    if contrib['category']:
        pagination, posts = wordpress.getPostsByCategory(
            cat=contrib['category'], page=page)
    else:
        pagination, posts = None, []

    # Building the context to return the template
    return render_template(
        'govresponde_results.html',
        **_get_context({
            'contrib': contrib,
            'hidesidebar': True,
            'rclass': 'result',
            'referrals': posts,
            'pagination': pagination,
            'statusedicao': statusedicao
        })
    )
Ejemplo n.º 3
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())
Ejemplo n.º 4
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(),
    )