예제 #1
0
파일: threads.py 프로젝트: drew/seddit
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
파일: threads.py 프로젝트: drew/seddit
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
파일: threads.py 프로젝트: drew/seddit
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
파일: threads.py 프로젝트: drew/seddit
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