Пример #1
0
def updaterecent(userid, threadid):
    """ updates the user's 'recent_threads' column with the new thread that they just visited
    
        returns the updated thread list.
        
        TOOD refactor this, it's a prety ugly implementation of recent threads.
    """
    threadlist = people.getperson(userid).recent_threads
    recent = []
    
    if threadlist:
        recent = threadlist.split(' ')    
    if threadid in recent:
        recent.remove(threadid)
        
    recent.insert(0, threadid)
    
    print recent
    
    text = recent.pop(0) # take care of the fence post.
    for r in recent:
        text += ' ' + r

    web.update('people', where='id=%s' % web.sqlquote(userid), recent_threads=text)
    return 'threads'
Пример #2
0
def messageoffset(id, offset):
    messages = web.select('messages', where='thread_id = %s and id > %s' % (web.sqlquote(id), web.sqlquote(offset)))
    
    offsetmessages = []
    
    for message in messages:
        message['date_sent'] = web.datestr(message['date_sent'])
        message['author'] = people.getperson(message.author_id).name
        offsetmessages.append(message)
        
    return offsetmessages
Пример #3
0
def getrecent(userid, limit=5):
    recentthreads = people.getperson(userid).recent_threads
    tlist = []
    threads = []
    
    if recentthreads:
        tlist = recentthreads.split(' ')
    
    if len(tlist) > limit:
        tlist = tlist[0:limit]

    for t in tlist:
        thread = web.select('threads', where='id=%s' % web.sqlquote(t), limit=1)
        if thread:
            cur = thread[0]
            room = rooms.roombyid(cur.room_id)
            
            threads.append({'id':cur.id, 'summary':cur.summary, 'question':cur.question, 'date_started':cur.date_started, 'room':room})
        
    return threads
Пример #4
0
def threadtranscript(threadid):
    thread = getthread(threadid)
    messages = getmessages(threadid)
    lastmessage = 0 # see javascript api for more information
    
    thread = web.storify(thread)
    thread.date_started = web.datestr(thread.date_started)
    
    transcript = { 'thread': thread, 'messages': None }
    transcript = web.storify(transcript)
    
    transcript.messages = []
    
    for message in messages:
        transcript.messages.append({ 'id': message.id, 'author_id': message.author_id, 'author': people.getperson(message.author_id).name, 'content': message.content, 'time': web.datestr(message.date_sent)})
        lastmessage = message.id
        
    transcript.thread.last_message = lastmessage
    
    return transcript