directory.models.directory

Attributes

InheritType

INHERIT

Classes

_Sentinel

Create a collection of name/value pairs.

DirectoryFile

A general file (image, document, pdf, etc), referenced in the database.

Directory

A directory of entries that share a common data structure. For example,

EntryRecipient

Represents a single recipient.

EntrySubscription

Adds subscription management to a recipient.

Module Contents

directory.models.directory.InheritType: TypeAlias = 'Literal[_Sentinel.INHERIT]'[source]
class directory.models.directory._Sentinel(*args, **kwds)[source]

Bases: enum.Enum

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

>>> Color.RED
<Color.RED: 1>
  • value lookup:

>>> Color(1)
<Color.RED: 1>
  • name lookup:

>>> Color['RED']
<Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

INHERIT[source]
directory.models.directory.INHERIT[source]
class directory.models.directory.DirectoryFile[source]

Bases: onegov.file.File

A general file (image, document, pdf, etc), referenced in the database.

Thanks to the use of Depot files can be seemingly stored in the database (with transaction guarantees), without actually storing it in the database.

__mapper_args__[source]
linked_directory_entries: sqlalchemy.orm.relationship[list[directory.models.directory_entry.DirectoryEntry]][source]
property directory_entry: directory.models.directory_entry.DirectoryEntry | None[source]
property access: str[source]
class directory.models.directory.Directory[source]

Bases: onegov.core.orm.Base, onegov.core.orm.mixins.ContentMixin, onegov.core.orm.mixins.TimestampMixin, onegov.search.SearchableContent, onegov.file.MultiAssociatedFiles

A directory of entries that share a common data structure. For example, a directory of people, of emergency services or playgrounds.

__tablename__ = 'directories'[source]
es_properties[source]

Returns the type mapping of this model. Each property in the mapping will be read from the model instance.

The returned object needs to be a dict or an object that provides a to_dict method.

Internally, onegov.search stores differing languages in different indices. It does this automatically through langauge detection, or by manually specifying a language.

Note that objects with multiple languages are not supported (each object is supposed to have exactly one language).

Onegov.search will automatically insert the right analyzer for types like these.

There’s currently only limited support for properties here, namely objects and nested mappings do not work! This is going to be added in the future though.

property es_public: bool[source]

Returns True if the model is available to be found by the public. If false, only editors/admins will see this object in the search results.

id: sqlalchemy.Column[uuid.UUID][source]
name: sqlalchemy.Column[str][source]
title: sqlalchemy.Column[str][source]
lead: sqlalchemy.Column[str | None][source]
order: sqlalchemy.Column[str][source]
type: sqlalchemy.Column[str][source]
structure: sqlalchemy.Column[str][source]
configuration: sqlalchemy.Column[directory.types.DirectoryConfiguration][source]
count() sqlalchemy.sql.ColumnElement[int][source]
__mapper_args__[source]
entries: sqlalchemy.orm.relationship[list[directory.models.directory_entry.DirectoryEntry]][source]
property entry_cls_name: str[source]
property entry_cls: type[directory.models.directory_entry.DirectoryEntry][source]
add(values: dict[str, Any], type: str | InheritType = INHERIT) directory.models.directory_entry.DirectoryEntry[source]
add_by_form(form: DirectoryEntryForm, type: str | InheritType = INHERIT) directory.models.directory_entry.DirectoryEntry[source]
update(entry: directory.models.directory_entry.DirectoryEntry, values: collections.abc.Mapping[str, Any], set_name: bool = False, force_update: bool = False) directory.models.directory_entry.DirectoryEntry[source]
title_observer(title: str) None[source]
structure_configuration_observer(structure: str, configuration: directory.types.DirectoryConfiguration) None[source]
entry_with_name_exists(name: str) bool[source]
migration(new_structure: str, new_configuration: directory.types.DirectoryConfiguration) onegov.directory.migration.DirectoryMigration[source]
property fields: collections.abc.Sequence[onegov.form.parser.core.ParsedField][source]
static fields_from_structure(structure: str) collections.abc.Sequence[onegov.form.parser.core.ParsedField][source]
property basic_fields: collections.abc.Sequence[onegov.form.parser.core.BasicParsedField][source]
property file_fields: collections.abc.Sequence[onegov.form.parser.core.FileParsedField][source]
field_by_id(id: str) onegov.form.parser.core.ParsedField | None[source]
property form_obj: DirectoryEntryForm[source]
property form_class: type[DirectoryEntryForm][source]
form_obj_from_structure(structure: str) DirectoryEntryForm[source]
form_class_from_structure(structure: str) type[Directory.form_class_from_structure.DirectoryEntryForm][source]
class directory.models.directory.EntryRecipient[source]

Bases: onegov.core.orm.Base, onegov.core.orm.mixins.TimestampMixin

Represents a single recipient.

__tablename__ = 'entry_recipients'[source]
id: sqlalchemy.Column[uuid.UUID][source]
address: sqlalchemy.Column[str][source]
validate_address(key: str, address: str) str[source]
token: sqlalchemy.Column[str][source]
confirmed: sqlalchemy.Column[bool][source]
property subscription: EntrySubscription[source]
directory_id: sqlalchemy.Column[uuid.UUID][source]
class directory.models.directory.EntrySubscription(recipient: EntryRecipient, token: str)[source]

Adds subscription management to a recipient.

recipient[source]
token[source]
property recipient_id: uuid.UUID[source]
confirm() bool[source]
unsubscribe() bool[source]