sponsors

Sponsors domain.

class Sponsor[source]

Bases: AuditBase, ContentManageableMixin, NameSlugMixin

__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: Mapped[datetime]
created_at: Mapped[datetime.datetime]

Date/time of instance creation.

creator
creator_id
id: Mapped[UUID]

UUID Primary key column.

last_modified_by
last_modified_by_id
name: Mapped[str]
slug: Mapped[str]
property tier: str

Get the tier name from the sponsor’s active sponsorship.

Returns the level slug from the first finalized sponsorship, or ‘community’ as a default if no active sponsorship exists.

updated: Mapped[datetime]
updated_at: Mapped[datetime.datetime]

Date/time of instance last update.

class SponsorApplicationCreate[source]

Bases: BaseModel

Schema for sponsor application form submission.

model_config: ClassVar[ConfigDict] = {'json_schema_extra': {'example': {'company_name': 'Acme Corp', 'contact_email': 'jane@acme.com', 'contact_name': 'Jane Doe', 'description': 'We love Python!', 'sponsorship_level': 'silver', 'website': 'https://acme.com'}}}

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

class SponsorController[source]

Bases: Controller

Controller for Sponsor 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 SponsorCreate[source]

Bases: BaseModel

Schema for creating a new sponsor.

model_config: ClassVar[ConfigDict] = {'json_schema_extra': {'example': {'city': 'Redmond', 'country': 'USA', 'description': 'Microsoft is a Visionary sponsor of the PSF', 'landing_page_url': 'https://microsoft.com', 'linked_in_page_url': 'https://linkedin.com/company/microsoft', 'name': 'Microsoft', 'postal_code': '98052', 'slug': 'microsoft', 'state': 'Washington', 'twitter_handle': 'Microsoft', 'web_logo': '/media/sponsors/microsoft-logo.png'}}}

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

class SponsorPublic[source]

Bases: BaseModel

Public sponsor schema.

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

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

class SponsorRead[source]

Bases: SponsorBase

Schema for reading sponsor data.

model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'json_schema_extra': {'example': {'city': 'Redmond', 'country': 'USA', 'country_of_incorporation': '', 'created': '2025-01-01T00:00:00Z', 'creator_id': '550e8400-e29b-41d4-a716-446655440000', 'description': 'Microsoft is a Visionary sponsor of the PSF', 'id': '550e8400-e29b-41d4-a716-446655440010', 'landing_page_url': 'https://microsoft.com', 'last_modified_by_id': None, 'linked_in_page_url': 'https://linkedin.com/company/microsoft', 'mailing_address_line_1': '', 'mailing_address_line_2': '', 'name': 'Microsoft', 'postal_code': '98052', 'primary_phone': '', 'print_logo': '', 'slug': 'microsoft', 'state': 'Washington', 'state_of_incorporation': '', 'twitter_handle': 'Microsoft', 'updated': '2025-01-01T00:00:00Z', 'web_logo': '/media/sponsors/microsoft-logo.png'}}}

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

class SponsorRenderController[source]

Bases: Controller

Controller for rendering sponsor pages as HTML.

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 SponsorRepository[source]

Bases: SQLAlchemyAsyncRepository[Sponsor]

Repository for Sponsor database operations.

async exists_by_slug(slug)[source]

Check if a sponsor exists by slug.

Parameters:

slug (str) – The slug to check.

Return type:

bool

Returns:

True if a sponsor with this slug exists, False otherwise.

async get_by_slug(slug)[source]

Get a sponsor by its slug.

Parameters:

slug (str) – The slug to search for.

Return type:

Sponsor | None

Returns:

The sponsor if found, None otherwise.

async list_with_active_sponsorships(limit=100, offset=0)[source]

List sponsors with active sponsorships.

Parameters:
  • limit (int) – Maximum number of sponsors to return.

  • offset (int) – Number of sponsors to skip.

Return type:

list[Sponsor]

Returns:

List of sponsors with active sponsorships, with sponsorships and levels loaded.

model_type

alias of Sponsor

class SponsorService[source]

Bases: SQLAlchemyAsyncRepositoryService[Sponsor, Any]

Service for Sponsor business logic.

async create_sponsor(data)[source]

Create a new sponsor.

Parameters:

data (SponsorCreate) – Sponsor creation data.

Return type:

Sponsor

Returns:

The created sponsor instance.

Raises:

ValueError – If slug already exists.

async get_by_slug(slug)[source]

Get a sponsor by its slug.

Parameters:

slug (str) – The slug to search for.

Return type:

Sponsor | None

Returns:

The sponsor if found, None otherwise.

async list_with_active_sponsorships(limit=100, offset=0)[source]

List sponsors with active sponsorships.

Parameters:
  • limit (int) – Maximum number of sponsors to return.

  • offset (int) – Number of sponsors to skip.

Return type:

list[Sponsor]

Returns:

List of sponsors with active sponsorships.

match_fields: ClassVar[Optional[Union[list[str], str]]] = ['slug']

List of dialects that prefer to use field.id = ANY(:1) instead of field.id IN (...).

repository_type

alias of SponsorRepository

class SponsorUpdate[source]

Bases: BaseModel

Schema for updating a sponsor.

model_config: ClassVar[ConfigDict] = {}

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

class Sponsorship[source]

Bases: AuditBase, ContentManageableMixin

__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: Mapped[datetime]
created_at: Mapped[datetime.datetime]

Date/time of instance creation.

creator
creator_id
id: Mapped[UUID]

UUID Primary key column.

last_modified_by
last_modified_by_id
updated: Mapped[datetime]
updated_at: Mapped[datetime.datetime]

Date/time of instance last update.

class SponsorshipController[source]

Bases: Controller

Controller for Sponsorship 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 SponsorshipCreate[source]

Bases: BaseModel

Schema for creating a new sponsorship.

model_config: ClassVar[ConfigDict] = {}

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

class SponsorshipLevel[source]

Bases: AuditBase, NameSlugMixin

__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.

name: Mapped[str]
slug: Mapped[str]
updated_at: Mapped[datetime.datetime]

Date/time of instance last update.

class SponsorshipLevelController[source]

Bases: Controller

Controller for SponsorshipLevel 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 SponsorshipLevelCreate[source]

Bases: BaseModel

Schema for creating a new sponsorship level.

model_config: ClassVar[ConfigDict] = {'json_schema_extra': {'example': {'logo_dimension': 200, 'name': 'Visionary', 'order': 1, 'slug': 'visionary', 'sponsorship_amount': 150000}}}

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

class SponsorshipLevelRead[source]

Bases: SponsorshipLevelBase

Schema for reading sponsorship level data.

model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'json_schema_extra': {'example': {'created_at': '2025-01-01T00:00:00Z', 'id': '550e8400-e29b-41d4-a716-446655440001', 'logo_dimension': 200, 'name': 'Visionary', 'order': 1, 'slug': 'visionary', 'sponsorship_amount': 150000, 'updated_at': '2025-01-01T00:00:00Z'}}}

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

class SponsorshipLevelRepository[source]

Bases: SQLAlchemyAsyncRepository[SponsorshipLevel]

Repository for SponsorshipLevel database operations.

async exists_by_slug(slug)[source]

Check if a sponsorship level exists by slug.

Parameters:

slug (str) – The slug to check.

Return type:

bool

Returns:

True if a level with this slug exists, False otherwise.

async get_by_slug(slug)[source]

Get a sponsorship level by its slug.

Parameters:

slug (str) – The slug to search for.

Return type:

SponsorshipLevel | None

Returns:

The sponsorship level if found, None otherwise.

async list_ordered(limit=100, offset=0)[source]

List sponsorship levels ordered by order field.

Parameters:
  • limit (int) – Maximum number of levels to return.

  • offset (int) – Number of levels to skip.

Return type:

list[SponsorshipLevel]

Returns:

List of sponsorship levels ordered by order field.

model_type

alias of SponsorshipLevel

class SponsorshipLevelService[source]

Bases: SQLAlchemyAsyncRepositoryService[SponsorshipLevel, Any]

Service for SponsorshipLevel business logic.

async create_level(data)[source]

Create a new sponsorship level.

Parameters:

data (SponsorshipLevelCreate) – Sponsorship level creation data.

Return type:

SponsorshipLevel

Returns:

The created sponsorship level instance.

Raises:

ValueError – If slug already exists.

async get_by_slug(slug)[source]

Get a sponsorship level by its slug.

Parameters:

slug (str) – The slug to search for.

Return type:

SponsorshipLevel | None

Returns:

The sponsorship level if found, None otherwise.

async list_ordered(limit=100, offset=0)[source]

List sponsorship levels ordered by order field.

Parameters:
  • limit (int) – Maximum number of levels to return.

  • offset (int) – Number of levels to skip.

Return type:

list[SponsorshipLevel]

Returns:

List of sponsorship levels ordered by order field.

match_fields: ClassVar[Optional[Union[list[str], str]]] = ['slug']

List of dialects that prefer to use field.id = ANY(:1) instead of field.id IN (...).

repository_type

alias of SponsorshipLevelRepository

class SponsorshipLevelUpdate[source]

Bases: BaseModel

Schema for updating a sponsorship level.

model_config: ClassVar[ConfigDict] = {'json_schema_extra': {'example': {'logo_dimension': 250, 'sponsorship_amount': 175000}}}

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

class SponsorshipPublic[source]

Bases: BaseModel

Public sponsorship schema.

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

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

class SponsorshipRead[source]

Bases: SponsorshipBase

Schema for reading sponsorship data.

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

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

class SponsorshipRepository[source]

Bases: SQLAlchemyAsyncRepository[Sponsorship]

Repository for Sponsorship database operations.

async get_previous_for_sponsor(sponsor_id, current_year)[source]

Get the previous sponsorship for a sponsor.

Parameters:
  • sponsor_id (UUID) – The sponsor ID to search for.

  • current_year (int | None) – The current sponsorship year to exclude.

Return type:

Sponsorship | None

Returns:

The previous sponsorship if found, None otherwise.

async list_active(limit=100, offset=0)[source]

List active sponsorships.

Parameters:
  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of active sponsorships.

async list_by_level_id(level_id, limit=100, offset=0)[source]

List sponsorships for a specific level.

Parameters:
  • level_id (UUID) – The level ID to filter by.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships for the level.

async list_by_sponsor_id(sponsor_id, limit=100, offset=0)[source]

List sponsorships for a specific sponsor.

Parameters:
  • sponsor_id (UUID) – The sponsor ID to filter by.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships for the sponsor.

async list_by_status(status, limit=100, offset=0)[source]

List sponsorships by status.

Parameters:
  • status (SponsorshipStatus) – The status to filter by.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships with the given status.

async list_expiring_soon(days=90, limit=100, offset=0)[source]

List sponsorships expiring within the given number of days.

Parameters:
  • days (int) – Number of days until expiration.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships expiring within the given timeframe.

model_type

alias of Sponsorship

class SponsorshipService[source]

Bases: SQLAlchemyAsyncRepositoryService[Sponsorship, Any]

Service for Sponsorship business logic.

async approve(sponsorship_id)[source]

Approve a sponsorship.

Parameters:

sponsorship_id (UUID) – The ID of the sponsorship to approve.

Return type:

Sponsorship

Returns:

The updated sponsorship instance.

async approve_with_renewal(sponsorship_id, start_date, end_date, sponsorship_fee=None, *, is_renewal=False)[source]

Approve a sponsorship with full approval data.

Parameters:
  • sponsorship_id (UUID) – The ID of the sponsorship to approve.

  • start_date (date) – The sponsorship start date.

  • end_date (date) – The sponsorship end date.

  • sponsorship_fee (int | None) – Optional sponsorship fee override.

  • is_renewal (bool) – Whether this is a renewal of a previous sponsorship.

Return type:

Sponsorship

Returns:

The updated sponsorship instance.

async create_renewal(previous_sponsorship, level_id=None)[source]

Create a renewal sponsorship based on a previous one.

Parameters:
  • previous_sponsorship (Sponsorship) – The sponsorship being renewed.

  • level_id (UUID | None) – Optional new level ID (defaults to same level).

Return type:

Sponsorship

Returns:

The new renewal sponsorship instance.

async create_sponsorship(data)[source]

Create a new sponsorship.

Parameters:

data (SponsorshipCreate) – Sponsorship creation data.

Return type:

Sponsorship

Returns:

The created sponsorship instance.

async finalize(sponsorship_id)[source]

Finalize a sponsorship.

Parameters:

sponsorship_id (UUID) – The ID of the sponsorship to finalize.

Return type:

Sponsorship

Returns:

The updated sponsorship instance.

async get_previous_sponsorship(sponsorship)[source]

Get the previous sponsorship for the same sponsor.

Used to determine previous effective date for renewal contracts.

Parameters:

sponsorship (Sponsorship) – The current sponsorship.

Return type:

Sponsorship | None

Returns:

The previous sponsorship if found, None otherwise.

async list_active(limit=100, offset=0)[source]

List active sponsorships.

Parameters:
  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of active sponsorships.

async list_by_level_id(level_id, limit=100, offset=0)[source]

List sponsorships for a specific level.

Parameters:
  • level_id (UUID) – The level ID to filter by.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships for the level.

async list_by_sponsor_id(sponsor_id, limit=100, offset=0)[source]

List sponsorships for a specific sponsor.

Parameters:
  • sponsor_id (UUID) – The sponsor ID to filter by.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships for the sponsor.

async list_by_status(status, limit=100, offset=0)[source]

List sponsorships by status.

Parameters:
  • status (SponsorshipStatus) – The status to filter by.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships with the given status.

async list_expiring_soon(days=90, limit=100, offset=0)[source]

List sponsorships expiring within the given number of days.

Useful for sending renewal reminders.

Parameters:
  • days (int) – Number of days until expiration.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships expiring within the given timeframe.

match_fields: ClassVar[Optional[Union[list[str], str]]] = ['sponsor_id', 'level_id']

List of dialects that prefer to use field.id = ANY(:1) instead of field.id IN (...).

async reject(sponsorship_id)[source]

Reject a sponsorship.

Parameters:

sponsorship_id (UUID) – The ID of the sponsorship to reject.

Return type:

Sponsorship

Returns:

The updated sponsorship instance.

repository_type

alias of SponsorshipRepository

class SponsorshipStatus[source]

Bases: StrEnum

__new__(value)
class SponsorshipUpdate[source]

Bases: BaseModel

Schema for updating a sponsorship.

model_config: ClassVar[ConfigDict] = {}

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

get_sponsors_dependencies()[source]

Get all sponsors domain dependency providers.

Return type:

dict

models

Sponsors domain models.

class SponsorshipStatus[source]

Bases: StrEnum

__new__(value)
class ContractStatus[source]

Bases: StrEnum

Contract workflow status.

__new__(value)
class SponsorshipLevel[source]

Bases: AuditBase, NameSlugMixin

__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.

name: Mapped[str]
slug: Mapped[str]
updated_at: Mapped[datetime.datetime]

Date/time of instance last update.

class Sponsor[source]

Bases: AuditBase, ContentManageableMixin, NameSlugMixin

property tier: str

Get the tier name from the sponsor’s active sponsorship.

Returns the level slug from the first finalized sponsorship, or ‘community’ as a default if no active sponsorship exists.

__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: Mapped[datetime]
created_at: Mapped[datetime.datetime]

Date/time of instance creation.

creator
creator_id
id: Mapped[UUID]

UUID Primary key column.

last_modified_by
last_modified_by_id
name: Mapped[str]
slug: Mapped[str]
updated: Mapped[datetime]
updated_at: Mapped[datetime.datetime]

Date/time of instance last update.

class Sponsorship[source]

Bases: AuditBase, ContentManageableMixin

__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: Mapped[datetime]
created_at: Mapped[datetime.datetime]

Date/time of instance creation.

creator
creator_id
id: Mapped[UUID]

UUID Primary key column.

last_modified_by
last_modified_by_id
updated: Mapped[datetime]
updated_at: Mapped[datetime.datetime]

Date/time of instance last update.

class LegalClause[source]

Bases: Base, NameSlugMixin

Legal clauses applied to sponsor contracts.

Clauses define terms and conditions that can be attached to contracts.

__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.

id: Mapped[UUID]

UUID Primary key column.

name: Mapped[str]
slug: Mapped[str]
class Contract[source]

Bases: AuditBase

Contract for officializing a sponsorship.

Tracks the contract document lifecycle from draft through execution.

property is_draft: bool

Check if contract is in draft status.

property is_awaiting_signature: bool

Check if contract is awaiting signature.

property is_executed: bool

Check if contract has been executed.

property can_send: bool

Check if contract can be sent for signature.

property can_execute: bool

Check if contract can be executed.

property can_nullify: bool

Check if contract can be nullified.

property next_statuses: list[ContractStatus]

Get valid next statuses for current state.

__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

Sponsors domain Pydantic schemas.

class SponsorshipLevelBase[source]

Bases: BaseModel

Base sponsorship level schema.

model_config: ClassVar[ConfigDict] = {}

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

class SponsorshipLevelCreate[source]

Bases: BaseModel

Schema for creating a new sponsorship level.

model_config: ClassVar[ConfigDict] = {'json_schema_extra': {'example': {'logo_dimension': 200, 'name': 'Visionary', 'order': 1, 'slug': 'visionary', 'sponsorship_amount': 150000}}}

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

class SponsorshipLevelUpdate[source]

Bases: BaseModel

Schema for updating a sponsorship level.

model_config: ClassVar[ConfigDict] = {'json_schema_extra': {'example': {'logo_dimension': 250, 'sponsorship_amount': 175000}}}

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

class SponsorshipLevelRead[source]

Bases: SponsorshipLevelBase

Schema for reading sponsorship level data.

model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'json_schema_extra': {'example': {'created_at': '2025-01-01T00:00:00Z', 'id': '550e8400-e29b-41d4-a716-446655440001', 'logo_dimension': 200, 'name': 'Visionary', 'order': 1, 'slug': 'visionary', 'sponsorship_amount': 150000, 'updated_at': '2025-01-01T00:00:00Z'}}}

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

class SponsorBase[source]

Bases: BaseModel

Base sponsor schema.

model_config: ClassVar[ConfigDict] = {}

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

class SponsorCreate[source]

Bases: BaseModel

Schema for creating a new sponsor.

model_config: ClassVar[ConfigDict] = {'json_schema_extra': {'example': {'city': 'Redmond', 'country': 'USA', 'description': 'Microsoft is a Visionary sponsor of the PSF', 'landing_page_url': 'https://microsoft.com', 'linked_in_page_url': 'https://linkedin.com/company/microsoft', 'name': 'Microsoft', 'postal_code': '98052', 'slug': 'microsoft', 'state': 'Washington', 'twitter_handle': 'Microsoft', 'web_logo': '/media/sponsors/microsoft-logo.png'}}}

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

class SponsorUpdate[source]

Bases: BaseModel

Schema for updating a sponsor.

model_config: ClassVar[ConfigDict] = {}

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

class SponsorRead[source]

Bases: SponsorBase

Schema for reading sponsor data.

model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'json_schema_extra': {'example': {'city': 'Redmond', 'country': 'USA', 'country_of_incorporation': '', 'created': '2025-01-01T00:00:00Z', 'creator_id': '550e8400-e29b-41d4-a716-446655440000', 'description': 'Microsoft is a Visionary sponsor of the PSF', 'id': '550e8400-e29b-41d4-a716-446655440010', 'landing_page_url': 'https://microsoft.com', 'last_modified_by_id': None, 'linked_in_page_url': 'https://linkedin.com/company/microsoft', 'mailing_address_line_1': '', 'mailing_address_line_2': '', 'name': 'Microsoft', 'postal_code': '98052', 'primary_phone': '', 'print_logo': '', 'slug': 'microsoft', 'state': 'Washington', 'state_of_incorporation': '', 'twitter_handle': 'Microsoft', 'updated': '2025-01-01T00:00:00Z', 'web_logo': '/media/sponsors/microsoft-logo.png'}}}

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

class SponsorPublic[source]

Bases: BaseModel

Public sponsor schema.

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

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

class SponsorshipBase[source]

Bases: BaseModel

Base sponsorship schema.

model_config: ClassVar[ConfigDict] = {}

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

class SponsorshipCreate[source]

Bases: BaseModel

Schema for creating a new sponsorship.

model_config: ClassVar[ConfigDict] = {}

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

class SponsorshipUpdate[source]

Bases: BaseModel

Schema for updating a sponsorship.

model_config: ClassVar[ConfigDict] = {}

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

class SponsorshipRead[source]

Bases: SponsorshipBase

Schema for reading sponsorship data.

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

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

class SponsorshipPublic[source]

Bases: BaseModel

Public sponsorship schema.

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

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

class SponsorApplicationCreate[source]

Bases: BaseModel

Schema for sponsor application form submission.

model_config: ClassVar[ConfigDict] = {'json_schema_extra': {'example': {'company_name': 'Acme Corp', 'contact_email': 'jane@acme.com', 'contact_name': 'Jane Doe', 'description': 'We love Python!', 'sponsorship_level': 'silver', 'website': 'https://acme.com'}}}

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

services

Sponsors domain services for business logic.

exception InvalidContractStatusError[source]

Bases: Exception

Raised when a contract status transition is not valid.

class SponsorshipLevelService[source]

Bases: SQLAlchemyAsyncRepositoryService[SponsorshipLevel, Any]

Service for SponsorshipLevel business logic.

repository_type

alias of SponsorshipLevelRepository

match_fields: ClassVar[Optional[Union[list[str], str]]] = ['slug']

List of dialects that prefer to use field.id = ANY(:1) instead of field.id IN (...).

async create_level(data)[source]

Create a new sponsorship level.

Parameters:

data (SponsorshipLevelCreate) – Sponsorship level creation data.

Return type:

SponsorshipLevel

Returns:

The created sponsorship level instance.

Raises:

ValueError – If slug already exists.

async get_by_slug(slug)[source]

Get a sponsorship level by its slug.

Parameters:

slug (str) – The slug to search for.

Return type:

SponsorshipLevel | None

Returns:

The sponsorship level if found, None otherwise.

async list_ordered(limit=100, offset=0)[source]

List sponsorship levels ordered by order field.

Parameters:
  • limit (int) – Maximum number of levels to return.

  • offset (int) – Number of levels to skip.

Return type:

list[SponsorshipLevel]

Returns:

List of sponsorship levels ordered by order field.

class SponsorService[source]

Bases: SQLAlchemyAsyncRepositoryService[Sponsor, Any]

Service for Sponsor business logic.

repository_type

alias of SponsorRepository

match_fields: ClassVar[Optional[Union[list[str], str]]] = ['slug']

List of dialects that prefer to use field.id = ANY(:1) instead of field.id IN (...).

async create_sponsor(data)[source]

Create a new sponsor.

Parameters:

data (SponsorCreate) – Sponsor creation data.

Return type:

Sponsor

Returns:

The created sponsor instance.

Raises:

ValueError – If slug already exists.

async get_by_slug(slug)[source]

Get a sponsor by its slug.

Parameters:

slug (str) – The slug to search for.

Return type:

Sponsor | None

Returns:

The sponsor if found, None otherwise.

async list_with_active_sponsorships(limit=100, offset=0)[source]

List sponsors with active sponsorships.

Parameters:
  • limit (int) – Maximum number of sponsors to return.

  • offset (int) – Number of sponsors to skip.

Return type:

list[Sponsor]

Returns:

List of sponsors with active sponsorships.

class SponsorshipService[source]

Bases: SQLAlchemyAsyncRepositoryService[Sponsorship, Any]

Service for Sponsorship business logic.

repository_type

alias of SponsorshipRepository

match_fields: ClassVar[Optional[Union[list[str], str]]] = ['sponsor_id', 'level_id']

List of dialects that prefer to use field.id = ANY(:1) instead of field.id IN (...).

async create_sponsorship(data)[source]

Create a new sponsorship.

Parameters:

data (SponsorshipCreate) – Sponsorship creation data.

Return type:

Sponsorship

Returns:

The created sponsorship instance.

async list_by_sponsor_id(sponsor_id, limit=100, offset=0)[source]

List sponsorships for a specific sponsor.

Parameters:
  • sponsor_id (UUID) – The sponsor ID to filter by.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships for the sponsor.

async list_by_level_id(level_id, limit=100, offset=0)[source]

List sponsorships for a specific level.

Parameters:
  • level_id (UUID) – The level ID to filter by.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships for the level.

async list_by_status(status, limit=100, offset=0)[source]

List sponsorships by status.

Parameters:
  • status (SponsorshipStatus) – The status to filter by.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships with the given status.

async list_active(limit=100, offset=0)[source]

List active sponsorships.

Parameters:
  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of active sponsorships.

async approve(sponsorship_id)[source]

Approve a sponsorship.

Parameters:

sponsorship_id (UUID) – The ID of the sponsorship to approve.

Return type:

Sponsorship

Returns:

The updated sponsorship instance.

async reject(sponsorship_id)[source]

Reject a sponsorship.

Parameters:

sponsorship_id (UUID) – The ID of the sponsorship to reject.

Return type:

Sponsorship

Returns:

The updated sponsorship instance.

async finalize(sponsorship_id)[source]

Finalize a sponsorship.

Parameters:

sponsorship_id (UUID) – The ID of the sponsorship to finalize.

Return type:

Sponsorship

Returns:

The updated sponsorship instance.

async approve_with_renewal(sponsorship_id, start_date, end_date, sponsorship_fee=None, *, is_renewal=False)[source]

Approve a sponsorship with full approval data.

Parameters:
  • sponsorship_id (UUID) – The ID of the sponsorship to approve.

  • start_date (date) – The sponsorship start date.

  • end_date (date) – The sponsorship end date.

  • sponsorship_fee (int | None) – Optional sponsorship fee override.

  • is_renewal (bool) – Whether this is a renewal of a previous sponsorship.

Return type:

Sponsorship

Returns:

The updated sponsorship instance.

async get_previous_sponsorship(sponsorship)[source]

Get the previous sponsorship for the same sponsor.

Used to determine previous effective date for renewal contracts.

Parameters:

sponsorship (Sponsorship) – The current sponsorship.

Return type:

Sponsorship | None

Returns:

The previous sponsorship if found, None otherwise.

async list_expiring_soon(days=90, limit=100, offset=0)[source]

List sponsorships expiring within the given number of days.

Useful for sending renewal reminders.

Parameters:
  • days (int) – Number of days until expiration.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships expiring within the given timeframe.

async create_renewal(previous_sponsorship, level_id=None)[source]

Create a renewal sponsorship based on a previous one.

Parameters:
  • previous_sponsorship (Sponsorship) – The sponsorship being renewed.

  • level_id (UUID | None) – Optional new level ID (defaults to same level).

Return type:

Sponsorship

Returns:

The new renewal sponsorship instance.

class LegalClauseService[source]

Bases: SQLAlchemyAsyncRepositoryService[LegalClause, Any]

Service for LegalClause business logic.

repository_type

alias of LegalClauseRepository

match_fields: ClassVar[Optional[Union[list[str], str]]] = ['slug']

List of dialects that prefer to use field.id = ANY(:1) instead of field.id IN (...).

async get_by_slug(slug)[source]

Get a legal clause by its slug.

Parameters:

slug (str) – The slug to search for.

Return type:

LegalClause | None

Returns:

The legal clause if found, None otherwise.

async list_active(limit=100, offset=0)[source]

List active legal clauses ordered by order field.

Parameters:
  • limit (int) – Maximum number of clauses to return.

  • offset (int) – Number of clauses to skip.

Return type:

list[LegalClause]

Returns:

List of active legal clauses.

class ContractService[source]

Bases: SQLAlchemyAsyncRepositoryService[Contract, Any]

Service for Contract business logic and workflow management.

repository_type

alias of ContractRepository

async create_contract(sponsorship_id)[source]

Create a new contract for a sponsorship.

Initializes a draft contract with sponsor information from the sponsorship.

Parameters:

sponsorship_id (UUID) – The sponsorship ID to create contract for.

Return type:

Contract

Returns:

The created contract instance.

async get_by_sponsorship_id(sponsorship_id)[source]

Get a contract by sponsorship ID.

Parameters:

sponsorship_id (UUID) – The sponsorship ID to search for.

Return type:

Contract | None

Returns:

The contract if found, None otherwise.

async list_by_status(status, limit=100, offset=0)[source]

List contracts by status.

Parameters:
  • status (ContractStatus) – The status to filter by.

  • limit (int) – Maximum number of contracts to return.

  • offset (int) – Number of contracts to skip.

Return type:

list[Contract]

Returns:

List of contracts with the given status.

async send_for_signature(contract_id, document_pdf='', document_docx='')[source]

Send contract for signature.

Transitions contract from DRAFT to AWAITING_SIGNATURE.

Parameters:
  • contract_id (UUID) – The contract ID.

  • document_pdf (str) – Path to the unsigned PDF document.

  • document_docx (str) – Path to the unsigned DOCX document.

Return type:

Contract

Returns:

The updated contract instance.

Raises:

InvalidContractStatusError – If transition is not valid.

async execute_contract(contract_id, signed_document='')[source]

Execute a contract.

Marks the contract as executed and finalizes the associated sponsorship.

Parameters:
  • contract_id (UUID) – The contract ID.

  • signed_document (str) – Path to the signed document.

Return type:

Contract

Returns:

The updated contract instance.

Raises:

InvalidContractStatusError – If transition is not valid.

async nullify_contract(contract_id)[source]

Nullify a contract.

Parameters:

contract_id (UUID) – The contract ID.

Return type:

Contract

Returns:

The updated contract instance.

Raises:

InvalidContractStatusError – If transition is not valid.

async revert_to_draft(contract_id)[source]

Revert a nullified contract back to draft.

Parameters:

contract_id (UUID) – The contract ID.

Return type:

Contract

Returns:

The updated contract instance.

Raises:

InvalidContractStatusError – If transition is not valid.

async update_benefits_and_clauses(contract_id, benefits_list, legal_clauses_text)[source]

Update contract benefits list and legal clauses.

Parameters:
  • contract_id (UUID) – The contract ID.

  • benefits_list (str) – Markdown formatted list of benefits.

  • legal_clauses_text (str) – Markdown formatted legal clauses.

Return type:

Contract

Returns:

The updated contract instance.

controllers

Sponsors domain API controllers.

class SponsorshipLevelController[source]

Bases: Controller

Controller for SponsorshipLevel 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 SponsorController[source]

Bases: Controller

Controller for Sponsor 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 SponsorshipController[source]

Bases: Controller

Controller for Sponsorship 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 SponsorRenderController[source]

Bases: Controller

Controller for rendering sponsor pages as HTML.

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

Sponsors domain repositories for database access.

class SponsorshipLevelRepository[source]

Bases: SQLAlchemyAsyncRepository[SponsorshipLevel]

Repository for SponsorshipLevel database operations.

model_type

alias of SponsorshipLevel

async get_by_slug(slug)[source]

Get a sponsorship level by its slug.

Parameters:

slug (str) – The slug to search for.

Return type:

SponsorshipLevel | None

Returns:

The sponsorship level if found, None otherwise.

async list_ordered(limit=100, offset=0)[source]

List sponsorship levels ordered by order field.

Parameters:
  • limit (int) – Maximum number of levels to return.

  • offset (int) – Number of levels to skip.

Return type:

list[SponsorshipLevel]

Returns:

List of sponsorship levels ordered by order field.

async exists_by_slug(slug)[source]

Check if a sponsorship level exists by slug.

Parameters:

slug (str) – The slug to check.

Return type:

bool

Returns:

True if a level with this slug exists, False otherwise.

class SponsorRepository[source]

Bases: SQLAlchemyAsyncRepository[Sponsor]

Repository for Sponsor database operations.

model_type

alias of Sponsor

async get_by_slug(slug)[source]

Get a sponsor by its slug.

Parameters:

slug (str) – The slug to search for.

Return type:

Sponsor | None

Returns:

The sponsor if found, None otherwise.

async list_with_active_sponsorships(limit=100, offset=0)[source]

List sponsors with active sponsorships.

Parameters:
  • limit (int) – Maximum number of sponsors to return.

  • offset (int) – Number of sponsors to skip.

Return type:

list[Sponsor]

Returns:

List of sponsors with active sponsorships, with sponsorships and levels loaded.

async exists_by_slug(slug)[source]

Check if a sponsor exists by slug.

Parameters:

slug (str) – The slug to check.

Return type:

bool

Returns:

True if a sponsor with this slug exists, False otherwise.

class SponsorshipRepository[source]

Bases: SQLAlchemyAsyncRepository[Sponsorship]

Repository for Sponsorship database operations.

model_type

alias of Sponsorship

async list_by_sponsor_id(sponsor_id, limit=100, offset=0)[source]

List sponsorships for a specific sponsor.

Parameters:
  • sponsor_id (UUID) – The sponsor ID to filter by.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships for the sponsor.

async list_by_level_id(level_id, limit=100, offset=0)[source]

List sponsorships for a specific level.

Parameters:
  • level_id (UUID) – The level ID to filter by.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships for the level.

async list_by_status(status, limit=100, offset=0)[source]

List sponsorships by status.

Parameters:
  • status (SponsorshipStatus) – The status to filter by.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships with the given status.

async list_active(limit=100, offset=0)[source]

List active sponsorships.

Parameters:
  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of active sponsorships.

async get_previous_for_sponsor(sponsor_id, current_year)[source]

Get the previous sponsorship for a sponsor.

Parameters:
  • sponsor_id (UUID) – The sponsor ID to search for.

  • current_year (int | None) – The current sponsorship year to exclude.

Return type:

Sponsorship | None

Returns:

The previous sponsorship if found, None otherwise.

async list_expiring_soon(days=90, limit=100, offset=0)[source]

List sponsorships expiring within the given number of days.

Parameters:
  • days (int) – Number of days until expiration.

  • limit (int) – Maximum number of sponsorships to return.

  • offset (int) – Number of sponsorships to skip.

Return type:

list[Sponsorship]

Returns:

List of sponsorships expiring within the given timeframe.

class LegalClauseRepository[source]

Bases: SQLAlchemyAsyncRepository[LegalClause]

Repository for LegalClause database operations.

model_type

alias of LegalClause

async get_by_slug(slug)[source]

Get a legal clause by its slug.

Parameters:

slug (str) – The slug to search for.

Return type:

LegalClause | None

Returns:

The legal clause if found, None otherwise.

async list_active(limit=100, offset=0)[source]

List active legal clauses ordered by order field.

Parameters:
  • limit (int) – Maximum number of clauses to return.

  • offset (int) – Number of clauses to skip.

Return type:

list[LegalClause]

Returns:

List of active legal clauses.

class ContractRepository[source]

Bases: SQLAlchemyAsyncRepository[Contract]

Repository for Contract database operations.

model_type

alias of Contract

async get_by_sponsorship_id(sponsorship_id)[source]

Get a contract by sponsorship ID.

Parameters:

sponsorship_id (UUID) – The sponsorship ID to search for.

Return type:

Contract | None

Returns:

The contract if found, None otherwise.

async list_by_status(status, limit=100, offset=0)[source]

List contracts by status.

Parameters:
  • status (ContractStatus) – The status to filter by.

  • limit (int) – Maximum number of contracts to return.

  • offset (int) – Number of contracts to skip.

Return type:

list[Contract]

Returns:

List of contracts with the given status.