swissvotes.fields.policy_area

Module Contents

Classes

PolicyAreaTreeNode

dict() -> new empty dictionary

PolicyAreaWidget

The widget for the React Dropdown Tree.

PolicyAreaField

A select field with React Dropdown Tree support.

class swissvotes.fields.policy_area.PolicyAreaTreeNode[source]

Bases: TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

value: str[source]
label: str[source]
children: list[PolicyAreaTreeNode][source]
expanded: typing_extensions.NotRequired[bool][source]
checked: typing_extensions.NotRequired[bool][source]
class swissvotes.fields.policy_area.PolicyAreaWidget(multiple=False)[source]

Bases: wtforms.widgets.Select

The widget for the React Dropdown Tree.

__call__(field: PolicyAreaField, **kwargs: object) markupsafe.Markup[source]
classmethod render_option(value: str, label: str, selected: bool, **kwargs: object) markupsafe.Markup[source]

Adds a level specific class to each option.

This allows to see the hierarchy in case the client has disabled javascript.

class swissvotes.fields.policy_area.PolicyAreaField(label=None, validators=None, coerce=str, choices=None, validate_choice=True, **kwargs)[source]

Bases: wtforms.fields.SelectMultipleField

A select field with React Dropdown Tree support.

property tree: list[PolicyAreaTreeNode][source]

Returns the tree data and automatically preselects the selected select options.

data: list[str] | None[source]
choices: list[tuple[str, str]][source]
widget[source]