def buzz_stream(aid): """public_buzz, moderated_buzz, selected_buzz, last_published at once filtred by from_id, selected_ids, moderated_ids and last_published_id""" public_limit = int(request.values.get('public_limit')) public_ids = request.values.getlist('public_ids[]') moderated_ids = request.values.getlist('moderated_ids[]') selected_ids = request.values.getlist('selected_ids[]') last_published_id = int(request.values.get('last_published_id', 0)) public = AudiencePosts.query.get(aid).get_public_buzz(0,public_limit,public_ids) moderated = AudiencePosts.query.get(aid).get_moderated_buzz(moderated_ids) selected = AudiencePosts.query.get(aid).get_selected_buzz(selected_ids) published = AudiencePosts.get(aid).get_last_published_notice() buzz = {'public': [notice.to_dict() for notice in public], 'moderated': [notice.to_dict() for notice in moderated], 'selected': [notice.to_dict() for notice in selected], 'published': published and published.id != last_published_id \ and published.to_dict() or None} # print "==================================================================================" # print dumps(buzz) # print "==================================================================================" return dumps(buzz)
def buzz_stream(aid): """public_buzz, moderated_buzz, selected_buzz, last_published at once filtred by from_id, selected_ids, moderated_ids and last_published_id""" public_limit = int(request.values.get('public_limit')) public_ids = request.values.getlist('public_ids[]') moderated_ids = request.values.getlist('moderated_ids[]') selected_ids = request.values.getlist('selected_ids[]') last_published_id = int(request.values.get('last_published_id', 0)) public = AudiencePosts.query.get(aid).get_public_buzz( 0, public_limit, public_ids) moderated = AudiencePosts.query.get(aid).get_moderated_buzz(moderated_ids) selected = AudiencePosts.query.get(aid).get_selected_buzz(selected_ids) published = AudiencePosts.get(aid).get_last_published_notice() buzz = {'public': [notice.to_dict() for notice in public], 'moderated': [notice.to_dict() for notice in moderated], 'selected': [notice.to_dict() for notice in selected], 'published': published and published.id != last_published_id \ and published.to_dict() or None} # print "==================================================================================" # print dumps(buzz) # print "==================================================================================" return dumps(buzz)
def last_published(aid): """Returns the last published notice of an audience""" notice = AudiencePosts.get(aid).get_last_published_notice() return dumps(notice and notice.to_dict() or None)