Example #1
0
 def post(self, tid):
     tid = request.form.get("tid")
     content = request.form.get("content")
     topic = get_topic(tid)
     sender, receiver = get_topic_users(g.current_user.id, topic.id)
     if not topic or not sender or not receiver:
         return redirect(url_for("topic.index"))
     make_reply(sender, receiver, topic, content)
     # clean cache
     clean_cache(g.current_user.id, receiver.uid, topic.id)
     backend.delete("topic:user_topic:%d:%d" % (g.current_user.id, topic.id))
     backend.delete("topic:user_topic:%d:%d" % (receiver.uid, topic.id))
     return redirect(url_for("topic.view", tid=tid))
Example #2
0
def format_topic_list(items):
    for item in items:
        t = get_topic(item.tid)
        if not t:
            #TODO have to log
            continue
        topic = Obj()
        topic.id = t.id
        topic.user = get_user(item.contact)
        topic.last_reply = get_reply(t.last_rid)
        topic.title = t.title
        topic.has_new = item.has_new
        yield topic
Example #3
0
 def get(self, tid):
     page = request.args.get('p', '1')
     topic = get_topic(tid)
     if not topic or not page.isdigit():
         raise abort(404)
     page = int(page)
     if mark_read(g.current_user.id, tid):
         backend.delete('topic:user_topic:%d:%d' % (g.current_user.id, tid))
         backend.delete('topic:notify:%d' % g.current_user.id)
         backend.delete('topic:list:%d:1' % g.current_user.id)
     list_page = get_user_replies(tid, page)
     if page > 1 and list_page.total != get_user_replies(tid, 1):
         backend.delete('topic:replies:%d:%d' % (tid, page))
         list_page = get_user_replies(tid, page)
     #TODO check reply count!!!
     return render_template('topic.view.html', \
             replies=format_reply_list(list_page.items), \
             topic=topic, list_page=list_page)