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)
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)
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)
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)
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)
def ajax_change_role(): change_role_form = ChangeRoleForm() if change_role_form.validate(): data = Api.put( '/admin/user/' + urllib2.quote(change_role_form.user_id.data), {'role': change_role_form.role.data}) return jsonify(data) else: raise ApiError(AppError.INVALID_REQUEST, change_role_form.errors)
def ajax_change_password(): change_password_form = ChangePasswordForm() if change_password_form.validate(): data = Api.put( '/admin/user/' + urllib2.quote(change_password_form.id.data), {'password': change_password_form.password.data}) return jsonify(data) else: raise ApiError(AppError.INVALID_REQUEST, change_password_form.errors)
def ajax_save(): form = MessageForm() if form.validate(): data = form.data message_id = data.pop('id') result = Api.put('/admin/message/detail/' + urllib2.quote(message_id), data) return jsonify(result) else: raise ApiError(AppError.INVALID_REQUEST, form.errors)
def ajax_change_profile(): change_profile_form = ChangeProfileForm() if change_profile_form.validate(): data = Api.put( '/admin/member/detail/' + urllib2.quote(change_profile_form.id.data), change_profile_form.data) return jsonify(data) else: raise ApiError(AppError.INVALID_REQUEST, change_profile_form.errors)
def ajax_change_security(): change_security_form = ChangeSecurityForm() if change_security_form.validate(): data = Api.put( '/admin/member/detail/' + urllib2.quote(change_security_form.security_id.data), {'security_password': change_security_form.security_password.data}) return jsonify(data) else: raise ApiError(AppError.INVALID_REQUEST, change_security_form.errors)
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)
def ajax_change_status(): change_status_form = ChangeStatusForm() if change_status_form.validate(): data = Api.put( '/admin/mall/order/' + urllib2.quote(change_status_form.id.data), { 'express_company': change_status_form.express_company.data, 'express_code': change_status_form.express_code.data, 'status': change_status_form.status.data }) return jsonify(data) else: raise ApiError(AppError.INVALID_REQUEST, change_status_form.errors)
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)
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)