Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/core/associations/endpoints_associations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import uuid

from fastapi import APIRouter, Depends, HTTPException, UploadFile
from fastapi import APIRouter, Depends, HTTPException
from fastapi.responses import FileResponse
from sqlalchemy.ext.asyncio import AsyncSession

Expand All @@ -19,6 +19,7 @@
)
from app.types.content_type import ContentType
from app.types.module import CoreModule
from app.types.upload import FILE_RESPONSE, UploadFile
from app.utils.tools import (
compress_and_save_image_file,
get_file_from_data,
Expand Down Expand Up @@ -195,6 +196,7 @@ async def create_association_logo(
@router.get(
"/associations/{association_id}/logo",
response_class=FileResponse,
responses=FILE_RESPONSE,
status_code=200,
)
async def read_association_logo(
Expand Down
2 changes: 2 additions & 0 deletions app/core/core_endpoints/endpoints_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
get_settings,
)
from app.types.module import CoreModule
from app.types.upload import FILE_RESPONSE
from app.utils.tools import patch_identity_in_text

router = APIRouter(tags=["Core"])
Expand Down Expand Up @@ -197,6 +198,7 @@ async def get_variables(settings: Settings = Depends(get_settings)):
@router.get(
"/favicon.ico",
response_class=FileResponse,
responses=FILE_RESPONSE,
status_code=200,
)
async def get_favicon():
Expand Down
2 changes: 2 additions & 0 deletions app/core/feed/endpoints_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
is_user_allowed_to,
)
from app.types.module import CoreModule
from app.types.upload import FILE_RESPONSE
from app.utils.tools import get_file_from_data

router = APIRouter(tags=["Feed"])
Expand Down Expand Up @@ -51,6 +52,7 @@ async def get_published_news(
@router.get(
"/feed/news/{news_id}/image",
response_class=FileResponse,
responses=FILE_RESPONSE,
status_code=200,
)
async def get_news_image(
Expand Down
4 changes: 3 additions & 1 deletion app/core/groups/endpoints_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging
import uuid

from fastapi import APIRouter, Depends, HTTPException, UploadFile
from fastapi import APIRouter, Depends, HTTPException
from fastapi.responses import FileResponse
from sqlalchemy.ext.asyncio import AsyncSession

Expand All @@ -25,6 +25,7 @@
)
from app.types.content_type import ContentType
from app.types.module import CoreModule
from app.types.upload import FILE_RESPONSE, UploadFile
from app.utils.communication.notifications import NotificationManager
from app.utils.tools import (
compress_and_save_image_file,
Expand Down Expand Up @@ -393,6 +394,7 @@ async def create_group_logo(
@router.get(
"/groups/{group_id}/logo",
response_class=FileResponse,
responses=FILE_RESPONSE,
status_code=200,
)
async def read_user_profile_picture(
Expand Down
2 changes: 2 additions & 0 deletions app/core/mypayment/endpoints_mypayment.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
from app.types.exceptions import ObjectExpectedInDbNotFoundError
from app.types.module import CoreModule
from app.types.scopes_type import ScopeType
from app.types.upload import FILE_RESPONSE
from app.utils.auth.auth_utils import get_user_id_from_token_with_scopes
from app.utils.communication.notifications import NotificationTool
from app.utils.mail.mailworker import send_email
Expand Down Expand Up @@ -3083,6 +3084,7 @@ async def get_structure_invoices(
@router.get(
"/mypayment/invoices/{invoice_id}",
response_class=FileResponse,
responses=FILE_RESPONSE,
)
async def download_invoice(
invoice_id: UUID,
Expand Down
12 changes: 11 additions & 1 deletion app/core/mypayment/schemas_mypayment.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from datetime import datetime
from typing import Annotated
from uuid import UUID

from pydantic import (
BaseModel,
Field,
WithJsonSchema,
model_validator,
)

Expand Down Expand Up @@ -209,7 +211,15 @@ class WalletDevice(WalletDeviceBase):


class WalletDeviceCreation(WalletDeviceBase):
ed25519_public_key: bytes
# A `bytes` field serializes to the JSON Schema 2020-12 form
# `{"type": "string", "contentMediaType": "application/octet-stream"}`, which
# breaks OpenAPI/Swagger client generators. The value is a base64-encoded
# public key (decoded in the endpoint), so we describe it as an OAS base64
# string instead.
ed25519_public_key: Annotated[
bytes,
WithJsonSchema({"type": "string", "format": "byte"}),
]


class TransactionBase(BaseModel):
Expand Down
2 changes: 2 additions & 0 deletions app/core/tickets/endpoints_tickets.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
)
from app.types.exceptions import ObjectExpectedInDbNotFoundError
from app.types.module import CoreModule
from app.types.upload import FILE_RESPONSE
from app.utils.communication.notifications import NotificationTool
from app.utils.mail.mailworker import send_email

Expand Down Expand Up @@ -1121,6 +1122,7 @@ async def get_event_tickets(
@router.get(
"/tickets/admin/events/{event_id}/tickets/csv",
response_class=FileResponse,
responses=FILE_RESPONSE,
status_code=200,
)
async def get_event_tickets_csv(
Expand Down
7 changes: 4 additions & 3 deletions app/core/users/endpoints_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
BackgroundTasks,
Body,
Depends,
File,
HTTPException,
Query,
UploadFile,
)
from fastapi.responses import FileResponse, RedirectResponse
from sqlalchemy.ext.asyncio import AsyncSession
Expand Down Expand Up @@ -45,6 +43,7 @@
from app.types.exceptions import UserWithEmailAlreadyExistError
from app.types.module import CoreModule
from app.types.s3_access import S3Access
from app.types.upload import FILE_RESPONSE, UploadFile
from app.utils.communication.notifications import NotificationManager
from app.utils.mail.mailworker import send_email
from app.utils.tools import (
Expand Down Expand Up @@ -1105,7 +1104,7 @@ async def update_user_as_super_admin(
status_code=201,
)
async def create_current_user_profile_picture(
image: UploadFile = File(...),
image: UploadFile,
user: models_users.CoreUser = Depends(is_user()),
):
"""
Expand Down Expand Up @@ -1135,6 +1134,7 @@ async def create_current_user_profile_picture(
@router.get(
"/users/me/profile-picture",
response_class=FileResponse,
responses=FILE_RESPONSE,
status_code=200,
)
async def read_own_profile_picture(
Expand All @@ -1154,6 +1154,7 @@ async def read_own_profile_picture(
@router.get(
"/users/{user_id}/profile-picture",
response_class=FileResponse,
responses=FILE_RESPONSE,
status_code=200,
)
async def read_user_profile_picture(
Expand Down
10 changes: 10 additions & 0 deletions app/core/users/factory_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ async def create_core_users(cls, db: AsyncSession):
)
await cruds_users.create_user(db=db, user=user)
for group in user_info.groups:
# A demo user may reference a group that does not exist in the
# database (e.g. a group only created by a later migration).
# We skip those memberships instead of failing the whole factory.
if await cruds_groups.get_group_by_id(db=db, group_id=group) is None:
hyperion_error_logger.warning(
"Skipping membership for demo user %s: group %s does not exist",
user.email,
group,
)
continue
await cruds_groups.create_membership(
db=db,
membership=CoreMembership(
Expand Down
6 changes: 4 additions & 2 deletions app/modules/advert/endpoints_advert.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import uuid
from datetime import UTC, datetime

from fastapi import Depends, File, HTTPException, Query, UploadFile
from fastapi import Depends, HTTPException, Query
from fastapi.responses import FileResponse
from sqlalchemy.ext.asyncio import AsyncSession

Expand All @@ -27,6 +27,7 @@
from app.modules.advert.factory_advert import AdvertFactory
from app.types.content_type import ContentType
from app.types.module import Module
from app.types.upload import FILE_RESPONSE, UploadFile
from app.utils.communication.notifications import NotificationManager, NotificationTool
from app.utils.tools import (
compress_and_save_image_file,
Expand Down Expand Up @@ -284,6 +285,7 @@ async def delete_advert(
@module.router.get(
"/advert/adverts/{advert_id}/picture",
response_class=FileResponse,
responses=FILE_RESPONSE,
status_code=200,
)
async def read_advert_image(
Expand Down Expand Up @@ -318,7 +320,7 @@ async def read_advert_image(
)
async def create_advert_image(
advert_id: uuid.UUID,
image: UploadFile = File(...),
image: UploadFile,
user: models_users.CoreUser = Depends(
is_user_allowed_to([AdvertPermissions.access_adverts]),
),
Expand Down
7 changes: 5 additions & 2 deletions app/modules/calendar/endpoints_calendar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import uuid
from datetime import UTC, datetime

from fastapi import Depends, File, HTTPException, UploadFile
from fastapi import Depends, HTTPException
from fastapi.responses import FileResponse
from sqlalchemy.ext.asyncio import AsyncSession

Expand Down Expand Up @@ -37,6 +37,7 @@
from app.types.content_type import ContentType
from app.types.exceptions import NewlyAddedObjectInDbNotFoundError
from app.types.module import Module
from app.types.upload import FILE_RESPONSE, UploadFile
from app.utils.communication.notifications import NotificationManager, NotificationTool
from app.utils.tools import (
compress_and_save_image_file,
Expand Down Expand Up @@ -189,6 +190,7 @@ async def get_event_ticket_url(
@module.router.get(
"/calendar/events/{event_id}/image",
response_class=FileResponse,
responses=FILE_RESPONSE,
status_code=200,
)
async def get_event_image(
Expand Down Expand Up @@ -237,7 +239,7 @@ async def get_event_image(
)
async def create_event_image(
event_id: uuid.UUID,
image: UploadFile = File(...),
image: UploadFile,
user: models_users.CoreUser = Depends(
is_user_allowed_to([CalendarPermissions.access_calendar]),
),
Expand Down Expand Up @@ -732,6 +734,7 @@ async def recreate_ical_file(
@module.router.get(
"/calendar/ical",
response_class=FileResponse,
responses=FILE_RESPONSE,
status_code=200,
)
async def get_icalendar_file(
Expand Down
6 changes: 4 additions & 2 deletions app/modules/campaign/endpoints_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import UTC, datetime

from anyio import Path
from fastapi import Depends, File, HTTPException, UploadFile
from fastapi import Depends, HTTPException
from fastapi.responses import FileResponse
from sqlalchemy.ext.asyncio import AsyncSession

Expand All @@ -27,6 +27,7 @@
from app.types import standard_responses
from app.types.content_type import ContentType
from app.types.module import Module
from app.types.upload import FILE_RESPONSE, UploadFile
from app.utils.tools import (
compress_and_save_image_file,
get_file_from_data,
Expand Down Expand Up @@ -824,7 +825,7 @@ async def get_stats_for_section(
)
async def create_campaigns_logo(
list_id: str,
image: UploadFile = File(...),
image: UploadFile,
user: models_users.CoreUser = Depends(
is_user_allowed_to([CampaignPermissions.manage_campaign]),
),
Expand Down Expand Up @@ -872,6 +873,7 @@ async def create_campaigns_logo(
@module.router.get(
"/campaign/lists/{list_id}/logo",
response_class=FileResponse,
responses=FILE_RESPONSE,
status_code=200,
)
async def read_campaigns_logo(
Expand Down
2 changes: 2 additions & 0 deletions app/modules/cdr/endpoints_cdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
)
from app.types.exceptions import ObjectExpectedInDbNotFoundError
from app.types.module import Module
from app.types.upload import FILE_RESPONSE
from app.types.websocket import (
HyperionWebsocketsRoom,
WebsocketConnectionManager,
Expand Down Expand Up @@ -539,6 +540,7 @@ async def generate_and_send_results(
"/cdr/sellers/{seller_id}/results/",
status_code=200,
response_class=FileResponse,
responses=FILE_RESPONSE,
)
async def send_seller_results(
seller_id: UUID,
Expand Down
6 changes: 4 additions & 2 deletions app/modules/cinema/endpoints_cinema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import UTC, datetime, timedelta

import httpx
from fastapi import Depends, File, HTTPException, UploadFile
from fastapi import Depends, HTTPException
from fastapi.responses import FileResponse
from sqlalchemy.ext.asyncio import AsyncSession

Expand All @@ -25,6 +25,7 @@
from app.types.content_type import ContentType
from app.types.module import Module
from app.types.scheduler import Scheduler
from app.types.upload import FILE_RESPONSE, UploadFile
from app.utils.communication.date_manager import (
get_date_day,
get_date_month,
Expand Down Expand Up @@ -224,7 +225,7 @@ async def delete_session(
)
async def create_campaigns_logo(
session_id: str,
image: UploadFile = File(...),
image: UploadFile,
user: models_users.CoreUser = Depends(
is_user_allowed_to([CinemaPermissions.manage_sessions]),
),
Expand Down Expand Up @@ -259,6 +260,7 @@ async def create_campaigns_logo(
@module.router.get(
"/cinema/sessions/{session_id}/poster",
response_class=FileResponse,
responses=FILE_RESPONSE,
status_code=200,
)
async def read_session_poster(
Expand Down
6 changes: 4 additions & 2 deletions app/modules/ph/endpoints_ph.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import uuid
from datetime import UTC, datetime, time, timedelta

from fastapi import Depends, File, HTTPException, UploadFile
from fastapi import Depends, HTTPException
from fastapi.responses import FileResponse
from sqlalchemy.ext.asyncio import AsyncSession

Expand All @@ -20,6 +20,7 @@
from app.types.content_type import ContentType
from app.types.module import Module
from app.types.scheduler import Scheduler
from app.types.upload import FILE_RESPONSE, UploadFile
from app.utils.communication.notifications import NotificationTool
from app.utils.tools import (
delete_file_from_data,
Expand Down Expand Up @@ -57,6 +58,7 @@ class PHPermissions(ModulePermissions):
@module.router.get(
"/ph/{paper_id}/pdf",
response_class=FileResponse,
responses=FILE_RESPONSE,
status_code=200,
)
async def get_paper_pdf(
Expand Down Expand Up @@ -179,7 +181,7 @@ async def create_paper(
)
async def create_paper_pdf_and_cover(
paper_id: uuid.UUID,
pdf: UploadFile = File(...),
pdf: UploadFile,
user: models_users.CoreUser = Depends(
is_user_allowed_to([PHPermissions.manage_ph]),
),
Expand Down
Loading
Loading