Example #1
0
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)
Example #2
0
def contest_edit(id):
    contest = Contest.get_by_id(id)
    contest_form = ContestForm()
    contest_form.department.data = current_user.department
    if request.method == 'GET':
        contest_form.name_cn.data = contest.name_cn
        contest_form.name_en.data = contest.name_en
        contest_form.level.data = contest.level
        contest_form.type.data = contest.type
        contest_form.department.data = contest.department
        contest.site = contest_form.site.data
        contest_form.organizer.data = contest.organizer
        contest_form.co_organizer.data = contest.co_organizer
        if contest.series:
            contest_form.series_id.data = contest.series.id
        contest_form.year.data = contest.year
        contest_form.date_range.data = [contest.start_date.strftime('%Y/%m/%d'),
                                        contest.end_date.strftime('%Y/%m/%d')]

    if request.method == 'POST' and contest_form.validate():
        ret = Contest.update_contest(contest, contest_form, request)
        if ret == 'OK':
            return redirect(url_for('admin.contest'))
        elif ret == 'FAIL':
            flash(u'提交失败')
        else:
            flash(ret)
        print ret
    current_app.logger.error(contest_form.errors)
    return render_template('admin/contest_form.html',
                           title = u'修改竞赛',
                           action = url_for('admin.contest_edit', id=id),
                           contest_form = contest_form)
Example #3
0
File: views.py Project: TSS2/test
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)
Example #4
0
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)
Example #5
0
File: views.py Project: TSS2/test
def contest_del():
    contest_id = request.form.get('contest_id', -1, type=int)
    if contest_id != -1:
        contest = Contest.get_by_id(contest_id)
        ret = Contest.delete_contest(contest)
    else:
        ret = u'删除失败'
    return jsonify(ret = ret)
Example #6
0
def contest_del():
    contest_id = request.form.get('contest_id', -1, type=int)
    if contest_id != -1:
        contest = Contest.get_by_id(contest_id)
        ret = Contest.delete_contest(contest)
    else:
        ret = u'删除失败'

    return jsonify(ret=ret)
Example #7
0
File: views.py Project: TSS2/a
def awards_check_after_pass(id, awards_id):
    contest = Contest.get_by_id(id)
    awards = Awards.get_by_id(awards_id)
    exist_resources = awards.resources
    return render_template('admin/awards_see.html',
                           title = u'奖项查看1',
                           contest = contest,
                           awards = awards,
                           exist_resources = exist_resources,
                           )
Example #8
0
File: views.py Project: TSS2/test
def contest_check(id):
    contest = Contest.get_by_id(id)
    contestResult = Contest.ContestResult[1:]
    if request.method == 'POST':
        result = request.form.get('result', 0, type=int)
        contest.result = Contest.ContestResult[result]
        contest.save()
    return render_template('admin/contest_check.html',
                           title = u'审核竞赛',
                           contest = contest,
                           contestResult = contestResult)
Example #9
0
def awards_check_after_pass(id, awards_id):
    contest = Contest.get_by_id(id)
    awards = Awards.get_by_id(awards_id)
    exist_resources = awards.resources
    return render_template(
        'admin/awards_see.html',
        title=u'奖项查看1',
        contest=contest,
        awards=awards,
        exist_resources=exist_resources,
    )
Example #10
0
File: views.py Project: TSS2/a
def contest_see(id):
    contest = Contest.get_by_id(id)
    contests = Contest.ResultList()
    contestResult = contests[0:]
    if request.method == 'POST':
        result = request.form.get('result', 0, type=int)
        current_app.logger.info(result)
        contest.result = contests[result-1].name
        contest.save()
    return render_template('admin/contest_see.html',
                           title = u'竞赛查看',
                           contest = contest,
                           contestResult = contestResult)
Example #11
0
def contest_see(id):
    contest = Contest.get_by_id(id)
    contests = Contest.ResultList()
    contestResult = contests[0:]
    if request.method == 'POST':
        result = request.form.get('result', 0, type=int)
        current_app.logger.info(result)
        contest.result = contests[result - 1].name
        contest.save()
    return render_template('admin/contest_see.html',
                           title=u'竞赛查看',
                           contest=contest,
                           contestResult=contestResult)
Example #12
0
File: views.py Project: TSS2/a
def contest_check(id):
    contest = Contest.get_by_id(id)
    contests = Contest.ResultList()
    contestResult = ContestResult.get_all()
    if request.method == 'POST':
        result = request.form.get('result', 0, type=int)
        current_app.logger.info(result)
        contest.result = contests[result-1].name
        if contest.apply == u'0':
            contest.apply = 1
        contest.save()
    return render_template('admin/contest_check.html',
                           title = u'审核竞赛',
                           contest = contest,
                           contestResult = contestResult)
Example #13
0
File: views.py Project: TSS2/test
def awards(id):
    contest = Contest.get_by_id(id)
    page = request.args.get('page', 1, type=int)
    per_page = current_app.config['ADMIN_AWARDS_PER_PAGE']
    if page == -1:
        page = ((Awards.get_count(contest_id=contest.contest_id) - 1) // per_page) + 1
    pagination = Awards.get_list_pageable(page, per_page,
                                          contest_id=contest.contest_id)
    awards_list = pagination.items
    return render_template('admin/awards.html',
                           title = u'奖项管理',
                           contest = contest,
                           awards_list = awards_list,
                           pagination = pagination,
                           process = Awards.AwardsProcess)
Example #14
0
def contest_check(id):
    contest = Contest.get_by_id(id)
    contests = Contest.ResultList()
    contestResult = ContestResult.get_all()
    if request.method == 'POST':
        result = request.form.get('result', 0, type=int)
        current_app.logger.info(result)
        contest.result = contests[result - 1].name
        if contest.apply == u'0':
            contest.apply = 1
        contest.save()
    return render_template('admin/contest_check.html',
                           title=u'审核竞赛',
                           contest=contest,
                           contestResult=contestResult)
Example #15
0
File: views.py Project: TSS2/test
def awards_add(id):
    contest = Contest.get_by_id(id)
    awards_form = AwardsForm()
    if request.method == 'POST' and awards_form.validate():
        ret = Awards.create_awards(awards_form, contest, 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)
Example #16
0
def contest_edit(id):
    contest = Contest.get_by_id(id)
    contest_form = ContestForm()
    contest_form.department.data = current_user.department
    if request.method == 'GET':
        contest_form.name_cn.data = contest.name_cn
        contest_form.name_en.data = contest.name_en
        #contest_form.level_id.data = contest.level
        contest_form.type.data = contest.type
        contest_form.department.data = contest.department
        contest_form.site.data = contest.site
        contest_form.organizer.data = contest.organizer
        contest_form.co_organizer.data = contest.co_organizer
        contest_form.place.data = contest.place
        if contest.series:
            contest_form.series_id.data = contest.series.id
        if contest.level_name:
            contest_form.level_id.data = contest.level.id
        # contest_form.year.data = contest.year
        contest_form.date_range.data = [
            contest.start_date.strftime('%Y/%m/%d'),
            contest.end_date.strftime('%Y/%m/%d')
        ]
        contest_form.budget.data = contest.budget
        contest_form.budget_text.data = contest.budget_text
        contest_form.student_num.data = contest.student_num
        contest_form.teacher_num.data = contest.teacher_num
        # contest_form.subject.data = contest.subject
    if request.method == 'POST' and contest_form.validate():
        ret = Contest.update_contest(contest, contest_form, request)
        if ret == 'OK':
            if contest.apply == u'3':
                contest.apply = 4
            contest.save()
            return redirect(url_for('admin.contest'))
        elif ret == 'FAIL':
            flash(u'提交失败')
        else:
            flash(ret)
        print ret
    current_app.logger.error(contest_form.errors)
    return render_template('admin/contest_form.html',
                           title=u'修改竞赛',
                           action=url_for('admin.contest_edit', id=id),
                           contest_form=contest_form)
Example #17
0
def awards(id):
    contest = Contest.get_by_id(id)
    page = request.args.get('page', 1, type=int)
    per_page = current_app.config['ADMIN_AWARDS_PER_PAGE']
    department = current_user.department if current_user.department != u'教务处' else None
    if page == -1:
        page = ((Awards.get_count(contest_id=contest.contest_id) - 1) //
                per_page) + 1
    pagination = Awards.get_list_pageable(page,
                                          per_page,
                                          contest_id=contest.contest_id)
    awards_list = pagination.items
    return render_template('admin/awards.html',
                           title=u'奖项管理',
                           contest=contest,
                           awards_list=awards_list,
                           pagination=pagination,
                           process=Awards.AwardsProcess,
                           department=department)
Example #18
0
File: views.py Project: TSS2/a
def contest_apply(id):
    contest = Contest.get_by_id(id)
    contest.apply = 2
    contest.save()
    page = request.args.get('page', 1, type=int)
    filter_pass = request.args.get('filter_pass', 0, type=int)
    per_page = current_app.config['ADMIN_CONTEST_PER_PAGE']
    department = current_user.department if current_user.department != u'教务处' else None
    if page == -1:
        page = ((Contest.get_count(filter_pass, department) - 1) // per_page) + 1
    pagination = Contest.get_list_pageable(page, per_page, filter_pass,
                                           department)
    contest_list = pagination.items
    return render_template('admin/contest.html',
                           title = u'竞赛管理',
                           contest_list = contest_list,
                           pagination = pagination,
                           filter_pass = filter_pass,
                           department = department)
Example #19
0
def contest_apply(id):
    contest = Contest.get_by_id(id)
    contest.apply = 2
    contest.save()
    page = request.args.get('page', 1, type=int)
    filter_pass = request.args.get('filter_pass', 0, type=int)
    per_page = current_app.config['ADMIN_CONTEST_PER_PAGE']
    department = current_user.department if current_user.department != u'教务处' else None
    if page == -1:
        page = (
            (Contest.get_count(filter_pass, department) - 1) // per_page) + 1
    pagination = Contest.get_list_pageable(page, per_page, filter_pass,
                                           department)
    contest_list = pagination.items
    return render_template('admin/contest.html',
                           title=u'竞赛管理',
                           contest_list=contest_list,
                           pagination=pagination,
                           filter_pass=filter_pass,
                           department=department)
Example #20
0
def awards_add(id):
    contest = Contest.get_by_id(id)
    awards_form = AwardsForm()
    i = 0
    awards_form.department.data = current_user.department
    # cid = contest.contest_id
    # Awards.set_new_apply(cid)
    request.values.get('StudentList')
    if request.method == 'POST' and awards_form.validate():
        ret = Awards.create_awards(awards_form, contest, 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,
                           i=i)
Example #21
0
File: views.py Project: TSS2/a
def awards_add(id):
    contest = Contest.get_by_id(id)
    awards_form = AwardsForm()
    i =0
    awards_form.department.data = current_user.department
    # cid = contest.contest_id
    # Awards.set_new_apply(cid)
    request.values.get('StudentList')
    if request.method == 'POST' and awards_form.validate():
        ret = Awards.create_awards(awards_form, contest, request.files)
        if ret == 'OK':
            return redirect(url_for('admin.awards', id=contest.id))
        elif ret == 'FAIL':
            flash(u'提交失败')
        else:
            flash(ret)
    # Student.remove_student()
    return render_template('admin/awards_form.html',
                           title = u'奖项录入',
                           contest = contest,
                           awards_form = awards_form,
                           i=i
                           )
Example #22
0
File: views.py Project: TSS2/test
def contest_print(id):
    contest = Contest.get_by_id(id)
    return render_template('print/contest.html',
                           contest = contest)
Example #23
0
def contest_print(id):
    contest = Contest.get_by_id(id)
    return render_template('print/contest.html', contest=contest)
Example #24
0
def awards_refuse_check(id):
    contest = Contest.get_by_id(id)
    cid = contest.contest_id
    Awards.set_all_apply_refuse(cid)
    return redirect(url_for('admin.awards', id=id))
Example #25
0
File: views.py Project: TSS2/a
def awards_refuse_check(id):
    contest = Contest.get_by_id(id)
    cid = contest.contest_id
    Awards.set_all_apply_refuse(cid)
    return  redirect(url_for('admin.awards',id = id))