示例#1
0
文件: matkul.py 项目: ap13p/elearn
def matkul_update(matkul_id):
    matkul = MataKuliah.get(MataKuliah.id == matkul_id)
    form = MataKuliahForm(request.form, obj=matkul)
    form.dosen.choices = get_dosen()
    form.action = url_for('admin:matkul:update', matkul_id=matkul.id)
    if form.validate_on_submit():
        form.populate_obj(matkul)
        matkul.dosen = User.get(User.id == form.dosen.data)
        matkul.save()
        flash('Sukses memperbarui mata kuliah')
        return redirect(url_for('admin:matkul:list'))
    return render_template('admin/matkul/update.html', form=form)
示例#2
0
文件: matkul.py 项目: ap13p/elearn
def matkul_create():
    form = MataKuliahForm(request.form)
    form.dosen.choices = get_dosen()
    form.action = url_for('admin:matkul:create')
    if form.validate_on_submit():
        matkul = MataKuliah()
        form.populate_obj(matkul)
        matkul.dosen = User.get(User.id == form.dosen.data)
        matkul.save()
        flash('Sukses menambah mata kuliah')
        return redirect(url_for('admin:matkul:list'))
    return render_template('admin/matkul/create.html', form=form)