Nominations¶
PSF board nominations and elections.
Module Contents¶
Nominations domain for PSF board elections.
- class Election[source]
-
- __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.
- description: Mapped[str | None]
- id: Mapped[UUID]
UUID Primary key column.
- name: Mapped[str]
- nominations_close: Mapped[datetime.date]
- nominations_open: Mapped[datetime.date]
- nominees: Mapped[list[Nominee]]
- slug: Mapped[str]
- property status: ElectionStatus
- updated_at: Mapped[datetime.datetime]
Date/time of instance last update.
- voting_close: Mapped[datetime.date]
- voting_open: Mapped[datetime.date]
- class ElectionController[source]
Bases:
ControllerController for Election CRUD operations.
- after_request: AfterRequestHookHandler | None
A sync or async function executed before a
Requestis 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
Requestinstance 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
Requestinstance and any non-Nonereturn value is used for the response, bypassing the route handler.
- cache_control: CacheControlHeader | None
A
CacheControlHeaderheader to add to route handlers of this controller.Can be overridden by route handlers.
- dependencies: Dependencies | None
A string keyed dictionary of dependency
Providerinstances.
- dto: type[AbstractDTO] | None | EmptyType
AbstractDTOto use for (de)serializing and validation of request data.
- etag: ETag | None
An
etagheader of typeETagto 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
Guardcallables.
- 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
Guardsor wherever you have access toRequestorASGI Scope.
- owner: Router
The
RouterorLitestarapp 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
Parameterdefinitions 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
Requestto 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
Responseto be used as the default response for all route handlers under the controller.
- response_cookies: ResponseCookies | None
A list of
Cookieinstances.
- response_headers: ResponseHeaders | None
A string keyed dictionary mapping
ResponseHeaderinstances.
- return_dto: type[AbstractDTO] | None | EmptyType
AbstractDTOto 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
WebSocketto be used as the default websocket for all route handlers under the controller.
- create_election(fn) = <litestar.handlers.http_handlers.decorators.post object>
- delete_election(fn) = <litestar.handlers.http_handlers.decorators.delete object>
- get_election(fn) = <litestar.handlers.http_handlers.decorators.get object>
- list_active_elections(fn) = <litestar.handlers.http_handlers.decorators.get object>
- list_elections(fn) = <litestar.handlers.http_handlers.decorators.get object>
- update_election(fn) = <litestar.handlers.http_handlers.decorators.put object>
- class ElectionCreate[source]
Bases:
ElectionBaseSchema for creating a new election.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- slug: Annotated[str, Field(max_length=200)] | None
- class ElectionPublic[source]
Bases:
BaseModelPublic election schema for listings.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- id: UUID
- slug: str
- name: str
- description: str | None
- nominations_open: datetime.date
- nominations_close: datetime.date
- voting_open: datetime.date
- voting_close: datetime.date
- status: ElectionStatus
- class ElectionRead[source]
Bases:
ElectionBaseSchema for reading election data.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- id: UUID
- slug: str
- created_at: datetime.datetime
- updated_at: datetime.datetime
- status: ElectionStatus
- class ElectionRepository[source]
Bases:
SQLAlchemyAsyncRepository[Election]Repository for Election database operations.
- async get_active_elections(limit=100, offset=0)[source]
Get elections that are currently active.
- async get_by_slug(slug)[source]
Get an election by slug.
- async get_by_status(status, limit=100, offset=0)[source]
Get elections by status.
- Parameters:
status (
ElectionStatus) – The election status to filter by.limit (
int) – Maximum number of elections to return.offset (
int) – Number of elections to skip.
- Return type:
- Returns:
List of elections with the specified status.
- model_type
alias of
Election
- class ElectionService[source]
Bases:
SQLAlchemyAsyncRepositoryService[Election, Any]Service for Election business logic.
- async create_election(data)[source]
Create a new election.
- Parameters:
data (
ElectionCreate) – Election creation data.- Return type:
- Returns:
The created election instance.
- async get_active_elections(limit=100, offset=0)[source]
Get elections that are currently active.
- async get_by_slug(slug)[source]
Get an election by slug.
- async get_by_status(status, limit=100, offset=0)[source]
Get elections by status.
- Parameters:
status (
ElectionStatus) – The election status to filter by.limit (
int) – Maximum number of elections to return.offset (
int) – Number of elections to skip.
- Return type:
- Returns:
List of elections with the specified status.
- match_fields: ClassVar[Optional[Union[list[str], str]]] = ['slug']
List of dialects that prefer to use
field.id = ANY(:1)instead offield.id IN (...).
- repository_type
alias of
ElectionRepository
- class ElectionStatus[source]
Bases:
StrEnum- __new__(value)
- UPCOMING = 'upcoming'
- NOMINATIONS_OPEN = 'nominations_open'
- VOTING_OPEN = 'voting_open'
- CLOSED = 'closed'
- class ElectionUpdate[source]
Bases:
BaseModelSchema for updating an election.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: Annotated[str, Field(max_length=200)] | None
- description: str | None
- nominations_open: datetime.date | None
- nominations_close: datetime.date | None
- voting_open: datetime.date | None
- voting_close: datetime.date | None
- slug: Annotated[str, Field(max_length=200)] | None
- class Nomination[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.
- endorsement: Mapped[str | None]
- id: Mapped[UUID]
UUID Primary key column.
- nominator: Mapped[User]
- nominator_id: Mapped[UUID]
- nominee: Mapped[Nominee]
- nominee_id: Mapped[UUID]
- updated_at: Mapped[datetime.datetime]
Date/time of instance last update.
- class NominationController[source]
Bases:
ControllerController for Nomination CRUD operations.
- after_request: AfterRequestHookHandler | None
A sync or async function executed before a
Requestis 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
Requestinstance 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
Requestinstance and any non-Nonereturn value is used for the response, bypassing the route handler.
- cache_control: CacheControlHeader | None
A
CacheControlHeaderheader to add to route handlers of this controller.Can be overridden by route handlers.
- dependencies: Dependencies | None
A string keyed dictionary of dependency
Providerinstances.
- dto: type[AbstractDTO] | None | EmptyType
AbstractDTOto use for (de)serializing and validation of request data.
- etag: ETag | None
An
etagheader of typeETagto 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
Guardcallables.
- 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
Guardsor wherever you have access toRequestorASGI Scope.
- owner: Router
The
RouterorLitestarapp 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
Parameterdefinitions 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
Requestto 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
Responseto be used as the default response for all route handlers under the controller.
- response_cookies: ResponseCookies | None
A list of
Cookieinstances.
- response_headers: ResponseHeaders | None
A string keyed dictionary mapping
ResponseHeaderinstances.
- return_dto: type[AbstractDTO] | None | EmptyType
AbstractDTOto 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
WebSocketto be used as the default websocket for all route handlers under the controller.
- create_nomination(fn) = <litestar.handlers.http_handlers.decorators.post object>
- delete_nomination(fn) = <litestar.handlers.http_handlers.decorators.delete object>
- get_nomination(fn) = <litestar.handlers.http_handlers.decorators.get object>
- list_nominations(fn) = <litestar.handlers.http_handlers.decorators.get object>
- class NominationCreate[source]
Bases:
NominationBaseSchema for creating a new nomination.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class NominationRead[source]
Bases:
NominationBaseSchema for reading nomination data.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- id: UUID
- nominator_id: UUID
- created_at: datetime.datetime
- updated_at: datetime.datetime
- class NominationRepository[source]
Bases:
SQLAlchemyAsyncRepository[Nomination]Repository for Nomination database operations.
- async count_by_nominee(nominee_id)[source]
Count nominations for a nominee.
- async get_by_nominator(nominator_id, limit=100, offset=0)[source]
Get nominations by nominator.
- Parameters:
- Return type:
- Returns:
List of nominations by the nominator.
- async get_by_nominee(nominee_id, limit=100, offset=0)[source]
Get nominations for a nominee.
- Parameters:
- Return type:
- Returns:
List of nominations for the nominee.
- model_type
alias of
Nomination
- class NominationService[source]
Bases:
SQLAlchemyAsyncRepositoryService[Nomination, Any]Service for Nomination business logic.
- async count_by_nominee(nominee_id)[source]
Count nominations for a nominee.
- async create_nomination(nominee_id, nominator_id, endorsement=None)[source]
Create a new nomination.
- Parameters:
- Return type:
- Returns:
The created nomination instance.
- async get_by_nominator(nominator_id, limit=100, offset=0)[source]
Get nominations by nominator.
- Parameters:
- Return type:
- Returns:
List of nominations by the nominator.
- async get_by_nominee(nominee_id, limit=100, offset=0)[source]
Get nominations for a nominee.
- Parameters:
- Return type:
- Returns:
List of nominations for the nominee.
- repository_type
alias of
NominationRepository
- class NominationUpdate[source]
Bases:
BaseModelSchema for updating a nomination.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- endorsement: str | None
- class NominationsHTMXController[source]
Bases:
ControllerHTMX controller for nominations form submissions.
- after_request: AfterRequestHookHandler | None
A sync or async function executed before a
Requestis 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
Requestinstance 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
Requestinstance and any non-Nonereturn value is used for the response, bypassing the route handler.
- cache_control: CacheControlHeader | None
A
CacheControlHeaderheader to add to route handlers of this controller.Can be overridden by route handlers.
- dependencies: Dependencies | None
A string keyed dictionary of dependency
Providerinstances.
- dto: type[AbstractDTO] | None | EmptyType
AbstractDTOto use for (de)serializing and validation of request data.
- etag: ETag | None
An
etagheader of typeETagto 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
Guardcallables.
- 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
Guardsor wherever you have access toRequestorASGI Scope.
- owner: Router
The
RouterorLitestarapp 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
Parameterdefinitions 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
Requestto 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
Responseto be used as the default response for all route handlers under the controller.
- response_cookies: ResponseCookies | None
A list of
Cookieinstances.
- response_headers: ResponseHeaders | None
A string keyed dictionary mapping
ResponseHeaderinstances.
- return_dto: type[AbstractDTO] | None | EmptyType
AbstractDTOto 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
WebSocketto be used as the default websocket for all route handlers under the controller.
- nominate_candidate(fn) = <litestar.handlers.http_handlers.decorators.post object>
- class NominationsRenderController[source]
Bases:
ControllerController for rendering nominations as HTML.
- after_request: AfterRequestHookHandler | None
A sync or async function executed before a
Requestis 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
Requestinstance 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
Requestinstance and any non-Nonereturn value is used for the response, bypassing the route handler.
- cache_control: CacheControlHeader | None
A
CacheControlHeaderheader to add to route handlers of this controller.Can be overridden by route handlers.
- dependencies: Dependencies | None
A string keyed dictionary of dependency
Providerinstances.
- dto: type[AbstractDTO] | None | EmptyType
AbstractDTOto use for (de)serializing and validation of request data.
- etag: ETag | None
An
etagheader of typeETagto 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
Guardcallables.
- 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
Guardsor wherever you have access toRequestorASGI Scope.
- owner: Router
The
RouterorLitestarapp 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
Parameterdefinitions 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
Requestto 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
Responseto be used as the default response for all route handlers under the controller.
- response_cookies: ResponseCookies | None
A list of
Cookieinstances.
- response_headers: ResponseHeaders | None
A string keyed dictionary mapping
ResponseHeaderinstances.
- return_dto: type[AbstractDTO] | None | EmptyType
AbstractDTOto 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
WebSocketto be used as the default websocket for all route handlers under the controller.
- get_election_html(fn) = <litestar.handlers.http_handlers.decorators.get object>
- list_elections_html(fn) = <litestar.handlers.http_handlers.decorators.get object>
- class Nominee[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.
- accepted: Mapped[bool]
- created_at: Mapped[datetime.datetime]
Date/time of instance creation.
- election: Mapped[Election]
- election_id: Mapped[UUID]
- id: Mapped[UUID]
UUID Primary key column.
- nominations: Mapped[list[Nomination]]
- updated_at: Mapped[datetime.datetime]
Date/time of instance last update.
- user: Mapped[User]
- user_id: Mapped[UUID]
- class NomineeController[source]
Bases:
ControllerController for Nominee CRUD operations.
- after_request: AfterRequestHookHandler | None
A sync or async function executed before a
Requestis 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
Requestinstance 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
Requestinstance and any non-Nonereturn value is used for the response, bypassing the route handler.
- cache_control: CacheControlHeader | None
A
CacheControlHeaderheader to add to route handlers of this controller.Can be overridden by route handlers.
- dependencies: Dependencies | None
A string keyed dictionary of dependency
Providerinstances.
- dto: type[AbstractDTO] | None | EmptyType
AbstractDTOto use for (de)serializing and validation of request data.
- etag: ETag | None
An
etagheader of typeETagto 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
Guardcallables.
- 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
Guardsor wherever you have access toRequestorASGI Scope.
- owner: Router
The
RouterorLitestarapp 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
Parameterdefinitions 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
Requestto 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
Responseto be used as the default response for all route handlers under the controller.
- response_cookies: ResponseCookies | None
A list of
Cookieinstances.
- response_headers: ResponseHeaders | None
A string keyed dictionary mapping
ResponseHeaderinstances.
- return_dto: type[AbstractDTO] | None | EmptyType
AbstractDTOto 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
WebSocketto be used as the default websocket for all route handlers under the controller.
- accept_nomination(fn) = <litestar.handlers.http_handlers.decorators.patch object>
- create_nominee(fn) = <litestar.handlers.http_handlers.decorators.post object>
- decline_nomination(fn) = <litestar.handlers.http_handlers.decorators.patch object>
- delete_nominee(fn) = <litestar.handlers.http_handlers.decorators.delete object>
- get_nominee(fn) = <litestar.handlers.http_handlers.decorators.get object>
- list_accepted_nominees(fn) = <litestar.handlers.http_handlers.decorators.get object>
- list_nominees(fn) = <litestar.handlers.http_handlers.decorators.get object>
- class NomineeCreate[source]
Bases:
NomineeBaseSchema for creating a new nominee.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class NomineePublic[source]
Bases:
BaseModelPublic nominee schema for listings.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- id: UUID
- election_id: UUID
- user_id: UUID
- accepted: bool
- class NomineeRead[source]
Bases:
NomineeBaseSchema for reading nominee data.
- model_config: ClassVar[ConfigDict] = {'from_attributes': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- id: UUID
- accepted: bool
- created_at: datetime.datetime
- updated_at: datetime.datetime
- class NomineeRepository[source]
Bases:
SQLAlchemyAsyncRepository[Nominee]Repository for Nominee database operations.
- async get_accepted_nominees(election_id, limit=100, offset=0)[source]
Get accepted nominees for an election.
- async get_by_election(election_id, limit=100, offset=0)[source]
Get nominees for an election.
- async get_by_election_and_user(election_id, user_id)[source]
Get a nominee by election and user.
- async get_by_user(user_id, limit=100, offset=0)[source]
Get nominees by user.
- model_type
alias of
Nominee
- class NomineeService[source]
Bases:
SQLAlchemyAsyncRepositoryService[Nominee, Any]Service for Nominee business logic.
- async accept_nomination(nominee_id)[source]
Accept a nomination.
- Parameters:
nominee_id (
UUID) – The nominee ID.- Return type:
- Returns:
The updated nominee instance.
- Raises:
ValueError – If nominee is already accepted.
- async create_nominee(election_id, user_id)[source]
Create a new nominee.
- Parameters:
- Return type:
- Returns:
The created nominee instance.
- Raises:
ValueError – If nominee already exists.
- async decline_nomination(nominee_id)[source]
Decline a nomination by deleting the nominee.
- async get_accepted_nominees(election_id, limit=100, offset=0)[source]
Get accepted nominees for an election.
- async get_by_election(election_id, limit=100, offset=0)[source]
Get nominees for an election.
- async get_by_user(user_id, limit=100, offset=0)[source]
Get nominees by user.
- repository_type
alias of
NomineeRepository
Models¶
Nominations domain models.
- class ElectionStatus[source]¶
Bases:
StrEnum- UPCOMING = 'upcoming'¶
- NOMINATIONS_OPEN = 'nominations_open'¶
- VOTING_OPEN = 'voting_open'¶
- CLOSED = 'closed'¶
- __new__(value)¶
- class Election[source]¶
-
- name: Mapped[str]¶
- description: Mapped[str | None]¶
- nominations_open: Mapped[datetime.date]¶
- nominations_close: Mapped[datetime.date]¶
- voting_open: Mapped[datetime.date]¶
- voting_close: Mapped[datetime.date]¶
- nominees: Mapped[list[Nominee]]¶
- property status: ElectionStatus¶
- __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.
- slug: Mapped[str]¶
- updated_at: Mapped[datetime.datetime]¶
Date/time of instance last update.
- class Nominee[source]¶
Bases:
AuditBase- election_id: Mapped[UUID]¶
- user_id: Mapped[UUID]¶
- accepted: Mapped[bool]¶
- election: Mapped[Election]¶
- user: Mapped[User]¶
- nominations: Mapped[list[Nomination]]¶
- __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 Nomination[source]¶
Bases:
AuditBase- nominee_id: Mapped[UUID]¶
- nominator_id: Mapped[UUID]¶
- endorsement: Mapped[str | None]¶
- nominee: Mapped[Nominee]¶
- nominator: Mapped[User]¶
- __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¶
Nominations domain Pydantic schemas.
- class ElectionBase[source]¶
Bases:
BaseModelBase election schema.
- name: Annotated[str, Field(max_length=200)]¶
- description: str | None¶
- nominations_open: datetime.date¶
- nominations_close: datetime.date¶
- voting_open: datetime.date¶
- voting_close: datetime.date¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ElectionCreate[source]¶
Bases:
ElectionBaseSchema for creating a new election.
- slug: Annotated[str, Field(max_length=200)] | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: Annotated[str, Field(max_length=200)]¶
- description: str | None¶
- nominations_open: datetime.date¶
- nominations_close: datetime.date¶
- voting_open: datetime.date¶
- voting_close: datetime.date¶
- class ElectionUpdate[source]¶
Bases:
BaseModelSchema for updating an election.
- name: Annotated[str, Field(max_length=200)] | None¶
- description: str | None¶
- nominations_open: datetime.date | None¶
- nominations_close: datetime.date | None¶
- voting_open: datetime.date | None¶
- voting_close: datetime.date | None¶
- slug: Annotated[str, Field(max_length=200)] | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ElectionRead[source]¶
Bases:
ElectionBaseSchema for reading election data.
- id: UUID¶
- slug: str¶
- created_at: datetime.datetime¶
- updated_at: datetime.datetime¶
- status: ElectionStatus¶
- model_config: ClassVar[ConfigDict] = {'from_attributes': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: Annotated[str, Field(max_length=200)]¶
- description: str | None¶
- nominations_open: datetime.date¶
- nominations_close: datetime.date¶
- voting_open: datetime.date¶
- voting_close: datetime.date¶
- class NomineeBase[source]¶
Bases:
BaseModelBase nominee schema.
- election_id: UUID¶
- user_id: UUID¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class NomineeCreate[source]¶
Bases:
NomineeBaseSchema for creating a new nominee.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- election_id: UUID¶
- user_id: UUID¶
- class NomineeUpdate[source]¶
Bases:
BaseModelSchema for updating a nominee.
- accepted: bool | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class NomineeRead[source]¶
Bases:
NomineeBaseSchema for reading nominee data.
- id: UUID¶
- accepted: bool¶
- created_at: datetime.datetime¶
- updated_at: datetime.datetime¶
- model_config: ClassVar[ConfigDict] = {'from_attributes': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- election_id: UUID¶
- user_id: UUID¶
- class NominationBase[source]¶
Bases:
BaseModelBase nomination schema.
- nominee_id: UUID¶
- endorsement: str | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class NominationCreate[source]¶
Bases:
NominationBaseSchema for creating a new nomination.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- nominee_id: UUID¶
- endorsement: str | None¶
- class NominationUpdate[source]¶
Bases:
BaseModelSchema for updating a nomination.
- endorsement: str | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class NominationRead[source]¶
Bases:
NominationBaseSchema for reading nomination data.
- id: UUID¶
- nominator_id: UUID¶
- created_at: datetime.datetime¶
- updated_at: datetime.datetime¶
- model_config: ClassVar[ConfigDict] = {'from_attributes': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- nominee_id: UUID¶
- endorsement: str | None¶
- class ElectionPublic[source]¶
Bases:
BaseModelPublic election schema for listings.
- id: UUID¶
- slug: str¶
- name: str¶
- description: str | None¶
- nominations_open: datetime.date¶
- nominations_close: datetime.date¶
- voting_open: datetime.date¶
- voting_close: datetime.date¶
- status: ElectionStatus¶
- model_config: ClassVar[ConfigDict] = {'from_attributes': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class NomineePublic[source]¶
Bases:
BaseModelPublic nominee schema for listings.
- id: UUID¶
- election_id: UUID¶
- user_id: UUID¶
- accepted: bool¶
- model_config: ClassVar[ConfigDict] = {'from_attributes': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Repositories¶
Nominations domain repositories for database access.
- class ElectionRepository[source]¶
Bases:
SQLAlchemyAsyncRepository[Election]Repository for Election database operations.
- async get_by_status(status, limit=100, offset=0)[source]¶
Get elections by status.
- Parameters:
status (
ElectionStatus) – The election status to filter by.limit (
int) – Maximum number of elections to return.offset (
int) – Number of elections to skip.
- Return type:
- Returns:
List of elections with the specified status.
- class NomineeRepository[source]¶
Bases:
SQLAlchemyAsyncRepository[Nominee]Repository for Nominee database operations.
- class NominationRepository[source]¶
Bases:
SQLAlchemyAsyncRepository[Nomination]Repository for Nomination database operations.
- model_type¶
alias of
Nomination
- async get_by_nominee(nominee_id, limit=100, offset=0)[source]¶
Get nominations for a nominee.
- Parameters:
- Return type:
- Returns:
List of nominations for the nominee.
Services¶
Nominations domain services for business logic.
- class ElectionService[source]¶
Bases:
SQLAlchemyAsyncRepositoryService[Election, Any]Service for Election business logic.
- repository_type¶
alias of
ElectionRepository
- match_fields: ClassVar[Optional[Union[list[str], str]]] = ['slug']¶
List of dialects that prefer to use
field.id = ANY(:1)instead offield.id IN (...).
- async create_election(data)[source]¶
Create a new election.
- Parameters:
data (
ElectionCreate) – Election creation data.- Return type:
- Returns:
The created election instance.
- async get_by_status(status, limit=100, offset=0)[source]¶
Get elections by status.
- Parameters:
status (
ElectionStatus) – The election status to filter by.limit (
int) – Maximum number of elections to return.offset (
int) – Number of elections to skip.
- Return type:
- Returns:
List of elections with the specified status.
- class NomineeService[source]¶
Bases:
SQLAlchemyAsyncRepositoryService[Nominee, Any]Service for Nominee business logic.
- repository_type¶
alias of
NomineeRepository
- async create_nominee(election_id, user_id)[source]¶
Create a new nominee.
- Parameters:
- Return type:
- Returns:
The created nominee instance.
- Raises:
ValueError – If nominee already exists.
- async accept_nomination(nominee_id)[source]¶
Accept a nomination.
- Parameters:
nominee_id (
UUID) – The nominee ID.- Return type:
- Returns:
The updated nominee instance.
- Raises:
ValueError – If nominee is already accepted.
- class NominationService[source]¶
Bases:
SQLAlchemyAsyncRepositoryService[Nomination, Any]Service for Nomination business logic.
- repository_type¶
alias of
NominationRepository
- async create_nomination(nominee_id, nominator_id, endorsement=None)[source]¶
Create a new nomination.
- Parameters:
- Return type:
- Returns:
The created nomination instance.
- async get_by_nominee(nominee_id, limit=100, offset=0)[source]¶
Get nominations for a nominee.
- Parameters:
- Return type:
- Returns:
List of nominations for the nominee.
Controllers¶
Nominations domain API controllers.
- class ElectionController[source]¶
Bases:
ControllerController for Election 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.
- list_elections(fn) = <litestar.handlers.http_handlers.decorators.get object>¶
- list_active_elections(fn) = <litestar.handlers.http_handlers.decorators.get object>¶
- get_election(fn) = <litestar.handlers.http_handlers.decorators.get object>¶
- create_election(fn) = <litestar.handlers.http_handlers.decorators.post object>¶
- update_election(fn) = <litestar.handlers.http_handlers.decorators.put object>¶
- delete_election(fn) = <litestar.handlers.http_handlers.decorators.delete object>¶
- after_request: AfterRequestHookHandler | None¶
A sync or async function executed before a
Requestis 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
Requestinstance 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
Requestinstance and any non-Nonereturn value is used for the response, bypassing the route handler.
- cache_control: CacheControlHeader | None¶
A
CacheControlHeaderheader to add to route handlers of this controller.Can be overridden by route handlers.
- dependencies: Dependencies | None¶
A string keyed dictionary of dependency
Providerinstances.
- dto: type[AbstractDTO] | None | EmptyType¶
AbstractDTOto use for (de)serializing and validation of request data.
- etag: ETag | None¶
An
etagheader of typeETagto 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
Guardcallables.
- 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
Guardsor wherever you have access toRequestorASGI Scope.
- owner: Router¶
The
RouterorLitestarapp 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
Parameterdefinitions available to all application paths.
- request_class: type[Request] | None¶
A custom subclass of
Requestto 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
Responseto be used as the default response for all route handlers under the controller.
- response_cookies: ResponseCookies | None¶
A list of
Cookieinstances.
- response_headers: ResponseHeaders | None¶
A string keyed dictionary mapping
ResponseHeaderinstances.
- return_dto: type[AbstractDTO] | None | EmptyType¶
AbstractDTOto 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
WebSocketto be used as the default websocket for all route handlers under the controller.
- class NomineeController[source]¶
Bases:
ControllerController for Nominee 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.
- list_nominees(fn) = <litestar.handlers.http_handlers.decorators.get object>¶
- get_nominee(fn) = <litestar.handlers.http_handlers.decorators.get object>¶
- list_accepted_nominees(fn) = <litestar.handlers.http_handlers.decorators.get object>¶
- create_nominee(fn) = <litestar.handlers.http_handlers.decorators.post object>¶
- accept_nomination(fn) = <litestar.handlers.http_handlers.decorators.patch object>¶
- decline_nomination(fn) = <litestar.handlers.http_handlers.decorators.patch object>¶
- delete_nominee(fn) = <litestar.handlers.http_handlers.decorators.delete object>¶
- after_request: AfterRequestHookHandler | None¶
A sync or async function executed before a
Requestis 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
Requestinstance 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
Requestinstance and any non-Nonereturn value is used for the response, bypassing the route handler.
- cache_control: CacheControlHeader | None¶
A
CacheControlHeaderheader to add to route handlers of this controller.Can be overridden by route handlers.
- dependencies: Dependencies | None¶
A string keyed dictionary of dependency
Providerinstances.
- dto: type[AbstractDTO] | None | EmptyType¶
AbstractDTOto use for (de)serializing and validation of request data.
- etag: ETag | None¶
An
etagheader of typeETagto 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
Guardcallables.
- 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
Guardsor wherever you have access toRequestorASGI Scope.
- owner: Router¶
The
RouterorLitestarapp 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
Parameterdefinitions available to all application paths.
- request_class: type[Request] | None¶
A custom subclass of
Requestto 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
Responseto be used as the default response for all route handlers under the controller.
- response_cookies: ResponseCookies | None¶
A list of
Cookieinstances.
- response_headers: ResponseHeaders | None¶
A string keyed dictionary mapping
ResponseHeaderinstances.
- return_dto: type[AbstractDTO] | None | EmptyType¶
AbstractDTOto 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
WebSocketto be used as the default websocket for all route handlers under the controller.
- class NominationController[source]¶
Bases:
ControllerController for Nomination 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.
- list_nominations(fn) = <litestar.handlers.http_handlers.decorators.get object>¶
- get_nomination(fn) = <litestar.handlers.http_handlers.decorators.get object>¶
- create_nomination(fn) = <litestar.handlers.http_handlers.decorators.post object>¶
- delete_nomination(fn) = <litestar.handlers.http_handlers.decorators.delete object>¶
- after_request: AfterRequestHookHandler | None¶
A sync or async function executed before a
Requestis 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
Requestinstance 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
Requestinstance and any non-Nonereturn value is used for the response, bypassing the route handler.
- cache_control: CacheControlHeader | None¶
A
CacheControlHeaderheader to add to route handlers of this controller.Can be overridden by route handlers.
- dependencies: Dependencies | None¶
A string keyed dictionary of dependency
Providerinstances.
- dto: type[AbstractDTO] | None | EmptyType¶
AbstractDTOto use for (de)serializing and validation of request data.
- etag: ETag | None¶
An
etagheader of typeETagto 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
Guardcallables.
- 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
Guardsor wherever you have access toRequestorASGI Scope.
- owner: Router¶
The
RouterorLitestarapp 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
Parameterdefinitions available to all application paths.
- request_class: type[Request] | None¶
A custom subclass of
Requestto 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
Responseto be used as the default response for all route handlers under the controller.
- response_cookies: ResponseCookies | None¶
A list of
Cookieinstances.
- response_headers: ResponseHeaders | None¶
A string keyed dictionary mapping
ResponseHeaderinstances.
- return_dto: type[AbstractDTO] | None | EmptyType¶
AbstractDTOto 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
WebSocketto be used as the default websocket for all route handlers under the controller.
- class NominationsRenderController[source]¶
Bases:
ControllerController for rendering nominations 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
- list_elections_html(fn) = <litestar.handlers.http_handlers.decorators.get object>¶
- get_election_html(fn) = <litestar.handlers.http_handlers.decorators.get object>¶
- after_request: AfterRequestHookHandler | None¶
A sync or async function executed before a
Requestis 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
Requestinstance 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
Requestinstance and any non-Nonereturn value is used for the response, bypassing the route handler.
- cache_control: CacheControlHeader | None¶
A
CacheControlHeaderheader to add to route handlers of this controller.Can be overridden by route handlers.
- dependencies: Dependencies | None¶
A string keyed dictionary of dependency
Providerinstances.
- dto: type[AbstractDTO] | None | EmptyType¶
AbstractDTOto use for (de)serializing and validation of request data.
- etag: ETag | None¶
An
etagheader of typeETagto 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
Guardcallables.
- 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
Guardsor wherever you have access toRequestorASGI Scope.
- owner: Router¶
The
RouterorLitestarapp 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
Parameterdefinitions available to all application paths.
- request_class: type[Request] | None¶
A custom subclass of
Requestto 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
Responseto be used as the default response for all route handlers under the controller.
- response_cookies: ResponseCookies | None¶
A list of
Cookieinstances.
- response_headers: ResponseHeaders | None¶
A string keyed dictionary mapping
ResponseHeaderinstances.
- return_dto: type[AbstractDTO] | None | EmptyType¶
AbstractDTOto 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
WebSocketto be used as the default websocket for all route handlers under the controller.
- class NominationsHTMXController[source]¶
Bases:
ControllerHTMX controller for nominations form submissions.
- 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
- nominate_candidate(fn) = <litestar.handlers.http_handlers.decorators.post object>¶
- after_request: AfterRequestHookHandler | None¶
A sync or async function executed before a
Requestis 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
Requestinstance 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
Requestinstance and any non-Nonereturn value is used for the response, bypassing the route handler.
- cache_control: CacheControlHeader | None¶
A
CacheControlHeaderheader to add to route handlers of this controller.Can be overridden by route handlers.
- dependencies: Dependencies | None¶
A string keyed dictionary of dependency
Providerinstances.
- dto: type[AbstractDTO] | None | EmptyType¶
AbstractDTOto use for (de)serializing and validation of request data.
- etag: ETag | None¶
An
etagheader of typeETagto 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
Guardcallables.
- 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
Guardsor wherever you have access toRequestorASGI Scope.
- owner: Router¶
The
RouterorLitestarapp 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
Parameterdefinitions available to all application paths.
- request_class: type[Request] | None¶
A custom subclass of
Requestto 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
Responseto be used as the default response for all route handlers under the controller.
- response_cookies: ResponseCookies | None¶
A list of
Cookieinstances.
- response_headers: ResponseHeaders | None¶
A string keyed dictionary mapping
ResponseHeaderinstances.
- return_dto: type[AbstractDTO] | None | EmptyType¶
AbstractDTOto 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
WebSocketto be used as the default websocket for all route handlers under the controller.
Dependencies¶
Nominations domain dependency injection providers.
- async provide_election_repository(db_session)[source]¶
Provide an ElectionRepository instance.
- Return type:
- async provide_election_service(db_session)[source]¶
Provide an ElectionService instance.
- Return type:
- async provide_nominee_repository(db_session)[source]¶
Provide a NomineeRepository instance.
- Return type:
- async provide_nomination_repository(db_session)[source]¶
Provide a NominationRepository instance.
- Return type:
URLs¶
Nominations domain URL constants.