Ejemplo n.º 1
0
 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}
Ejemplo n.º 2
0
 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}
Ejemplo n.º 3
0
def timeline(request):
    from vilya.models.timeline import format_timeline
    from vilya.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)
Ejemplo n.º 4
0
def timeline(request):
    from vilya.models.timeline import format_timeline
    from vilya.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)
Ejemplo n.º 5
0
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())
Ejemplo n.º 6
0
Archivo: m.py Proyecto: mozillazg/code
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())
Ejemplo n.º 7
0
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())
Ejemplo n.º 8
0
 def test_userinbox(self):
     actor = 'testuser1'
     all_feed = [
         get_user_inbox(actor),
         get_user_feed(actor),
         get_public_feed(),
     ]
     data = dict(type='pull_request',
                 owner='testuser2',
                 url='',
                 title='pr title',
                 description='pr desc',
                 date=datetime.now(),
                 from_proj='10',
                 to_proj='1',
                 uid='pullrequest-1-1-unmerge')
     for feed in all_feed:
         feed.add_action(data)
         actions = feed.get_actions()
         assert len(actions) == 1
Ejemplo n.º 9
0
# -*- coding: utf-8 -*-

import pickle

from vilya.models.feed import get_public_feed

with open('tests/init/feed_actions.pickle', 'r') as f:
    actions = pickle.load(f)

feed = get_public_feed()
if feed:
    for action in actions:
        feed.add_action(action)
Ejemplo n.º 10
0
def public_timeline(request):
    actions = get_public_feed().get_actions(stop=PAGE_ACTIONS_COUNT - 1)
    return st('public_timeline.html', **locals())
Ejemplo n.º 11
0
def public_timeline(request):
    actions = get_public_feed().get_actions(stop=PAGE_ACTIONS_COUNT - 1)
    return st('public_timeline.html', **locals())
Ejemplo n.º 12
0
# -*- coding: utf-8 -*-

import pickle

from vilya.models.feed import get_public_feed


with open('tests/init/feed_actions.pickle', 'r') as f:
    actions = pickle.load(f)


feed = get_public_feed()
if feed:
    for action in actions:
        feed.add_action(action)