Example #1
0
File: views.py Project: TSS2/test
def series_del():
    series_id = request.form.get('series_id', -1, type=int)
    if series_id != -1:
        series = ContestSeries.get_by_id(series_id)
        ret = ContestSeries.delete_series(series)
    else:
        ret = u'删除失败'
    return jsonify(ret = ret)
Example #2
0
File: views.py Project: TSS2/test
def series():
    page = request.args.get('page', 1, type=int)
    per_page = current_app.config['ADMIN_SERIES_PER_PAGE']
    if page == -1:
        page = ((ContestSeries.get_count() - 1) // per_page) + 1
    pagination = ContestSeries.get_list_pageable(page, per_page)
    series_list = pagination.items
    return render_template('admin/series.html',
                           title = u'竞赛系列管理',
                           series_list = series_list,
                           pagination = pagination)
Example #3
0
File: views.py Project: TSS2/test
def series_edit(id):
    series = ContestSeries.get_by_id(id)
    series_form = ContestSeriesForm()
    if request.method == 'GET':
        series_form.name.data = series.name
    if request.method == 'POST' and series_form.validate():
        ret = ContestSeries.update_series(series, series_form)
        if ret == 'OK':
            return redirect(url_for('admin.series'))
        elif ret == 'FAIL':
            flash(u'提交失败')
        else:
            flash(ret)
    return render_template('admin/series_form.html',
                           title = u'竞赛系列修改',
                           action = url_for('admin.series_edit', id=id),
                           series_form = series_form)
Example #4
0
File: forms.py Project: TSS2/test
 def __init__(self, *args, **kwargs):
     super(ContestForm, self).__init__(*args, **kwargs)
     cur_year = date.today().year
     self.year.choices = [(year, year) for year in range(cur_year - 1, cur_year + 2)]
     series_list = ContestSeries.get_all()
     self.series_id.choices = [(-1, u'  ')] + [(series.id, series.name) for series in series_list]
     self.type.choices = [("-1", u"--- 请选择 ---")] + [(t, t) for t in Contest.ContestType]
     self.department.choices = [("-1", u"--- 请选择 ---")] + [(department, department) for department in DepartmentList]
Example #5
0
File: views.py Project: TSS2/test
def series_add():
    series_form = ContestSeriesForm()
    if request.method == 'POST' and series_form.validate():
        ret = ContestSeries.create_series(series_form)
        if ret == 'OK':
            return redirect(url_for('admin.series'))
        elif ret == 'FAIL':
            flash(u'提交失败')
        else:
            flash(ret)
    return render_template('admin/series_form.html',
                           title = u'竞赛系列录入',
                           action = url_for('admin.series_add'),
                           series_form = series_form)