Spaces:
Running
Running
File size: 752 Bytes
428a607 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from flask import Blueprint, request, redirect, url_for, flash
from middleware import role_required
from models.history import History
from flask_login import current_user
history = Blueprint('history', __name__, template_folder='templates', url_prefix='/dashboard/history')
@history.route('/delete', methods=['POST'])
@role_required('pengguna')
def delete():
id = request.form['id']
try:
history = History(id=id)
history.delete(current_user.id)
flash(('Hapus Riwayat Sukses', 'Riwayat berhasil dihapus'), 'success')
except Exception as e:
flash(('Hapus Riwayat Gagal', 'Terjadi kesalahan server saat menghapus'), 'error')
return redirect(url_for('dashboard.history', id=current_user.id))
|