Download a Discussion attachment with a filename.
(fid: int)
| 13063 | # Ensure we don't remove the last admin |
| 13064 | admins = conn.execute("SELECT COUNT(*) AS c FROM users WHERE is_admin=1").fetchone() |
| 13065 | if admins and int(admins["c"]) <= 1: |
| 13066 | conn.close() |
| 13067 | flash("Refusing to remove the last admin.") |
| 13068 | return redirect(url_for("admin_panel")) |
| 13069 | |
| 13070 | row = conn.execute("SELECT is_admin FROM users WHERE username=?", (u,)).fetchone() |
| 13071 | if not row: |
| 13072 | conn.close() |
| 13073 | flash("User not found.") |
| 13074 | return redirect(url_for("admin_panel")) |
| 13075 | if int(row["is_admin"]) != 1: |
| 13076 | conn.close() |
| 13077 | flash("User is not an admin.") |
| 13078 | return redirect(url_for("admin_panel")) |
| 13079 | |
| 13080 | conn.execute("UPDATE users SET is_admin=0, admin_device_id=NULL WHERE username=?", (u,)) |
| 13081 | conn.commit() |
| 13082 | conn.close() |
| 13083 | flash(f"Removed admin from @{u}.") |
| 13084 | return redirect(url_for("admin_panel")) |
| 13085 | |
| 13086 | @app.route("/admin/kick", methods=["POST"]) |
| 13087 | @login_required |
| 13088 | def admin_kick_user(): |
| 13089 | """admin_kick_user. |
| 13090 | |
| 13091 | Admin-only route handler. |
| 13092 | |
| 13093 | This docstring was expanded to make future maintenance easier. |
| 13094 | |
| 13095 | Returns: |
| 13096 | Varies. |
| 13097 | """ |
nothing calls this directly
no test coverage detected