
Some checks failed
Deploy to Production, build images and push to Gitea Registry / build_and_push (pull_request) Failing after 1m24s
This commit adds new guidelines for FastAPI and Vue.js development, emphasizing best practices for component structure, API performance, and data handling. It also introduces caching mechanisms using Redis for improved performance and updates the API structure to streamline authentication and user management. Additionally, new endpoints for categories and time entries are implemented, enhancing the overall functionality of the application.
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
from fastapi import APIRouter, Depends, HTTPException, status
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from typing import List
|
|
|
|
from app import models
|
|
from app.schemas.audit import FinancialAuditLogPublic
|
|
from app.database import get_session
|
|
from app.auth import current_active_user
|
|
from app.crud import audit as crud_audit, group as crud_group
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/financial/group/{group_id}", response_model=List[FinancialAuditLogPublic])
|
|
async def read_financial_history_for_group(
|
|
group_id: int,
|
|
db: AsyncSession = Depends(get_session),
|
|
current_user: models.User = Depends(current_active_user),
|
|
skip: int = 0,
|
|
limit: int = 100,
|
|
):
|
|
"""
|
|
Retrieve financial audit history for a specific group.
|
|
"""
|
|
is_member = await crud_group.is_user_member(db, group_id=group_id, user_id=current_user.id)
|
|
if not is_member:
|
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Not a member of this group")
|
|
|
|
history = await crud_audit.get_financial_audit_logs_for_group(
|
|
db=db, group_id=group_id, skip=skip, limit=limit
|
|
)
|
|
return history
|
|
|
|
@router.get("/financial/user/me", response_model=List[FinancialAuditLogPublic])
|
|
async def read_financial_history_for_user(
|
|
db: AsyncSession = Depends(get_session),
|
|
current_user: models.User = Depends(current_active_user),
|
|
skip: int = 0,
|
|
limit: int = 100,
|
|
):
|
|
"""
|
|
Retrieve financial audit history for the current user.
|
|
"""
|
|
history = await crud_audit.get_financial_audit_logs_for_user(
|
|
db=db, user_id=current_user.id, skip=skip, limit=limit
|
|
)
|
|
return history |