Files
devplacepy/devplacepy/routers/profile/_shared.py
T
retoor ede7a863b7 chore: remove stale agent reports and add PYTHONDONTWRITEBYTECODE export to Makefile
Delete four stale SEO and style agent report JSON/MD files from agents/reports/ that had zero findings or were superseded. Export PYTHONDONTWRITEBYTECODE=1 in the Makefile so all make targets suppress bytecode generation, and add a `tree` target that lists the repository file tree via git ls-tree. Update AGENTS.md and CLAUDE.md documentation to reflect that routers now form a directory tree mirroring URL paths and that bytecode writing is disabled project-wide.
2026-06-13 16:27:41 +00:00

23 lines
822 B
Python

# retoor <retoor@molodetz.nl>
from fastapi import Request
from fastapi.responses import RedirectResponse
from devplacepy.database import get_table
from devplacepy.responses import wants_json, json_error
from devplacepy.utils import require_user, not_found
def resolve_customization_target(request: Request, username: str):
current_user = require_user(request)
target = get_table("users").find_one(username=username)
if not target:
raise not_found("User not found")
is_owner = current_user["uid"] == target["uid"]
is_admin = current_user.get("role") == "Admin"
if not (is_owner or is_admin):
if wants_json(request):
return None, json_error(403, "Not allowed")
return None, RedirectResponse(url=f"/profile/{username}", status_code=302)
return target, None