Exemplo n.º 1
0
def ajax_match_task():
    match_form = MatchOrderForm()
    if match_form.validate():
        data = Api.post('/admin/order/start_match', match_form.data)
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, match_form.errors)
Exemplo n.º 2
0
Arquivo: home.py Projeto: q25979/tdb99
def login():
    login_form = LoginForm()
    error = None
    if request.method == 'POST' and login_form.validate():
        try:
            data = Api.post(
                '/admin/user/login', {
                    'uid': login_form.uid.data,
                    'password': login_form.password.data,
                    'uuid': login_form.uuid.data,
                    'pin_code': login_form.captcha.data
                })
            session['uid'] = login_form.uid.data
            session['token'] = data['token']
            session['role'] = data['role']
            session['permission'] = data['permission']

            return redirect(url_for('home.index'))
        except ApiError as e:
            if 'id' in e.message or 'password' in e.message:
                error = u'用户名或密码错误'
            elif 'uuid' in e.message or 'pin_code' in e.message:
                error = u'验证码错误'
            elif 'locked' in e.message:
                error = u'账号已被锁定'
            elif 'uid' in e.message:

                error = u'账号不存在'
            else:
                error = u'登录错误'
    login_form.captcha.data = None
    return render_template('login.html', form=login_form, login_error=error)
Exemplo n.º 3
0
def ajax_add_user():
    add_user_form = AddUserForm()
    if add_user_form.data['id']:
        add_user_form.password.validators = []
        add_user_form.confirm_password.validators = []
    if add_user_form.validate():
        permission = {}
        for item in add_user_form.permission.data:
            permission[item] = api_permission[item]
        if add_user_form.data['id']:
            data = Api.put(
                '/admin/user/' + urllib2.quote(add_user_form.id.data), {
                    'uid': add_user_form.uid.data,
                    'password': add_user_form.password.data,
                    'permission': permission
                })
        else:
            data = Api.post(
                '/admin/user', {
                    'uid': add_user_form.uid.data,
                    'password': add_user_form.password.data,
                    'permission': permission
                })
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, add_user_form.errors)
Exemplo n.º 4
0
def ajax_register_member():
    form = RegisterForm()
    if form.validate():
        data = form.data
        return jsonify(Api.post('/admin/member', data))
    else:
        raise ApiError(AppError.INVALID_REQUEST, form.errors)
Exemplo n.º 5
0
def ajax_deposit():
    deposit_form = DepositForm()
    if deposit_form.validate():
        data = Api.post('/admin/assets/recharge', deposit_form.data)
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, deposit_form.errors)
Exemplo n.º 6
0
def ajax_add_payment():
    payment_form = PaymentForm()
    if payment_form.validate():
        data = Api.post('/admin/payment/list', payment_form.data)
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, payment_form.errors)
Exemplo n.º 7
0
def ajax_product_modify():
    product_form = ResellerForm()
    if product_form.validate():
        params = product_form.data
        if product_form.id.data:
            data = Api.put('/admin/reseller/' + urllib2.quote(product_form.id.data), params)
        else:
            data = Api.post('/admin/reseller', params)
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, product_form.errors)
Exemplo n.º 8
0
Arquivo: home.py Projeto: q25979/tdb99
def change_password():
    change_password_form = ChangePasswordForm()
    if request.method == 'POST':
        if change_password_form.validate():
            params = change_password_form.data
            params.pop('confirm_new_password')
            return jsonify(Api.post('/admin/user/reset_password', params))
        else:
            raise AppError.invalid_request(change_password_form.errors)
    else:
        return render_template('change_password.html',
                               change_password_form=change_password_form)
Exemplo n.º 9
0
Arquivo: news.py Projeto: q25979/tdb99
def ajax_save():
    form = NewsForm()
    if form.validate():
        data = form.data
        news_id = data.pop('id')
        # detail_data = data['details']
        # details_hash = utils.md5hex(detail_data)
        # data['details'] = upload.put_oss('news/%s.html' % details_hash, detail_data)
        if news_id:
            result = Api.put('/admin/news/details/' + urllib2.quote(news_id),
                             data)
        else:
            result = Api.post('/admin/news', data)
        return jsonify(result)
    else:
        raise ApiError(AppError.INVALID_REQUEST, form.errors)
Exemplo n.º 10
0
def ajax_product_modify():
    product_form = ProductForm()
    if product_form.validate():
        params = {
            'name': product_form.name.data,
            'front_cover': product_form.front_cover.data,
            'category': product_form.category.data,
            'detail_cover_0': product_form.detail_cover_0.data,
            'detail_cover_1': product_form.detail_cover_1.data,
            'detail_cover_2': product_form.detail_cover_2.data,
            'description': product_form.description.data,
            'price': product_form.price.data,
            'sequence': product_form.sequence.data,
            'status': product_form.status.data
        }
        if product_form.id.data:
            data = Api.put(
                '/admin/mall/' + urllib2.quote(product_form.id.data), params)
        else:
            data = Api.post('/admin/mall/product_add', params)
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, product_form.errors)
Exemplo n.º 11
0
def ajax_recharge():
    params = request.get_json()
    result = Api.post('/admin/assets/recharge', params)
    return jsonify(result)
Exemplo n.º 12
0
def ajax_withdraw_cancel():
    params = request.get_json()
    result = Api.post(
        '/admin/order/withdraw/cancel/' + urllib2.quote(str(params['number'])),
        {})
    return jsonify(result)