Exemple #1
0
def edit_mahasiswa():
    form=editmahasiswa_F()
    if form.validate_on_submit():
        if form.foto.data:
            file_foto=simpan_foto(form.foto.data)
            current_user.foto= file_foto
        pass_hash=bcrypt.generate_password_hash(form.password.data).decode('UTF-8')
        current_user.npm=form.npm.data
        current_user.nama=form.nama.data
        current_user.email=form.email.data
        current_user.kelas=form.kelas.data
        current_user.alamat=form.alamat.data
        current_user.password=pass_hash
        db.session.commit()
        flash('Data Berhasil di Ubah', 'Warning')
        return redirect(url_for('rmahasiswa.edit_mahasiswa')) 
    elif request.method=="GET":
        form.npm.data=current_user.npm
        form.nama.data=current_user.nama
        form.email.data=current_user.email
        form.kelas.data=current_user.kelas
        form.alamat.data=current_user.alamat
        form.password.data=current_user.password

    return render_template('edit_mahasiswa.html', form=form) 
Exemple #2
0
def edit_mahasiswa():
    form = editmahasiswa_F()
    if form.validate_on_submit():
        if form.foto.data:
            file_foto = simpan_foto(form.foto.data)
            current_user.foto = file_foto
        current_user.npm = form.npm.data
        current_user.nama = form.nama.data
        current_user.email = form.email.data
        current_user.kelas = form.kelas.data
        current_user.alamat = form.alamat.data
        current_user.password = form.password.data
        db.session.commit()
        flash('Data berhasil di ubah', 'warning')
        return redirect(url_for('rmahasiswa.edit_mahasiswa'))
    elif request.method == "GET":
        form.npm.data = current_user.npm
        form.nama.data = current_user.nama
        form.email.data = current_user.email
        form.kelas.data = current_user.kelas
        form.alamat.data = current_user.alamat
    return render_template('edit_mahasiswa.html', form=form)