def get_upload_info(): now = int(time.time()) expire_syncpoint = now + 1800 expire = get_iso_8601(expire_syncpoint) policy_dict = {} policy_dict["expiration"] = expire condition_array = [] array_item = [] array_item.append("content-length-range") array_item.append(0) array_item.append(104857600) condition_array.append(array_item) policy_dict["conditions"] = condition_array policy = json.dumps(policy_dict).strip() policy_encode = base64.b64encode(bytes(policy, 'utf-8')) sts = request_sts_token('rain') signature = get_sign_policy(sts.access_key_secret, policy_encode) callback_dict = {} callback_dict["callbackUrl"] = "https://apl.apluslabs.com/after_upload" callback_dict[ "callbackBody"] = "bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&filename=${x:filename}&uid=${x:uid}" callback_dict["callbackBodyType"] = "application/x-www-form-urlencoded" callback_param = json.dumps(callback_dict).strip() base64_callback_body = base64.b64encode(bytes(callback_param, 'utf-8')) result = {} # result['run_mode'] = current_app.config['DEBUG'] result['OSSAccessKeyId'] = sts.access_key_id result['x-oss-security-token'] = sts.security_token result['policy'] = policy_encode.decode() result['Signature'] = signature.decode() result['key'] = str(uuid.uuid1()).replace('-', '') result['success_action_status'] = '201' result['callback'] = base64_callback_body.decode() result['x:uid'] = 1 #admin_manager.current_user.get_id() result['x:filename'] = '' return jsonify(result)
def show_profile(): form = ProfileForm() user = user_manager.current_user if form.validate_on_submit(): # user.email = form.email.data # 不允许修改邮箱 user.name = form.name.data user.phone = form.phone.data user.wechat = form.wechat.data user.company = form.company.data user.gender = form.gender.data user.avatar = form.avatar.data user.resume = form.resume.data user.interested = ','.join(form.interested.data) user.invest_role = form.invest_role.data user.investment_min = form.investment_min.data user.investment_max = form.investment_max.data user.invest_phase = ','.join(form.invest_phase.data) with safe_session(db): db.session.add(user) form.email.data = user.email form.name.data = user.name form.phone.data = user.phone form.wechat.data = user.wechat form.company.data = user.company form.gender.data = user.gender form.avatar.data = user.avatar form.resume.data = user.resume form.investment_min.data = user.investment_min form.investment_max.data = user.investment_max industries = [[name, member.value, 'unchecked'] for name, member in Industry.__members__.items()] phases = [[name, member.value, 'unchecked'] for name, member in InvestmentPhase.__members__.items()] gender = [[name, member.value, 'unchecked'] for name, member in Gender.__members__.items()] investment_type = [[name, member.value, 'unchecked'] for name, member in InvestmentType.__members__.items()] for i in investment_type: if i[0] == user.invest_role.name: i[2] = 'checked' break for i in gender: if i[0] == user.gender.name: i[2] = 'checked' break industries_selected = [] if not user.interested else user.interested.split( ',') for i in industries: for j in industries_selected: if i[0] == j: i[2] = 'checked' continue phases_select = [] if not user.invest_phase else user.invest_phase.split( ',') for i in phases: for j in phases_select: if i[0] == j: i[2] = 'checked' # 处理文件上传相关逻辑 now = int(time.time()) expire_syncpoint = now + 1800 expire = get_iso_8601(expire_syncpoint) policy_dict = {} policy_dict["expiration"] = expire condition_array = [] array_item = [] array_item.append("content-length-range") array_item.append(0) array_item.append(104857600) condition_array.append(array_item) policy_dict["conditions"] = condition_array policy = json.dumps(policy_dict).strip() policy_encode = base64.b64encode(bytes(policy, 'utf-8')) sts = request_sts_token('rain') signature = get_sign_policy(sts.access_key_secret, policy_encode) callback_dict = {} callback_dict["callbackUrl"] = "https://apl.apluslabs.com/after_upload" callback_dict[ "callbackBody"] = "bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&filename=${x:filename}&uid=${x:uid}" callback_dict["callbackBodyType"] = "application/x-www-form-urlencoded" callback_param = json.dumps(callback_dict).strip() base64_callback_body = base64.b64encode(bytes(callback_param, 'utf-8')) form.run_mode.data = current_app.config['DEBUG'] form.oss_access_key_id.data = sts.access_key_id form.token.data = sts.security_token form.policy.data = policy_encode.decode() form.Signature.data = signature.decode() # form.key.data = str(uuid.uuid1()).replace('-', '') form.success_action_status.data = '201' form.callback.data = base64_callback_body.decode() form.uid.data = user_manager.current_user.get_id() form.origin_filename.data = '' return render_template('investor/profile.html', form=form, industries=industries, phases=phases, gender=gender, investment_type=investment_type)
def project_new(): form = ProjectForm() p = Project() pid = request.args.get('pid', -1) if pid != -1: temp = Project.query.filter_by( id=pid, owner_id=user_manager.current_user.get_id()).first() if temp: p = temp if form.validate_on_submit(): p.owner_id = user_manager.current_user.get_id() p.icon_url = form.logo_url.data p.name = form.name.data p.description = form.description.data p.advantage = form.advantage.data p.industry = form.industry.data p.company_phase = form.company_phase.data p.financing_sum = form.financing_sum.data p.bp_url = form.bp_url.data p.duration = form.duration.data p.financing_mode = form.financing_mode.data p.financing_status = form.financing_status.data p.deadline = form.deadline.data p.contact_name = form.contact_name.data p.contact_phone = form.contact_phone.data p.contact_email = form.contact_email.data # ProjectPhase.query.filter_by(project_id=p.id).delete() phase_id_list = form.project_phase.data if pid == -1: for ppid in phase_id_list: pp = ProjectPhase() pp.phase = Phase.query.get(int(ppid)) p.phases.append(pp) sorted(phase_id_list) p.phase_index = phase_id_list[0] p.phase_start = datetime.datetime.now() with safe_session(db): db.session.add(p) return redirect(url_for('startup.show_project', pid=p.id)) form.logo_url.data = p.icon_url form.name.data = p.name form.description.data = p.description form.advantage.data = p.advantage form.industry.data = Industry.IntelligentMake.name if not p.industry else p.industry.name form.company_phase.data = CompanyPhase.Initial.name if not p.company_phase else p.company_phase.name form.financing_sum.data = p.financing_sum form.bp_url.data = p.bp_url form.duration.data = p.duration form.financing_mode.data = FinancingMode.Stock if not p.financing_mode else p.financing_mode.name form.financing_status.data = p.financing_status form.deadline.data = p.deadline form.contact_name.data = p.contact_name form.contact_phone.data = p.contact_phone form.contact_email.data = p.contact_email # 处理项目阶段的显示 phases = Phase.query.all() pps = ProjectPhase.query.filter_by(project_id=p.id).all() pp_checked = [pp.phase_id for pp in pps] # 处理文件上传相关逻辑 now = int(time.time()) expire_syncpoint = now + 1800 expire = get_iso_8601(expire_syncpoint) policy_dict = {} policy_dict["expiration"] = expire condition_array = [] array_item = [] array_item.append("content-length-range") array_item.append(0) array_item.append(104857600) condition_array.append(array_item) policy_dict["conditions"] = condition_array policy = json.dumps(policy_dict).strip() policy_encode = base64.b64encode(bytes(policy, 'utf-8')) sts = request_sts_token('rain') signature = get_sign_policy(sts.access_key_secret, policy_encode) callback_dict = {} callback_dict["callbackUrl"] = "https://apl.apluslabs.com/after_upload" callback_dict[ "callbackBody"] = "bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&filename=${x:filename}&uid=${x:uid}" callback_dict["callbackBodyType"] = "application/x-www-form-urlencoded" callback_param = json.dumps(callback_dict).strip() base64_callback_body = base64.b64encode(bytes(callback_param, 'utf-8')) form.run_mode.data = current_app.config['DEBUG'] form.oss_access_key_id.data = sts.access_key_id form.token.data = sts.security_token form.policy.data = policy_encode.decode() form.Signature.data = signature.decode() # form.key.data = str(uuid.uuid1()).replace('-', '') form.success_action_status.data = '201' form.callback.data = base64_callback_body.decode() form.uid.data = user_manager.current_user.get_id() form.origin_filename.data = '' return render_template('startup/project_new.html', form=form, project=p, phases=phases, checked_phase=pp_checked)