def _q_lookup(self, request, num): if not num.isdigit(): raise TraversalError num = int(num) actions = get_public_feed().get_actions(start=num, stop=num+PAGE_ACTIONS_COUNT-1) length = len(actions) render_html = render_actions(actions, show_avatar=True) return {'result': render_html, 'length': length}
def timeline(request): from models.timeline import format_timeline from models.feed import get_public_feed timestamp = request.get_form_var('timestamp') count = request.get_form_var('count') or 15 start = request.get_form_var('start') or 0 start = int(start) count = int(count) if timestamp: actions = get_public_feed().get_actions_by_timestamp(max=timestamp) actions = actions[:count] else: actions = get_public_feed().get_actions(start, start + count) data = [] for action in actions: formated_action = format_timeline(action) if formated_action: data.append(formated_action) return json.dumps(data)
def actions(request): since_id = request.get_form_var('since_id', '') is_public = request.get_form_var('is_public', '') user = request.user all_actions = [] if is_public == 'true': all_actions = get_public_feed().get_actions(0, MAX_ACT_COUNT) elif user: all_actions = get_user_inbox(user.username).get_actions( 0, MAX_ACT_COUNT) if since_id: actions = [] for action in all_actions: if action.get('uid') == since_id: break actions.append(action) else: actions = all_actions return st('/m/actions.html', **locals())