swissvotes.fields.policy_area

Classes

PolicyAreaTreeNode

dict() -> new empty dictionary

PolicyAreaWidget

The widget for the React Dropdown Tree.

PolicyAreaField

A select field with React Dropdown Tree support.

Module Contents

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: NotRequired[bool][source]
checked: 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: str | None = None, validators: onegov.form.types.Validators[onegov.form.types.FormT, Self] | None = None, *, tree: list[PolicyAreaTreeNode] = ..., filters: collections.abc.Sequence[onegov.form.types.Filter] = (), description: str = '', id: str | None = None, default: object | None = None, widget: onegov.form.types.Widget[Self] | None = None, option_widget: onegov.form.types.Widget[wtforms.fields.choices.SelectFieldBase._Option] | None = None, render_kw: dict[str, Any] | None = None, name: str | None = None, _form: wtforms.form.BaseForm | None = None, _prefix: str = '', _translations: wtforms.meta._SupportsGettextAndNgettext | None = None, _meta: wtforms.meta.DefaultMeta | None = None, fieldset: str | None = None, depends_on: collections.abc.Sequence[Any] | None = None, pricing: onegov.form.types.PricingRules | None = None)[source]

Bases: wtforms.fields.SelectMultipleField

A select field with React Dropdown Tree support.

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

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