def awards_edit(id, awards_id): contest = Contest.get_by_id(id) awards = Awards.get_by_id(awards_id) exist_resources = awards.resources awards_form = AwardsForm() # if awards.apply == 3 or awards.apply == 5: # cid = contest.contest_id # Awards.set_all_apply_to_zero(cid) i = 1 if request.method == 'GET': awards_form.honor.data = awards.honor awards_form.level.data = awards.level awards_form.title.data = awards.title awards_form.type.data = awards.type # if awards.teachers: # teacher = awards.teachers[0] # awards_form.teachers.data = teacher.name awards_form.teachers.data = [t.name for t in awards.teachers] awards_form.students.data = [s.stu_no for s in awards.students] if request.method == 'POST' and awards_form.validate(): ret = Awards.update_awards(awards, awards_form, request.files) if ret == 'OK': return redirect(url_for('admin.awards', id=contest.id)) elif ret == 'FAIL': flash(u'提交失败') else: flash(ret) return render_template('admin/awards_form.html', title=u'奖项修改', contest=contest, awards_form=awards_form, exist_resources=exist_resources, awards=awards, i=i)
def awards_edit(id, awards_id): contest = Contest.get_by_id(id) awards = Awards.get_by_id(awards_id) exist_resources = awards.resources awards_form = AwardsForm() if request.method == 'GET': awards_form.honor.data = awards.honor awards_form.level.data = awards.level awards_form.title.data = awards.title awards_form.type.data = awards.type if awards.teachers: teacher = awards.teachers[0] awards_form.teachers.data = teacher.name awards_form.students.data = [s.stu_no for s in awards.students] if request.method == 'POST' and awards_form.validate(): ret = Awards.update_awards(awards, awards_form, request.files) if ret == 'OK': return redirect(url_for('admin.awards', id=contest.id)) elif ret == 'FAIL': flash(u'提交失败') else: flash(ret) return render_template('admin/awards_form.html', title = u'奖项修改', contest = contest, awards_form = awards_form, exist_resources = exist_resources)
def awards_check(id, awards_id): contest = Contest.get_by_id(id) awards = Awards.get_by_id(awards_id) exist_resources = awards.resources awards_form = AwardsForm() department = current_user.department if current_user.department != u'教务处' else None if request.method == 'GET': awards_form.honor.data = awards.honor awards_form.level.data = awards.level awards_form.title.data = awards.title awards_form.type.data = awards.type if awards.teachers: teacher = awards.teachers[0] awards_form.teachers.data = teacher.name awards_form.students.data = [s.stu_no for s in awards.students] if request.method == 'POST' and awards_form.validate(): ret = Awards.update_awards(awards, awards_form, request.files) if ret == 'OK': return redirect(url_for('admin.awards', id=contest.id)) elif ret == 'FAIL': flash(u'提交失败') else: flash(ret) return render_template('admin/awards_form_check.html', title=u'奖项查看', contest=contest, awards_form=awards_form, awards=awards, exist_resources=exist_resources, department=department)