示例#1
0
def post_comment():
    user = session.get('user_info')
    chat = {'author':user.get('username'),
            'date':datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
            'message':request.values.get('message')}
    if len(request.values.get('message')) > 0:
        r_session.lpush('comments_list',json.dumps(chat))
    return redirect(url_for('comments'))
示例#2
0
def post_comment():
    user = session.get('user_info')
    chat = {
        'author': user.get('username'),
        'date': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
        'message': request.values.get('message')
    }
    if len(request.values.get('message')) > 0:
        r_session.lpush('comments_list', json.dumps(chat))
    return redirect(url_for('comments'))
示例#3
0
def send_msg(username, subject, content, expire=3600 * 24 * 31, sender='Admin'):
    if bytes(username, 'utf-8') not in r_session.smembers('users'):
        return '找不到该用户。'
    msgs_key = 'user_messages:%s' % username
    msg_id = str(uuid.uuid1())
    msg = dict(id=msg_id, subject=subject, content=content,sender=sender,
               is_read=False, time=datetime.now().strftime('%Y-%m-%d %H:%M'))
    msg_key = 'user_message:%s' % msg_id
    r_session.setex(msg_key, expire, json.dumps(msg))
    r_session.lpush(msgs_key, msg_id)
    return '发送成功'