Download apps/organization/api/utils_api.py from jun2024/fc: direct link, hf CLI and curl.
- Browser
- Download file 488 Bytes
-
https://huggingface.co/spaces/jun2024/fc/resolve/main/apps/organization/api/utils_api.py
- Command line
-
hf download hf://spaces/jun2024/fc/apps/organization/api/utils_api.py
-
curl -L -o utils_api.py https://huggingface.co/spaces/jun2024/fc/resolve/main/apps/organization/api/utils_api.py
488 Bytes
| """API 层公共辅助函数""" | |
| from __future__ import annotations | |
| from django.http import HttpRequest | |
| from ninja import Router | |
| from apps.organization.models import Lawyer | |
| router = Router(tags=["组织管理辅助"]) | |
| def get_request_user(request: HttpRequest) -> Lawyer | None: | |
| """从 Ninja request 中提取当前用户(兼容 auth 和 session 两种认证方式)""" | |
| return getattr(request, "auth", None) or getattr(request, "user", None) # type: ignore[return-value] | |