Skip to content

field_types

Definitions of custom types for ResourceConfig fields.

AmPmTime = Annotated[time, BeforeValidator(parse_ampm_time)] module-attribute

Clock time that can be parsed from a string in AM/PM 12-hour format, HH:MM AM/PM.

HexColor = Annotated[str, StringConstraints(pattern='^#[0-9A-Fa-f]{6}$')] module-attribute

Color hex string with 6 digits (no alpha), ie. "#AAAAAA", used for the color of individual resource calendars in the embedded calendar view

HtmlFormInputType = Literal['button', 'checkbox', 'color', 'date', 'datetime-local', 'email', 'file', 'hidden', 'image', 'month', 'number', 'password', 'range', 'reset', 'search', 'submit', 'tel', 'text', 'time', 'url', 'week'] module-attribute

Possible values for the type argument of a custom form input field.

CalendarInfo

Bases: BaseModel

Loaded from resource config yaml as the values under the calendars dictionary. Each identifies a Google calendar mapping to an individually reservable resource (ie. a single tennis court out of many).

Attributes:

Name Type Description
id str

The ID string for the Google calendar, of the form "[longhexstring]@group.calendar.google.com".

color HexColor | None

Color hex string with 6 digits (no alpha), ie. "#AAAAAA", used for the color of the Google calendar in the embedded calendar view. Can be omitted from the yaml dict if you don't care. Also it will not be used if a resource has more than 4 calendars, since then the calendars won't be shown.Defaults to None.

CustomFormField

Bases: BaseModel

Custom html form input fields can be defined for a resource, either globally in app-config.yaml, or per resource in its own resource config yaml file. You can directly specify any additional legal html form attributes as a key/value pair. Just make sure to also subclass the ReservationRequest model for proper validation of custom fields.

Attributes:

Name Type Description
type HtmlFormInputType

A string specifying for one of the legal form input types.

name str

The name value is used by both an input's returned key name (made accessible to ReservationRequest for validation) and id attribute (for linking the input to the label).

label str

The label text that appears above the form input box.

required bool

Whether the field is requiered. Defaults to True.

title str

This is the "tool tip" text that will appear over the input when you mouse over it.

ImageFile

Bases: BaseModel

Bundle of info for an image to display on a reservation webpage. Uses the image's actual dimensions if not specified. If both pixel_width and pixel_height are None, then the rendered image uses the original image's actual dimensions. If only one of them is None, then the rendered image keeps the original image's aspect ratio.

Attributes:

Name Type Description
path Path

Image filepath. Must be relative to the resource-configs directory.

caption str

Caption to display for the image. Defaults to "".

pixel_width int | None

Desired pixel width for the displayed image. Defaults to None. See above for behavior details.

pixel_height int | None

Desired pixel height for the displayed image. Defaults to None. See above for behavior details.