org.models.document_form

Classes

DocumentFormFile

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

FormDocument

Mixin providing a meta/content JSON pair. Meta is a JSON column loaded

FormDocumentCollection

Abstract base class for generic types.

Module Contents

class org.models.document_form.DocumentFormFile[source]

Bases: onegov.file.File, onegov.file.SearchableFile

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]
es_type_name = 'document_form_file'[source]

Returns the unique type name of the model.

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.

class org.models.document_form.FormDocument[source]

Bases: onegov.core.orm.Base, onegov.core.orm.mixins.ContentMixin, onegov.core.orm.mixins.TimestampMixin, onegov.org.models.AccessExtension, onegov.search.SearchableContent, onegov.file.AssociatedFiles

Mixin providing a meta/content JSON pair. Meta is a JSON column loaded with each request, content is a JSON column loaded deferred (to be shown only in the detail view).

__tablename__ = 'form_documents'[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.

id: sqlalchemy.Column[uuid.UUID][source]
name: sqlalchemy.Column[str][source]
title: sqlalchemy.Column[str][source]
lead: onegov.core.orm.mixins.dict_property[str | None][source]
text[source]
pdf = None[source]
member_of: sqlalchemy.Column[str | None][source]
group: sqlalchemy.Column[str | None][source]
order: sqlalchemy.Column[str][source]
pdf_extract: onegov.core.orm.mixins.dict_property[str | None][source]
pdf_observer(pdf: DocumentFormFile | None) None[source]
title_observer(title: str) None[source]
es_type_name = 'document_pages'[source]

Returns the unique type name of the model.

es_id = 'title'[source]

The name of the id attribute (not the actual value!).

If you use this on an ORM model, be sure to use a primary key, all other properties are not available during deletion.

class org.models.document_form.FormDocumentCollection(session: sqlalchemy.orm.Session, member_of: str | None = None, group: str | None = None, type: str | None = None)[source]

Bases: onegov.core.collection.GenericCollection[FormDocument]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
supported_collections[source]
member_of = None[source]
group = None[source]
type = None[source]
static translatable_name(model_class: type[object]) str[source]

Most collections have a base model whose name can be guessed from the collection name.

form_choices() tuple[tuple[str, str], Ellipsis][source]
by_name(name: str) FormDocument | None[source]

Returns the given form by name or None.

classmethod collection_by_name() dict[str, type[onegov.core.collection.GenericCollection[Any]]][source]
property model_class: type[FormDocument][source]
classmethod target(external_link: FormDocument) type[onegov.core.collection.GenericCollection[Any]][source]
query() sqlalchemy.orm.Query[FormDocument][source]