banners

Banners domain.

class Banner[source]

Bases: AuditBase

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

created_at: Mapped[datetime.datetime]

Date/time of instance creation.

id: Mapped[UUID]

UUID Primary key column.

updated_at: Mapped[datetime.datetime]

Date/time of instance last update.

class BannerController[source]

Bases: Controller

Controller for Banner CRUD operations.

after_request: AfterRequestHookHandler | None

A sync or async function executed before a Request is passed to any route handler.

If this function returns a value, the request will not reach the route handler, and instead this value will be used.

after_response: AfterResponseHookHandler | None

A sync or async function called after the response has been awaited.

It receives the Request instance and should not return any values.

before_request: BeforeRequestHookHandler | None

A sync or async function called immediately before calling the route handler.

It receives the Request instance and any non-None return value is used for the response, bypassing the route handler.

cache_control: CacheControlHeader | None

A CacheControlHeader header to add to route handlers of this controller.

Can be overridden by route handlers.

dependencies: Dependencies | None

A string keyed dictionary of dependency Provider instances.

dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for (de)serializing and validation of request data.

etag: ETag | None

An etag header of type ETag to add to route handlers of this controller.

Can be overridden by route handlers.

exception_handlers: ExceptionHandlersMap | None

A map of handler functions to status codes and/or exception types.

guards: Sequence[Guard] | None

A sequence of Guard callables.

include_in_schema: bool | EmptyType

A boolean flag dictating whether the route handler should be documented in the OpenAPI schema

middleware: Sequence[Middleware] | None

A sequence of Middleware.

opt: Mapping[str, Any] | None

A string key mapping of arbitrary values that can be accessed in Guards or wherever you have access to Request or ASGI Scope.

owner: Router

The Router or Litestar app that owns the controller.

This value is set internally by Litestar and it should not be set when subclassing the controller.

parameters: ParametersMap | None

A mapping of Parameter definitions available to all application paths.

path: str

A path fragment for the controller.

All route handlers under the controller will have the fragment appended to them. If not set it defaults to /.

request_class: type[Request] | None

A custom subclass of Request to be used as the default request for all route handlers under the controller.

request_max_body_size: int | None | EmptyType

Maximum allowed size of the request body in bytes. If this size is exceeded, a ‘413 - Request Entity Too Large’ error response is returned.

response_class: type[Response] | None

A custom subclass of Response to be used as the default response for all route handlers under the controller.

response_cookies: ResponseCookies | None

A list of Cookie instances.

response_headers: ResponseHeaders | None

A string keyed dictionary mapping ResponseHeader instances.

return_dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for serializing outbound response data.

security: Sequence[SecurityRequirement] | None

A sequence of dictionaries that to the schema of all route handlers under the controller.

signature_namespace: dict[str, Any]

A mapping of names to types for use in forward reference resolution during signature modelling.

signature_types: Sequence[Any]

A sequence of types for use in forward reference resolution during signature modelling.

These types will be added to the signature namespace using their __name__ attribute.

tags: Sequence[str] | None

A sequence of string tags that will be appended to the schema of all route handlers under the controller.

type_decoders: TypeDecodersSequence | None

A sequence of tuples, each composed of a predicate testing for type identity and a msgspec hook for deserialization.

type_encoders: TypeEncodersMap | None

A mapping of types to callables that transform them into types supported for serialization.

websocket_class: type[WebSocket] | None

A custom subclass of WebSocket to be used as the default websocket for all route handlers under the controller.

class BannerCreate[source]

Bases: BannerBase

Schema for creating a new Banner.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class BannerList[source]

Bases: BaseModel

Schema for Banner list items.

model_config: ClassVar[ConfigDict] = {'from_attributes': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class BannerRead[source]

Bases: BannerBase

Schema for reading Banner data.

model_config: ClassVar[ConfigDict] = {'from_attributes': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class BannerRepository[source]

Bases: SQLAlchemyAsyncRepository[Banner]

Repository for Banner database operations.

async get_active_banners(current_date=None)[source]

Get active banners.

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active banners.

async get_api_banners(current_date=None)[source]

Get active banners for API routes (sitewide OR target=api).

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active API banners.

async get_by_name(name)[source]

Get a banner by name.

Parameters:

name (str) – The banner name to search for.

Return type:

Banner | None

Returns:

The banner if found, None otherwise.

async get_frontend_banners(current_date=None)[source]

Get active banners for frontend pages (sitewide OR target=frontend).

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active frontend banners.

async get_sitewide_banners(current_date=None)[source]

Get active sitewide banners (is_sitewide=True).

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active sitewide banners.

model_type

alias of Banner

class BannerService[source]

Bases: SQLAlchemyAsyncRepositoryService[Banner, Any]

Service for Banner business logic.

async get_active_banners(current_date=None)[source]

Get active banners.

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active banners.

async get_api_banners(current_date=None)[source]

Get active banners for API routes.

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active API banners.

async get_by_name(name)[source]

Get a banner by name.

Parameters:

name (str) – The banner name to search for.

Return type:

Banner | None

Returns:

The banner if found, None otherwise.

async get_frontend_banners(current_date=None)[source]

Get active banners for frontend pages.

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active frontend banners.

async get_sitewide_banners(current_date=None)[source]

Get active sitewide banners.

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active sitewide banners.

repository_type

alias of BannerRepository

class BannerUpdate[source]

Bases: BaseModel

Schema for updating a Banner.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class BannersPageController[source]

Bases: Controller

Controller for banners HTML pages (admin preview).

after_request: AfterRequestHookHandler | None

A sync or async function executed before a Request is passed to any route handler.

If this function returns a value, the request will not reach the route handler, and instead this value will be used.

after_response: AfterResponseHookHandler | None

A sync or async function called after the response has been awaited.

It receives the Request instance and should not return any values.

before_request: BeforeRequestHookHandler | None

A sync or async function called immediately before calling the route handler.

It receives the Request instance and any non-None return value is used for the response, bypassing the route handler.

cache_control: CacheControlHeader | None

A CacheControlHeader header to add to route handlers of this controller.

Can be overridden by route handlers.

dependencies: Dependencies | None

A string keyed dictionary of dependency Provider instances.

dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for (de)serializing and validation of request data.

etag: ETag | None

An etag header of type ETag to add to route handlers of this controller.

Can be overridden by route handlers.

exception_handlers: ExceptionHandlersMap | None

A map of handler functions to status codes and/or exception types.

guards: Sequence[Guard] | None

A sequence of Guard callables.

include_in_schema: bool | EmptyType

A boolean flag dictating whether the route handler should be documented in the OpenAPI schema

middleware: Sequence[Middleware] | None

A sequence of Middleware.

opt: Mapping[str, Any] | None

A string key mapping of arbitrary values that can be accessed in Guards or wherever you have access to Request or ASGI Scope.

owner: Router

The Router or Litestar app that owns the controller.

This value is set internally by Litestar and it should not be set when subclassing the controller.

parameters: ParametersMap | None

A mapping of Parameter definitions available to all application paths.

path: str

A path fragment for the controller.

All route handlers under the controller will have the fragment appended to them. If not set it defaults to /.

request_class: type[Request] | None

A custom subclass of Request to be used as the default request for all route handlers under the controller.

request_max_body_size: int | None | EmptyType

Maximum allowed size of the request body in bytes. If this size is exceeded, a ‘413 - Request Entity Too Large’ error response is returned.

response_class: type[Response] | None

A custom subclass of Response to be used as the default response for all route handlers under the controller.

response_cookies: ResponseCookies | None

A list of Cookie instances.

response_headers: ResponseHeaders | None

A string keyed dictionary mapping ResponseHeader instances.

return_dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for serializing outbound response data.

security: Sequence[SecurityRequirement] | None

A sequence of dictionaries that to the schema of all route handlers under the controller.

signature_namespace: dict[str, Any]

A mapping of names to types for use in forward reference resolution during signature modelling.

signature_types: Sequence[Any]

A sequence of types for use in forward reference resolution during signature modelling.

These types will be added to the signature namespace using their __name__ attribute.

tags: Sequence[str] | None

A sequence of string tags that will be appended to the schema of all route handlers under the controller.

type_decoders: TypeDecodersSequence | None

A sequence of tuples, each composed of a predicate testing for type identity and a msgspec hook for deserialization.

type_encoders: TypeEncodersMap | None

A mapping of types to callables that transform them into types supported for serialization.

websocket_class: type[WebSocket] | None

A custom subclass of WebSocket to be used as the default websocket for all route handlers under the controller.

get_banners_dependencies()[source]

Get all banners domain dependency providers.

Return type:

dict

models

Banners domain models.

class BannerType[source]

Bases: str, Enum

Banner display type for styling.

__new__(value)
class BannerTarget[source]

Bases: str, Enum

Where the banner should be displayed when not sitewide.

__new__(value)
class Banner[source]

Bases: AuditBase

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

created_at: Mapped[datetime.datetime]

Date/time of instance creation.

id: Mapped[UUID]

UUID Primary key column.

updated_at: Mapped[datetime.datetime]

Date/time of instance last update.

schemas

Banners domain Pydantic schemas.

class BannerTypeEnum[source]

Bases: str, Enum

Banner display type for styling.

__new__(value)
class BannerBase[source]

Bases: BaseModel

Base Banner schema with common fields.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class BannerCreate[source]

Bases: BannerBase

Schema for creating a new Banner.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class BannerUpdate[source]

Bases: BaseModel

Schema for updating a Banner.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class BannerRead[source]

Bases: BannerBase

Schema for reading Banner data.

model_config: ClassVar[ConfigDict] = {'from_attributes': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class BannerList[source]

Bases: BaseModel

Schema for Banner list items.

model_config: ClassVar[ConfigDict] = {'from_attributes': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class BannerSitewideRead[source]

Bases: BaseModel

Schema for reading sitewide banner data (minimal for frontend).

model_config: ClassVar[ConfigDict] = {'from_attributes': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

services

Banners domain services for business logic.

class BannerService[source]

Bases: SQLAlchemyAsyncRepositoryService[Banner, Any]

Service for Banner business logic.

repository_type

alias of BannerRepository

async get_active_banners(current_date=None)[source]

Get active banners.

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active banners.

async get_sitewide_banners(current_date=None)[source]

Get active sitewide banners.

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active sitewide banners.

async get_frontend_banners(current_date=None)[source]

Get active banners for frontend pages.

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active frontend banners.

async get_api_banners(current_date=None)[source]

Get active banners for API routes.

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active API banners.

async get_by_name(name)[source]

Get a banner by name.

Parameters:

name (str) – The banner name to search for.

Return type:

Banner | None

Returns:

The banner if found, None otherwise.

controllers

Banners domain API and page controllers.

class BannerController[source]

Bases: Controller

Controller for Banner CRUD operations.

path: str

A path fragment for the controller.

All route handlers under the controller will have the fragment appended to them. If not set it defaults to /.

tags: Sequence[str] | None

A sequence of string tags that will be appended to the schema of all route handlers under the controller.

after_request: AfterRequestHookHandler | None

A sync or async function executed before a Request is passed to any route handler.

If this function returns a value, the request will not reach the route handler, and instead this value will be used.

after_response: AfterResponseHookHandler | None

A sync or async function called after the response has been awaited.

It receives the Request instance and should not return any values.

before_request: BeforeRequestHookHandler | None

A sync or async function called immediately before calling the route handler.

It receives the Request instance and any non-None return value is used for the response, bypassing the route handler.

cache_control: CacheControlHeader | None

A CacheControlHeader header to add to route handlers of this controller.

Can be overridden by route handlers.

dependencies: Dependencies | None

A string keyed dictionary of dependency Provider instances.

dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for (de)serializing and validation of request data.

etag: ETag | None

An etag header of type ETag to add to route handlers of this controller.

Can be overridden by route handlers.

exception_handlers: ExceptionHandlersMap | None

A map of handler functions to status codes and/or exception types.

guards: Sequence[Guard] | None

A sequence of Guard callables.

include_in_schema: bool | EmptyType

A boolean flag dictating whether the route handler should be documented in the OpenAPI schema

middleware: Sequence[Middleware] | None

A sequence of Middleware.

opt: Mapping[str, Any] | None

A string key mapping of arbitrary values that can be accessed in Guards or wherever you have access to Request or ASGI Scope.

owner: Router

The Router or Litestar app that owns the controller.

This value is set internally by Litestar and it should not be set when subclassing the controller.

parameters: ParametersMap | None

A mapping of Parameter definitions available to all application paths.

request_class: type[Request] | None

A custom subclass of Request to be used as the default request for all route handlers under the controller.

request_max_body_size: int | None | EmptyType

Maximum allowed size of the request body in bytes. If this size is exceeded, a ‘413 - Request Entity Too Large’ error response is returned.

response_class: type[Response] | None

A custom subclass of Response to be used as the default response for all route handlers under the controller.

response_cookies: ResponseCookies | None

A list of Cookie instances.

response_headers: ResponseHeaders | None

A string keyed dictionary mapping ResponseHeader instances.

return_dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for serializing outbound response data.

security: Sequence[SecurityRequirement] | None

A sequence of dictionaries that to the schema of all route handlers under the controller.

signature_namespace: dict[str, Any]

A mapping of names to types for use in forward reference resolution during signature modelling.

signature_types: Sequence[Any]

A sequence of types for use in forward reference resolution during signature modelling.

These types will be added to the signature namespace using their __name__ attribute.

type_decoders: TypeDecodersSequence | None

A sequence of tuples, each composed of a predicate testing for type identity and a msgspec hook for deserialization.

type_encoders: TypeEncodersMap | None

A mapping of types to callables that transform them into types supported for serialization.

websocket_class: type[WebSocket] | None

A custom subclass of WebSocket to be used as the default websocket for all route handlers under the controller.

class BannersPageController[source]

Bases: Controller

Controller for banners HTML pages (admin preview).

path: str

A path fragment for the controller.

All route handlers under the controller will have the fragment appended to them. If not set it defaults to /.

include_in_schema: bool | EmptyType

A boolean flag dictating whether the route handler should be documented in the OpenAPI schema

after_request: AfterRequestHookHandler | None

A sync or async function executed before a Request is passed to any route handler.

If this function returns a value, the request will not reach the route handler, and instead this value will be used.

after_response: AfterResponseHookHandler | None

A sync or async function called after the response has been awaited.

It receives the Request instance and should not return any values.

before_request: BeforeRequestHookHandler | None

A sync or async function called immediately before calling the route handler.

It receives the Request instance and any non-None return value is used for the response, bypassing the route handler.

cache_control: CacheControlHeader | None

A CacheControlHeader header to add to route handlers of this controller.

Can be overridden by route handlers.

dependencies: Dependencies | None

A string keyed dictionary of dependency Provider instances.

dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for (de)serializing and validation of request data.

etag: ETag | None

An etag header of type ETag to add to route handlers of this controller.

Can be overridden by route handlers.

exception_handlers: ExceptionHandlersMap | None

A map of handler functions to status codes and/or exception types.

guards: Sequence[Guard] | None

A sequence of Guard callables.

middleware: Sequence[Middleware] | None

A sequence of Middleware.

opt: Mapping[str, Any] | None

A string key mapping of arbitrary values that can be accessed in Guards or wherever you have access to Request or ASGI Scope.

owner: Router

The Router or Litestar app that owns the controller.

This value is set internally by Litestar and it should not be set when subclassing the controller.

parameters: ParametersMap | None

A mapping of Parameter definitions available to all application paths.

request_class: type[Request] | None

A custom subclass of Request to be used as the default request for all route handlers under the controller.

request_max_body_size: int | None | EmptyType

Maximum allowed size of the request body in bytes. If this size is exceeded, a ‘413 - Request Entity Too Large’ error response is returned.

response_class: type[Response] | None

A custom subclass of Response to be used as the default response for all route handlers under the controller.

response_cookies: ResponseCookies | None

A list of Cookie instances.

response_headers: ResponseHeaders | None

A string keyed dictionary mapping ResponseHeader instances.

return_dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for serializing outbound response data.

security: Sequence[SecurityRequirement] | None

A sequence of dictionaries that to the schema of all route handlers under the controller.

signature_namespace: dict[str, Any]

A mapping of names to types for use in forward reference resolution during signature modelling.

signature_types: Sequence[Any]

A sequence of types for use in forward reference resolution during signature modelling.

These types will be added to the signature namespace using their __name__ attribute.

tags: Sequence[str] | None

A sequence of string tags that will be appended to the schema of all route handlers under the controller.

type_decoders: TypeDecodersSequence | None

A sequence of tuples, each composed of a predicate testing for type identity and a msgspec hook for deserialization.

type_encoders: TypeEncodersMap | None

A mapping of types to callables that transform them into types supported for serialization.

websocket_class: type[WebSocket] | None

A custom subclass of WebSocket to be used as the default websocket for all route handlers under the controller.

repositories

Banners domain repositories for database access.

class BannerRepository[source]

Bases: SQLAlchemyAsyncRepository[Banner]

Repository for Banner database operations.

model_type

alias of Banner

async get_active_banners(current_date=None)[source]

Get active banners.

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active banners.

async get_sitewide_banners(current_date=None)[source]

Get active sitewide banners (is_sitewide=True).

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active sitewide banners.

async get_frontend_banners(current_date=None)[source]

Get active banners for frontend pages (sitewide OR target=frontend).

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active frontend banners.

async get_api_banners(current_date=None)[source]

Get active banners for API routes (sitewide OR target=api).

Parameters:

current_date (date | None) – The date to check against. If None, only checks is_active flag.

Return type:

list[Banner]

Returns:

List of active API banners.

async get_by_name(name)[source]

Get a banner by name.

Parameters:

name (str) – The banner name to search for.

Return type:

Banner | None

Returns:

The banner if found, None otherwise.