repository.images#

Module Contents#

Functions#

access_check

Check if the user has access rights to a specific picture based on user ID and role.

upload_picture

Upload a new picture to the database.

delete_picture

Delete a specific picture from the database.

update_picture_description

Update the description of a specific picture in the database.

get_picture

Retrieve information about a specific picture from the database.

API#

async repository.images.access_check(user: src.entity.models.User, picture_user_id, role)#

Check if the user has access rights to a specific picture based on user ID and role.

Parameters:
  • user (User) – The user making the access check.

  • picture_user_id (int) – The user ID associated with the picture.

  • role (Role) – The role of the user making the access check.

Returns:

True if the user has access, False otherwise.

Return type:

bool

async repository.images.upload_picture(file: fastapi.UploadFile, body: src.schemas.images.PictureSchema, db: sqlalchemy.ext.asyncio.AsyncSession, user: src.entity.models.User)#

Upload a new picture to the database.

Parameters:
  • file (UploadFile) – The file to be uploaded.

  • body (PictureSchema) – The schema representing the picture data.

  • db (AsyncSession) – The asynchronous database session.

  • user (User) – The user uploading the picture.

Returns:

Information about the uploaded picture.

Return type:

Dict[str, Union[int, str, List[str], datetime, List[str]]]

async repository.images.delete_picture(picture_id: int, db: sqlalchemy.ext.asyncio.AsyncSession, user: src.entity.models.User)#

Delete a specific picture from the database.

Parameters:
  • picture_id (int) – The ID of the picture to delete.

  • db (AsyncSession) – The asynchronous database session.

  • user (User) – The user deleting the picture.

Returns:

Success message.

Return type:

str

async repository.images.update_picture_description(picture_id: int, body: src.schemas.images.PictureUpdateSchema, db: sqlalchemy.ext.asyncio.AsyncSession, user: src.entity.models.User)#

Update the description of a specific picture in the database.

Parameters:
  • picture_id (int) – The ID of the picture to update.

  • body (PictureUpdateSchema) – The schema representing the updated picture data.

  • db (AsyncSession) – The asynchronous database session.

  • user (User) – The user updating the picture.

Returns:

Information about the updated picture.

Return type:

Dict[str, Union[int, str, List[str], datetime, List[str]]]

async repository.images.get_picture(picture_id: int, db: sqlalchemy.ext.asyncio.AsyncSession, user: src.entity.models.User)#

Retrieve information about a specific picture from the database.

Parameters:
  • picture_id (int) – The ID of the picture to retrieve.

  • db (AsyncSession) – The asynchronous database session.

  • user (User) – The user requesting information about the picture.

Returns:

Information about the picture.

Return type:

Dict[str, Union[int, str, List[str], datetime, List[str]]]