def modify_honor(): if not current_user.is_admin and not current_user.is_coach: return redirect(url_for('main.index')) try: honor = honor_server.get_by_id(request.args['p']) except: return redirect(url_for('admin.manage_honor')) honor_form = form.HonorForm() honor_form.users.choices = user_server.get_user_choice() honor_form.id.data = honor.id honor_form.acquire_time.data = honor.acquire_time honor_form.contest_name.data = honor.contest_name honor_form.team_name.data = honor.team_name honor_form.contest_level.data = str(honor.contest_level) honor_form.users.data = [user.username for user in honor.users] upload_form = form.FileUploadForm() from dao.dbResource import ResourceLevel, ResourceUsage upload_form.level.data = str(ResourceLevel.PUBLIC) upload_form.usage.data = str(ResourceUsage.HONOR_RES) return render_template('edit_honor.html', title = u'修改荣誉', honor_form = honor_form, upload_form = upload_form, exist_res = honor.resources, file_url = resource_server.file_url)
def modify_honor(): if not current_user.is_admin and not current_user.is_coach: return redirect(url_for('main.index')) honor_form = form.HonorForm() honor_form.users.choices = user_server.get_user_choice() try: honor = honor_server.get_by_id(request.args['p']) except: return redirect(url_for('admin.manage_honor')) honor_form.id.data = honor.id honor_form.introduce.data = honor.introduce honor_form.acquire_time.data = honor.acquire_time honor_form.contest_name.data = honor.contest_name honor_form.team_name.data = honor.team_name honor_form.contest_level.data = str(honor.contest_level) users = [] for user in honor.users: users.append(user.username) honor_form.users.data = users upload_form = form.FileUploadForm() from dao.dbResource import ResourceLevel, ResourceUsage upload_form.level.data = str(ResourceLevel.PUBLIC) upload_form.usage.data = str(ResourceUsage.HONOR_RES) return render_template('edit_honor.html', title=u'修改荣誉', honor_form=honor_form, upload_form=upload_form, show_upload=False)
def modify_honor(): honor_form = form.HonorForm() file_form = form.FileUploadForm() honor_form.users.choices = user_server.get_user_choice() if honor_form.validate_on_submit(): try: honor = honor_server.get_by_id(honor_form.id.data) from dao.dbResource import ResourceLevel, ResourceUsage resource_list = [] for name, file in request.files.items(multi=True): if file.filename == '': continue file_form.level.data = ResourceLevel.PUBLIC file_form.name.data = unicode(file.filename).split('.')[0] file_form.usage.data = ResourceUsage.HONOR_RES ret = resource_server.save_file(file_form, file, current_user, 'honor') if ret == 'OK': resource = resource_server.get_by_name(file_form.name.data) resource_list.append(resource) msg = honor_server.modify_honor(honor, honor_form, resource_list) return msg except: current_app.logger.error(traceback.format_exc()) return 'failed' return u'数据填写有误'
def honor(honor_id=None): if not honor_id: return redirect(url_for('main.honor_wall')) honor = honor_server.get_by_id(honor_id) return render_template('index/honor.html', title = u'荣誉', honor = honor, HONOR_LEVEL_MAP = HONOR_LEVEL_MAP)