Files
Christopher Ahern 2758be8680
Some checks are pending
CI / build (3.10) (push) Waiting to run
CI / build (3.8) (push) Waiting to run
CI / build (3.9) (push) Waiting to run
Fix/pylint cleanup (#8)
* Fix pylint warnings across all 24 Python files in web_server

- Add module, class, and function docstrings (C0114, C0115, C0116)
- Fix import ordering: stdlib before third-party before local (C0411)
- Replace wildcard imports with explicit named imports (W0401)
- Remove trailing whitespace and add missing final newlines (C0303, C0304)
- Replace dict() with dict literals (R1735)
- Remove unused imports and variables (W0611, W0612)
- Narrow broad Exception catches to specific exceptions (W0718)
- Replace f-string logging with lazy % formatting (W1203)
- Fix variable naming: UPPER_CASE for constants, snake_case for locals (C0103)
- Add pylint disable comments for necessary global statements (W0603)
- Fix no-else-return, simplifiable-if-expression, singleton-comparison
- Fix bad indentation in stripe.py (W0311)
- Add encoding="utf-8" to open() calls (W1514)
- Add check=True to subprocess.run() calls (W1510)
- Register Celery task modules via conf.include

* Update `package-lock.json` add peer dependencies
2026-02-07 20:57:28 +00:00

30 lines
893 B
Python

"""Admin blueprint for user management operations."""
from flask import Blueprint, session
from utils.utils import sanitize
from utils.admin_utils import check_if_admin, check_if_user_exists, ban_user
admin_bp = Blueprint("admin", __name__)
@admin_bp.route('/ban_user/<int:banned_user>')
def admin_delete_user(banned_user):
"""
Only to be used by a user who has admin privileges.
Contacts the database to ban a user for violation Terms of Service.
"""
# Sanitise the user input
banned_user = sanitize(banned_user)
# Check if the user is an admin
username = session.get("username")
is_admin = check_if_admin(username)
# Check if the user exists
user_exists = check_if_user_exists(banned_user)
# If the user is an admin, try to delete the account
if is_admin and user_exists:
ban_user(banned_user)