def admin_delete_group(): form = EnterPasswordForm() id = request.args.get('id') group_details = FlicketGroup.query.filter_by(id=id).first() # we won't ever delete the flicket_admin group (id = 1) if id == '1': flash(gettext('Can\'t delete default flicket_admin group.')) return redirect(url_for('admin_bp.index')) if form.validate_on_submit(): # delete the group. flash( gettext('Deleted group %(value)s', value=group_details.group_name)) db.session.delete(group_details) db.session.commit() return redirect(url_for('admin_bp.groups')) # populate form with logged in user details form.id.data = g.user.id title = gettext('Delete Group') # noinspection PyUnresolvedReferences return render_template('admin_delete_group.html', title=title, group_details=group_details, form=form)
def delete_user(): form = EnterPasswordForm() id = request.args.get("id") user_details = FlicketUser.query.filter_by(id=id).first() # we won't ever delete the flicket_admin user (id = 1) if id == "1": flash(gettext("Can't delete default flicket_admin user."), category="warning") return redirect(url_for("admin_bp.index")) if form.validate_on_submit(): # delete the user. flash(gettext(f"Deleted user {user_details.username}s"), category="success") db.session.delete(user_details) db.session.commit() return redirect(url_for("admin_bp.users")) # populate form with logged in user details form.id.data = g.user.id # noinspection PyUnresolvedReferences return render_template( "admin_delete_user.html", title="Delete user", user_details=user_details, form=form, )
def admin_delete_group(): form = EnterPasswordForm() id = request.args.get("id") group_details = FlicketGroup.query.filter_by(id=id).first() # we won't ever delete the flicket_admin group (id = 1) if id == "1": flash(gettext("Can't delete default flicket_admin group."), category="warning") return redirect(url_for("admin_bp.index")) if form.validate_on_submit(): # delete the group. flash(gettext(f"Deleted group {group_details.group_name}s"), category="info") db.session.delete(group_details) db.session.commit() return redirect(url_for("admin_bp.groups")) # populate form with logged in user details form.id.data = g.user.id title = gettext("Delete Group") # noinspection PyUnresolvedReferences return render_template("admin_delete_group.html", title=title, group_details=group_details, form=form)
def delete_user(): form = EnterPasswordForm() id = request.args.get('id') user_details = FlicketUser.query.filter_by(id=id).first() # we won't ever delete the flicket_admin user (id = 1) if id == '1': flash(gettext('Can\'t delete default flicket_admin user.'), category='warning') return redirect(url_for('admin_bp.index')) if form.validate_on_submit(): # delete the user. flash(gettext('Deleted user {}s'.format(user_details.username)), category='success') db.session.delete(user_details) db.session.commit() return redirect(url_for('admin_bp.users')) # populate form with logged in user details form.id.data = g.user.id # noinspection PyUnresolvedReferences return render_template('admin_delete_user.html', title='Delete user', user_details=user_details, form=form)