def my_apply_id(id): apply = Apply.query.get_or_404(id) comments = Comment.query.filter_by(apply_id=id).all() form = MyApplyForm() file_form = FileApplyForm() comment_form = CommentForm() if apply.status_id % 2 == 0: reapply_form = ReApplyForm() else: reapply_form = None if form.submit1.data and form.validate_on_submit(): apply.name = form.name.data apply.info = form.info.data db.session.commit() flash('更改项目信息成功', 'success') return redirect(url_for('user.my_apply_id', id=id)) if file_form.submit2.data and file_form.validate_on_submit(): last_time = time.strftime('%Y-%m-%d_%H:%M:%S', time.localtime()) upload_file(last_time, id=id) apply.last_time = last_time db.session.commit() flash('上传项目文件成功', 'success') return redirect(url_for('user.my_apply_id', id=id)) if comment_form.submit3.data and comment_form.validate_on_submit(): body = comment_form.body.data new_comment = Comment(body=body, author_id=current_user.id, apply_id=id) db.session.add(new_comment) db.session.commit() return redirect(url_for('user.my_apply_id', id=id)) if reapply_form and reapply_form.submit0.data and reapply_form.validate_on_submit( ): apply.status_id = 1 apply.t_id = reapply_form.t_id.data apply.s_id, apply.c_id = None, None apply.last_time = time.strftime('%Y-%m-%d_%H:%M:%S', time.localtime()) for i in comments: db.session.delete(i) db.session.commit() flash('项目已重新申请', 'success') return redirect(url_for('user.my_apply')) flash_errors(file_form) form.name.data = apply.name form.info.data = apply.info files_list = os.listdir(file_path(apply.inner_path)) return render_template('user/my_apply_id.html', form=form, file_form=file_form, comment_form=comment_form, reapply_form=reapply_form, apply=apply, comments=comments, files_list=files_list)
def pending_approval_id(id): apply = Apply.query.get_or_404(id) comments = Comment.query.filter_by(apply_id=id).all() files_list = os.listdir(file_path(apply.inner_path)) comment_form = CommentForm() if comment_form.submit3.data and comment_form.validate_on_submit(): body = comment_form.body.data new_comment = Comment(body=body, author_id=current_user.id, apply_id=id) db.session.add(new_comment) db.session.commit() return redirect(url_for('college.pending_approval_id', id=id)) return render_template('college/pending_approval_id.html', apply=apply, files_list=files_list, comments=comments,comment_form=comment_form)
def upload_image(): f = request.files.get('upload') inner_path = current_user.number f.save(file_path(inner_path) + '/' + f.filename) url = archives.url(inner_path + '/' + f.filename) return upload_success(url, f.filename)