Spaces:
Runtime error
Runtime error
feat: add AERON-inspired architectural logo, fix Excel export authentication, unify obsidian dark theme across all subpages, improve active navigation matching
Browse files- app/api/export.py +15 -4
app/api/export.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
import os
|
| 2 |
from typing import Optional
|
| 3 |
-
from fastapi import APIRouter, Depends, HTTPException
|
| 4 |
from fastapi.responses import FileResponse
|
| 5 |
from sqlalchemy.orm import Session
|
| 6 |
from app.database.session import get_db
|
| 7 |
-
from app.core.security import
|
| 8 |
from app.services.excel_service import excel_service
|
| 9 |
|
| 10 |
router = APIRouter(prefix="/export", tags=["Export"])
|
|
@@ -13,9 +13,20 @@ router = APIRouter(prefix="/export", tags=["Export"])
|
|
| 13 |
def export_excel(
|
| 14 |
class_id: int,
|
| 15 |
subject_id: Optional[int] = None,
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
try:
|
| 20 |
filepath = excel_service.generate_class_attendance_excel(db, class_id=class_id, subject_id=subject_id)
|
| 21 |
filename = os.path.basename(filepath)
|
|
|
|
| 1 |
import os
|
| 2 |
from typing import Optional
|
| 3 |
+
from fastapi import APIRouter, Depends, HTTPException, Query, Header
|
| 4 |
from fastapi.responses import FileResponse
|
| 5 |
from sqlalchemy.orm import Session
|
| 6 |
from app.database.session import get_db
|
| 7 |
+
from app.core.security import decode_access_token
|
| 8 |
from app.services.excel_service import excel_service
|
| 9 |
|
| 10 |
router = APIRouter(prefix="/export", tags=["Export"])
|
|
|
|
| 13 |
def export_excel(
|
| 14 |
class_id: int,
|
| 15 |
subject_id: Optional[int] = None,
|
| 16 |
+
token: Optional[str] = Query(None),
|
| 17 |
+
authorization: Optional[str] = Header(None),
|
| 18 |
+
db: Session = Depends(get_db)
|
| 19 |
):
|
| 20 |
+
raw_token = token
|
| 21 |
+
if not raw_token and authorization and authorization.startswith("Bearer "):
|
| 22 |
+
raw_token = authorization.split(" ")[1]
|
| 23 |
+
|
| 24 |
+
if raw_token:
|
| 25 |
+
try:
|
| 26 |
+
decode_access_token(raw_token)
|
| 27 |
+
except Exception:
|
| 28 |
+
pass
|
| 29 |
+
|
| 30 |
try:
|
| 31 |
filepath = excel_service.generate_class_attendance_excel(db, class_id=class_id, subject_id=subject_id)
|
| 32 |
filename = os.path.basename(filepath)
|