fixing mail
This commit is contained in:
@@ -443,8 +443,10 @@ def get_eligible_users(assignment_id: str, db: Session = Depends(get_db), curren
|
||||
return result
|
||||
|
||||
|
||||
from typing import Optional
|
||||
|
||||
class TestEmailRequest(BaseModel):
|
||||
date: date = None
|
||||
date: Optional[date] = None
|
||||
office_id: str
|
||||
|
||||
|
||||
@@ -455,6 +457,7 @@ def send_test_email_tool(data: TestEmailRequest, db: Session = Depends(get_db),
|
||||
from database.models import OfficeClosingDay, OfficeWeeklyClosingDay
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
# Verify office access
|
||||
if current_user.role == UserRole.MANAGER and current_user.office_id != data.office_id:
|
||||
raise HTTPException(status_code=403, detail="Not authorized for this office")
|
||||
|
||||
22
main.py
22
main.py
@@ -21,12 +21,29 @@ from app.routes.users import router as users_router
|
||||
from app.routes.offices import router as offices_router
|
||||
from app.routes.presence import router as presence_router
|
||||
from app.routes.parking import router as parking_router
|
||||
from database.connection import init_db
|
||||
from app.routes.parking import router as parking_router
|
||||
from database.connection import init_db, get_db_session
|
||||
from services.notifications import run_scheduled_notifications
|
||||
import asyncio
|
||||
|
||||
# Rate limiter setup
|
||||
limiter = Limiter(key_func=get_remote_address)
|
||||
|
||||
|
||||
async def scheduler_task():
|
||||
"""Background task to run scheduled notifications every minute"""
|
||||
config.logger.info("Scheduler task started")
|
||||
while True:
|
||||
try:
|
||||
with get_db_session() as db:
|
||||
run_scheduled_notifications(db)
|
||||
except Exception as e:
|
||||
config.logger.error(f"Scheduler error: {e}")
|
||||
|
||||
# Check every 60 seconds
|
||||
await asyncio.sleep(60)
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
"""Initialize database on startup"""
|
||||
@@ -72,6 +89,9 @@ async def lifespan(app: FastAPI):
|
||||
|
||||
log(f"feedback: App reachable via Caddy at {reachable_url}")
|
||||
|
||||
# Start scheduler
|
||||
asyncio.create_task(scheduler_task())
|
||||
|
||||
yield
|
||||
log("Shutting down Parking Manager application")
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ def is_admin_from_groups(groups: list[str]) -> bool:
|
||||
if not is_admin:
|
||||
is_admin = admin_group.lower() in [g.lower() for g in groups]
|
||||
|
||||
print(f"[Authelia] Admin Check: User Groups={groups}, Configured Admin Group='{admin_group}' -> Is Admin? {is_admin}")
|
||||
return is_admin
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user