def project_detail_form_to_api_project( detail_form: ProjectDetailForm) -> sw.Project: """プロジェクト詳細: Form -> API""" project_ = sw.Project() project_.note = detail_form.note.data project_.detail = detail_form.detail.data return project_
def project_review(project_id): project_api = sw.ProjectApi(api_client=g.api) project_ = sw.Project() project_.is_approval = 0 # (承認ステータス) 3:未申請 -> 0:未承認 -> 1:承認済み project_api.projects_project_id_put(project_id=project_id, project=project_) flash('プロジェクトの審査を開始しました。', category='info') return redirect_(url_for('creator.project', project_id=project_id))
def update_project(self, project_id, metadata, **kwargs): client = self._get_client(**kwargs) project = swagger_client.Project(project_id, None, None, None, None, None, None, None, None, None, None, metadata) _, status_code, _ = client.projects_project_id_put_with_http_info( project_id, project) base._assert_status_code(200, status_code)
def project_form_to_api_project(basic_form: ProjectBasicForm) -> sw.Project: """TODO プロジェクト基本情報: Form -> API""" project = sw.Project() project.title = basic_form.title.data project.summary = basic_form.summary.data project.type = basic_form.type.data project.target_amount = basic_form.target_amount.data project.open_amount = basic_form.open_amount.data project.start_time = '%s %s' % ( basic_form.start_date.data, basic_form.start_time.data, ) project.end_time = '%s %s' % ( basic_form.end_date.data, basic_form.end_time.data, ) project.main_color = basic_form.main_color.data project.accent_color = basic_form.accent_color.data.hex return project
def create_replication_rule(self, projectIDList, targetIDList, name=base._random_name("rule"), desc="", filters=[], trigger=swagger_client.RepTrigger(kind="Manual"), replicate_deletion=True, replicate_existing_image_now=False, **kwargs): projects = [] for projectID in projectIDList: projects.append(swagger_client.Project(project_id=int(projectID))) targets = [] for targetID in targetIDList: targets.append(swagger_client.RepTarget(id=int(targetID))) for filter in filters: filter["value"] = int(filter["value"]) client = self._get_client(**kwargs) policy = swagger_client.RepPolicy(name=name, description=desc, projects=projects, targets=targets, filters=filters, trigger=trigger, replicate_deletion=replicate_deletion, replicate_existing_image_now=replicate_existing_image_now) _, _, header = client.policies_replication_post_with_http_info(policy) return base._get_id_from_header(header), name
def project_edit_basic(project_id): """プロジェクト(基本情報): 編集""" basic_form = ProjectBasicForm(request.form) project_api = sw.ProjectApi(g.api) if 'image' in request.files and request.files['image'].filename: image = request.files['image'] if image.content_length < 1048577: # 画像は1MB制限 file_path = utils.upload_file_to_s3(prefix='project', file=image) project_ = sw.Project() project_.image = file_path project_api.projects_project_id_put(project_id=project_id, project=project_) else: flash('画像は1MB以下にしてください', category='error') elif basic_form.validate_on_submit(): project_ = converter.project_form_to_api_project(basic_form) project_api.projects_project_id_put(project_id=project_id, project=project_) flash('プロジェクト(基本情報)を更新しました', category='info') utils.flash_errors(basic_form) project_ = project_api.projects_project_id_get(project_id=project_id) basic_form = converter.api_project_to_project_form(project_) return render_template('creator_project_edit_basic.html', title="Edit Project", project=project_, basic_form=basic_form)