Exemplo n.º 1
0
def add_notice(*args, **kwargs):
    params = get_request_args(request)
    is_open = params.get('is_open', 1)
    wx_nick_name = params.get('wx_nick_name', '')
    wx_open_id = params.get('wx_open_id', '')

    if request.method == 'POST':
        content = params['content']
        Notice(
            content=content,
            is_open=is_open,
            wx_nick_name=wx_nick_name,
            wx_open_id=wx_open_id
        ).add()
    elif request.method == 'GET':
        notices = Notice.query(
            Notice,
            filter=[or_(
                and_(
                    Notice.wx_open_id == wx_open_id,
                    Notice.is_open == 0),
                Notice.is_open == 1)])
        return [{
            'content': notice.content,
            'is_read': notice.is_read,
        }for notice in notices]
Exemplo n.º 2
0
def vote_handler(*args, **kwargs):
    params = get_request_args(request)
    if request.method == 'GET':
        return get_vote(**params)
    elif request.method == 'POST':
        return add_vote(**params)
    elif request.method == 'PUT':
        return edit_vote(**params)
Exemplo n.º 3
0
def upload(*args, **kwargs):
    data = get_request_args(request)
    file_path = '/Users/wanggao/mm/'
    logger.info('request.files:{}, data:{}'.format(request.files, data))
    file_handler = request.files['image']

    file_name = file_handler.filename
    file_store_path = file_path + file_name

    file_handler.save(file_store_path)
    return file_store_path
Exemplo n.º 4
0
def commit_feedback(*args, **kwargs):
    params = get_request_args(request)
    content = params['content']
    wx_nick_name = params['wx_nick_name']
    wx_open_id = params['wx_open_id']

    Feedback(
        content=content,
        wx_nick_name=wx_nick_name,
        wx_open_id=wx_open_id
    ).add()
Exemplo n.º 5
0
def vote_result_handle(*args, **kwargs):
    params = get_request_args(request)
    vote_id = params.get('vote_id')
    option_id_list = params.get('option_id_list')
    voter_wx_name = params.get('voter_wx_name')
    voter_wx_open_id = params.get('voter_wx_open_id')
    avatar_url = params.get('avatar_url')
    if request.method == 'GET':
        return get_vote_result(vote_id, voter_wx_open_id)
    elif request.method == 'POST':
        return post_vote_result(
            vote_id,
            option_id_list,
            voter_wx_name,
            voter_wx_open_id,
            avatar_url)
Exemplo n.º 6
0
def tap_notice(*args, **kwargs):
    params = get_request_args(request)
    notice_id = params['notice_id']
    Notice.update(
        {'is_read': 1},
        filter=[Notice.id == notice_id])