working version
This commit is contained in:
0
backend/api/routers/__init__.py
Normal file → Executable file
0
backend/api/routers/__init__.py
Normal file → Executable file
0
backend/api/routers/admin.py
Normal file → Executable file
0
backend/api/routers/admin.py
Normal file → Executable file
0
backend/api/routers/albums.py
Normal file → Executable file
0
backend/api/routers/albums.py
Normal file → Executable file
0
backend/api/routers/auth.py
Normal file → Executable file
0
backend/api/routers/auth.py
Normal file → Executable file
14
backend/api/routers/events.py
Normal file → Executable file
14
backend/api/routers/events.py
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy.orm import Session, joinedload
|
||||
from typing import List
|
||||
from datetime import datetime
|
||||
from config.database import get_db
|
||||
@@ -64,7 +64,7 @@ async def get_events(
|
||||
upcoming: bool = None
|
||||
):
|
||||
"""Get all events, optionally filtered by upcoming status."""
|
||||
query = db.query(Event)
|
||||
query = db.query(Event).options(joinedload(Event.creator))
|
||||
|
||||
if upcoming is True:
|
||||
# Only upcoming events
|
||||
@@ -83,7 +83,7 @@ async def get_upcoming_events(
|
||||
current_user: User = Depends(get_current_active_user)
|
||||
):
|
||||
"""Get only upcoming events."""
|
||||
events = db.query(Event).filter(
|
||||
events = db.query(Event).options(joinedload(Event.creator)).filter(
|
||||
Event.date >= datetime.utcnow()
|
||||
).order_by(Event.date).all()
|
||||
return [format_event_response(event, db) for event in events]
|
||||
@@ -94,7 +94,7 @@ async def get_past_events(
|
||||
current_user: User = Depends(get_current_active_user)
|
||||
):
|
||||
"""Get only past events."""
|
||||
events = db.query(Event).filter(
|
||||
events = db.query(Event).options(joinedload(Event.creator)).filter(
|
||||
Event.date < datetime.utcnow()
|
||||
).order_by(Event.date.desc()).all()
|
||||
return [format_event_response(event, db) for event in events]
|
||||
@@ -204,6 +204,9 @@ def format_event_response(event: Event, db: Session) -> dict:
|
||||
participations = []
|
||||
present_count = absent_count = maybe_count = pending_count = 0
|
||||
|
||||
# Get creator user directly
|
||||
creator = db.query(User).filter(User.id == event.creator_id).first()
|
||||
|
||||
for p in event.participations:
|
||||
user = db.query(User).filter(User.id == p.user_id).first()
|
||||
participations.append({
|
||||
@@ -235,7 +238,8 @@ def format_event_response(event: Event, db: Session) -> dict:
|
||||
"cover_image": event.cover_image,
|
||||
"created_at": event.created_at,
|
||||
"updated_at": event.updated_at,
|
||||
"creator_name": event.creator.full_name,
|
||||
"creator_name": creator.full_name if creator else "Unknown",
|
||||
"creator_avatar": creator.avatar_url if creator else None,
|
||||
"participations": participations,
|
||||
"present_count": present_count,
|
||||
"absent_count": absent_count,
|
||||
|
||||
0
backend/api/routers/information.py
Normal file → Executable file
0
backend/api/routers/information.py
Normal file → Executable file
0
backend/api/routers/notifications.py
Normal file → Executable file
0
backend/api/routers/notifications.py
Normal file → Executable file
0
backend/api/routers/posts.py
Normal file → Executable file
0
backend/api/routers/posts.py
Normal file → Executable file
24
backend/api/routers/settings.py
Normal file → Executable file
24
backend/api/routers/settings.py
Normal file → Executable file
@@ -40,7 +40,7 @@ async def get_upload_limits(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_admin_user)
|
||||
):
|
||||
"""Get current upload limits configuration."""
|
||||
"""Get current upload limits configuration (admin only)."""
|
||||
settings = db.query(SystemSettings).filter(
|
||||
SystemSettings.category == "uploads"
|
||||
).all()
|
||||
@@ -61,6 +61,28 @@ async def get_upload_limits(
|
||||
allowed_video_types=settings_dict.get("allowed_video_types", "video/mp4,video/mpeg,video/quicktime,video/webm").split(",")
|
||||
)
|
||||
|
||||
@router.get("/public/upload-limits", response_model=UploadLimitsResponse)
|
||||
async def get_public_upload_limits(
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""Get current upload limits configuration (public endpoint - no auth required)."""
|
||||
settings = db.query(SystemSettings).filter(
|
||||
SystemSettings.category == "uploads"
|
||||
).all()
|
||||
|
||||
# Convertir en dictionnaire pour faciliter l'accès
|
||||
settings_dict = {s.key: s.value for s in settings}
|
||||
|
||||
return UploadLimitsResponse(
|
||||
max_album_size_mb=int(settings_dict.get("max_album_size_mb", "100")),
|
||||
max_vlog_size_mb=int(settings_dict.get("max_vlog_size_mb", "500")),
|
||||
max_image_size_mb=int(settings_dict.get("max_image_size_mb", "10")),
|
||||
max_video_size_mb=int(settings_dict.get("max_video_size_mb", "100")),
|
||||
max_media_per_album=int(settings_dict.get("max_media_per_album", "50")),
|
||||
allowed_image_types=settings_dict.get("allowed_image_types", "image/jpeg,image/png,image/gif,image/webp").split(","),
|
||||
allowed_video_types=settings_dict.get("allowed_video_types", "video/mp4,video/mpeg,video/quicktime,video/webm").split(",")
|
||||
)
|
||||
|
||||
@router.post("/", response_model=SystemSettingResponse)
|
||||
async def create_setting(
|
||||
setting_data: SystemSettingCreate,
|
||||
|
||||
0
backend/api/routers/stats.py
Normal file → Executable file
0
backend/api/routers/stats.py
Normal file → Executable file
0
backend/api/routers/tickets.py
Normal file → Executable file
0
backend/api/routers/tickets.py
Normal file → Executable file
0
backend/api/routers/users.py
Normal file → Executable file
0
backend/api/routers/users.py
Normal file → Executable file
0
backend/api/routers/vlogs.py
Normal file → Executable file
0
backend/api/routers/vlogs.py
Normal file → Executable file
Reference in New Issue
Block a user