def upload(): # TODO try to parse file in webargs ********** image_file = request.files['file'] args = args_parser.parse_all() isprivate = args.get('isprivate', False) file_hash = upload_file(image_file, isprivate=isprivate) return {'file_hash': file_hash}
def get_all_status(): args = args_parser.parse_all() activity_payments = pay_base.get_all_activity_stats(args) # set restaurant name restaurants = rst_base.mget( [pay.get('restaurant_id') for pay in activity_payments]) for index, payments in enumerate(activity_payments): payments['restaurant_name'] = restaurants[index].name if not restaurants[index].is_valid: payments['restaurant_name'] += u'(餐厅已无效)' activity_payments = pay_base.set_activity_names(activity_payments) activity_payments = pay_base.set_bank_card_exist_or_not(activity_payments) visible_city_ids = city_base.get_city_id_name_pairs_by_user() no_subsidy_indication, pay_fail_indication = pay_base.\ get_failed_status_indication(args) return { 'payments': activity_payments, 'city_ids': visible_city_ids, 'no_subsidy_indication': no_subsidy_indication, 'pay_fail_indication': pay_fail_indication, 'total_num': 0 }
def hash2url(hash): ''' :return: redirect to real image url via hash ''' args = args_parser.parse_all() isprivate = args.get('isprivate', False) return redirect(get_file_url(hash, isprivate=isprivate))
def hash2url(hash): ''' :return: redirect to real image url via hash ''' args = args_parser.parse_all() isprivate=args.get('isprivate',False) return redirect(get_file_url(hash,isprivate=isprivate))
def upload(): # TODO try to parse file in webargs ********** image_file = request.files['file'] args = args_parser.parse_all() isprivate=args.get('isprivate',False) file_hash = upload_file(image_file,isprivate=isprivate) return {'file_hash': file_hash}
def check_region_post(*args, **kwargs): if current_user.is_super_admin(): return True args = args_parser.parse_all() city_ids = current_user.city_ids if args['city_id'] in city_ids: return True
def delete(): args = args_parser.parse_all() isprivate=args.get('isprivate',False) file_hash = args_parser.parse( {'file_hash': Arg(str), }).get('file_hash') delete_file(file_hash,isprivate=isprivate) return ''
def delete(): args = args_parser.parse_all() isprivate = args.get('isprivate', False) file_hash = args_parser.parse({ 'file_hash': Arg(str), }).get('file_hash') delete_file(file_hash, isprivate=isprivate) return ''
def post(): dic = args_parser.parse_all() if not check_region_post(): raise_auth_exc(AUTH_FAILED_ERROR) dic['area'] = front_area_to_back_area(dic['_area']) result = region_base.post(None, dic) if dic['type_code'] == WHITE_COLLAR_TYPE_CODE: white_collar_base.update_building_region(result, dic['_area']) return result
def put(pk): pk = int(pk) if not check_region(pk=pk): raise_auth_exc(AUTH_FAILED_ERROR) dic = args_parser.parse_all() region = region_base.get(pk) dic['area'] = front_area_to_back_area(dic['_area']) result = region_base.put(pk, dic) if region['type_code'] == WHITE_COLLAR_TYPE_CODE and dic['type_code'] != WHITE_COLLAR_TYPE_CODE: white_collar_base.delete_by_region(result) if dic['type_code'] == WHITE_COLLAR_TYPE_CODE: white_collar_base.update_building_region(result, dic['_area']) return result
def put(pk): pk = int(pk) if not check_region(pk=pk): raise_auth_exc(AUTH_FAILED_ERROR) dic = args_parser.parse_all() region = region_base.get(pk) dic['area'] = front_area_to_back_area(dic['_area']) result = region_base.put(pk, dic) if region['type_code'] == WHITE_COLLAR_TYPE_CODE and dic[ 'type_code'] != WHITE_COLLAR_TYPE_CODE: white_collar_base.delete_by_region(result) if dic['type_code'] == WHITE_COLLAR_TYPE_CODE: white_collar_base.update_building_region(result, dic['_area']) return result
def payment_log(restaurant_id): args = args_parser.parse_all() activity_id = args.get('activity_id') activity_category_id = args.get('activity_category_id') page_no, page_size = get_paging_params() records, total_num = act_pay_base.get_pay_records2( restaurant_id, activity_id, activity_category_id, offset=(page_no-1) * page_size, limit=page_size, ) return {'records': records, 'total_num': total_num}
def payment_log(restaurant_id): args = args_parser.parse_all() activity_id = args.get('activity_id') activity_category_id = args.get('activity_category_id') page_no, page_size = get_paging_params() records, total_num = act_pay_base.get_pay_records2( restaurant_id, activity_id, activity_category_id, offset=(page_no - 1) * page_size, limit=page_size, ) return {'records': records, 'total_num': total_num}
def processing(): args = args_parser.parse_all() status_to = int(args.get("status")) comment = args.get("comment", "") restaurant_id = int(args.get("restaurant_id")) cert = cert_base.get(restaurant_id) if status_to != CERTIFICATION_CONST.STATUS_PASSED and status_to != CERTIFICATION_CONST.STATUS_FAILED: raise_user_exc(CERT_PROC_ILL_ERR) if cert.status != CERTIFICATION_CONST.STATUS_PENDING: raise_user_exc(CERT_NOT_PENDING_ERR) cert_base.process_certification(restaurant_id, status_to) record_base.add(restaurant_id, cert.type, cert.status, status_to, comment) return ""
def processing(): args = args_parser.parse_all() status_to = int(args.get('status')) comment = args.get('comment', '') restaurant_id = int(args.get('restaurant_id')) cert = cert_base.get(restaurant_id) if status_to != CERTIFICATION_CONST.STATUS_PASSED and \ status_to != CERTIFICATION_CONST.STATUS_FAILED: raise_user_exc(CERT_PROC_ILL_ERR) if cert.status != CERTIFICATION_CONST.STATUS_PENDING: raise_user_exc(CERT_NOT_PENDING_ERR) cert_base.process_certification(restaurant_id, status_to) record_base.add(restaurant_id, cert.type, cert.status, status_to, comment) return ''
def export_excel(): args = args_parser.parse_all() activity_payments = pay_base.get_all_activity_stats(args) # set restaurant name restaurants = rst_base.mget( [pay.get('restaurant_id') for pay in activity_payments]) for index, payments in enumerate(activity_payments): payments['restaurant_name'] = restaurants[index].name activity_payments = pay_base.set_activity_names(activity_payments) activity_payments = pay_base.set_act_category_names(activity_payments) temp_file = tempfile.TemporaryFile() workbook = generate_excel(activity_payments, u'活动打款审核记录', ( ('restaurant_id', u'餐厅id'), ('restaurant_name', u'餐厅名称'), ('activity_name', u'活动名称'), ('activity_id', u'活动id'), ('first_date', u'起始日期'), ('last_date', u'结束日期'), ('activity_category_id', u'活动类别'), ('total_subsidy', u'打款总额'), ('quantity', u'数量'), )) workbook.save(temp_file) temp_file.seek(0) response = send_file(temp_file, as_attachment=True, mimetype='application/vnd.ms-excel', attachment_filename='活动打款审核记录.xls', add_etags=False) temp_file.seek(0, os.SEEK_END) size = temp_file.tell() temp_file.seek(0) response.headers.extend({ 'Content-Length': size, 'Cache-Control': 'no-cache' }) return response
def update_customer_service_user(pk): args = args_parser.parse_all() cs_user_base.post_or_put(pk, args) return ''
def post(): args = args_parser.parse_all() city_manager_base.post_or_put(None, args) return ''
def put(pk): args = args_parser.parse_all() city_manager_base.post_or_put(pk, args) return ''
def get(file_hash): args = args_parser.parse_all() isprivate=args.get('isprivate',False) file_url = get_file_url(file_hash,isprivate=isprivate) return {'file_url': file_url}
def update(): args = args_parser.parse_all() _set_files_into_args(args) cert = dict2object(args, TRestaurantCertification()) _format_certification(cert) return cert_base.update(cert)
def get_pending_status(): args = args_parser.parse_all() audit_enabled = pay_base.get_audit_status() activity_payments = pay_base.get_pending_activity_stats(args) restaurants = rst_base.mget( [pay.get('restaurant_id') for pay in activity_payments]) rest_map = {r.id: r.name for r in restaurants} for index, payments in enumerate(activity_payments): payments['restaurant_name'] = rest_map.get(payments['restaurant_id'], u'') activity_payments = pay_base.set_activity_names(activity_payments) activity_payments = pay_base.set_bank_card_exist_or_not(activity_payments) final_payments = {} for act_pay in activity_payments: payment = final_payments.get(act_pay['restaurant_id']) if payment: payment['activities'].append({ 'activity_name': act_pay['activity_name'], 'activity_id': act_pay['activity_id'], 'activity_category_id': act_pay['activity_category_id'], 'first_date': act_pay['first_date'], 'last_date': act_pay['last_date'], 'quantity': act_pay['quantity'], 'total_subsidy': act_pay['total_subsidy'] }) else: act_pay['activities'] = [{ 'activity_name': act_pay['activity_name'], 'activity_id': act_pay['activity_id'], 'activity_category_id': act_pay['activity_category_id'], 'first_date': act_pay['first_date'], 'last_date': act_pay['last_date'], 'quantity': act_pay['quantity'], 'total_subsidy': act_pay['total_subsidy'] }] act_pay.__delitem__('activity_id') act_pay.__delitem__('activity_category_id') act_pay.__delitem__('activity_name') act_pay.__delitem__('first_date') act_pay.__delitem__('last_date') act_pay.__delitem__('quantity') act_pay.__delitem__('total_subsidy') final_payments[act_pay['restaurant_id']] = act_pay return { 'payments': final_payments.values(), 'audit_enabled': audit_enabled, 'total_num': 0 }
def get(file_hash): args = args_parser.parse_all() isprivate = args.get('isprivate', False) file_url = get_file_url(file_hash, isprivate=isprivate) return {'file_url': file_url}