election_day.directives

Attributes

FormCallable

Classes

ManageHtmlAction

HTML directive for manage views which makes sure the permission is set

ManageFormAction

HTML directive for manage forms which makes sure the permission is set

SvgFileViewAction

View directive for viewing SVG files from filestorage. The SVGs

PdfFileViewAction

View directive for viewing PDF files from filestorage. The PDFs

JsonFileAction

View directive for viewing JSON data as file.

CsvFileAction

View directive for viewing CSV data as file.

ScreenWidgetRegistry

dict() -> new empty dictionary

ScreenWidgetAction

Register a screen widget.

Functions

render_svg(→ morepath.request.Response)

render_pdf(→ morepath.request.Response)

render_json(→ morepath.request.Response)

render_csv(→ morepath.request.Response)

Module Contents

election_day.directives.FormCallable: TypeAlias = Callable[[Any, _RequestT], type[Form]][source]
class election_day.directives.ManageHtmlAction(model: type | str, render: Callable[[Any, _RequestT], BaseResponse] | str | None = None, template: StrOrBytesPath | None = None, load: Callable[[_RequestT], Any] | str | None = None, permission: object | str | None = None, internal: bool = False, **predicates: Any)[source]

Bases: morepath.directive.HtmlAction

HTML directive for manage views which makes sure the permission is set to private.

class election_day.directives.ManageFormAction(model: type | str, form: type[Form] | FormCallable[_RequestT] = EmptyForm, render: Callable[[Any, _RequestT], BaseResponse] | str | None = None, template: _typeshed.StrOrBytesPath = 'form.pt', load: Callable[[_RequestT], Any] | str | None = None, permission: object | str | None = None, internal: bool = False, **predicates: Any)[source]

Bases: onegov.core.directives.HtmlHandleFormAction

HTML directive for manage forms which makes sure the permission is set to private. Sets a valid default for the template and form class.

election_day.directives.render_svg(content: dict[str, Any], request: onegov.core.request.CoreRequest) morepath.request.Response[source]
election_day.directives.render_pdf(content: dict[str, Any], request: onegov.core.request.CoreRequest) morepath.request.Response[source]
election_day.directives.render_json(content: dict[str, Any], request: onegov.core.request.CoreRequest) morepath.request.Response[source]
election_day.directives.render_csv(content: dict[str, Any], request: onegov.core.request.CoreRequest) morepath.request.Response[source]
class election_day.directives.SvgFileViewAction(model: type | str, load: Callable[[_RequestT], Any] | str | None = None, permission: object | str = Public, internal: bool = False, **predicates: Any)[source]

Bases: morepath.directive.ViewAction

View directive for viewing SVG files from filestorage. The SVGs are created using a cronjob and might not be available.

class election_day.directives.PdfFileViewAction(model: type | str, load: Callable[[_RequestT], Any] | str | None = None, permission: object | str = Public, internal: bool = False, **predicates: Any)[source]

Bases: morepath.directive.ViewAction

View directive for viewing PDF files from filestorage. The PDFs are created using a cronjob and might not be available.

class election_day.directives.JsonFileAction(model: type | str, load: Callable[[_RequestT], Any] | str | None = None, permission: object | str = Public, internal: bool = False, **predicates: Any)[source]

Bases: morepath.directive.ViewAction

View directive for viewing JSON data as file.

class election_day.directives.CsvFileAction(model: type | str, load: Callable[[_RequestT], Any] | str | None = None, permission: object | str = Public, internal: bool = False, **predicates: Any)[source]

Bases: morepath.directive.ViewAction

View directive for viewing CSV data as file.

class election_day.directives.ScreenWidgetRegistry[source]

Bases: dict[str, dict[str, ScreenWidget]]

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)

by_categories(categories: Iterable[str]) dict[str, ScreenWidget][source]
class election_day.directives.ScreenWidgetAction(tag: str, category: str)[source]

Bases: dectate.Action

Register a screen widget.

config[source]

Describe configuration.

A dict mapping configuration names to factory functions. The resulting configuration objects are passed into Action.identifier(), Action.discriminators(), Action.perform(), and Action.before() and Action.after().

After commit completes, the configured objects are found as attributes on App.config.

tag[source]
category[source]
identifier(screen_widget_registry: ScreenWidgetRegistry) str[source]

Returns an immutable that uniquely identifies this config.

Needs to be implemented by the Action subclass.

Used for overrides and conflict detection.

If two actions in the same group have the same identifier in the same configurable, those two actions are in conflict and a ConflictError is raised during commit().

If an action in an extending configurable has the same identifier as the configurable being extended, that action overrides the original one in the extending configurable.

Parameters:

**kw – a dictionary of configuration objects as specified by the config class attribute.

Returns:

an immutable value uniquely identifying this action.

perform(func: Callable[[], InputScreenWidget], screen_widget_registry: ScreenWidgetRegistry) None[source]

Do whatever configuration is needed for obj.

Needs to be implemented by the Action subclass.

Raise a DirectiveError to indicate that the action cannot be performed due to incorrect configuration.

Parameters:
  • obj – the object that the action should be performed for. Typically a function or a class object.

  • **kw – a dictionary of configuration objects as specified by the config class attribute.