org.models.extensions

Attributes

FILE_URL_RE

Classes

SupportsExtendForm

Base class for protocol classes.

ContentExtension

Extends classes based on onegov.core.orm.mixins.ContentMixin

AccessExtension

Extends any class that has a meta dictionary field with the ability to

CoordinatesExtension

Extends any class that has a data dictionary field with the ability

VisibleOnHomepageExtension

Extends any class that has a meta dictionary field with the ability to

ContactExtensionBase

Common base class for extensions that add a contact field.

ContactExtension

Extends any class that has a content dictionary field with a simple

InheritableContactExtension

Extends any class that has a content dictionary field with a simple

ContactHiddenOnPageExtension

Extends any class that has a content dictionary field with a simple

PeopleShownOnMainPageExtension

Extends any class that has a content dictionary field with a simple

NewsletterExtension

Extends classes based on onegov.core.orm.mixins.ContentMixin

PersonWithFunction

A person.

PersonLinkExtension

Extends any class that has a content dictionary field with the ability

ResourceValidationExtension

Extends classes based on onegov.core.orm.mixins.ContentMixin

PublicationExtension

Extends classes based on onegov.core.orm.mixins.ContentMixin

HoneyPotExtension

Extends classes based on onegov.core.orm.mixins.ContentMixin

ImageExtension

Extends classes based on onegov.core.orm.mixins.ContentMixin

GeneralFileLinkExtension

Extends any class that has a files relationship to reference files from

SidebarLinksExtension

Extends classes based on onegov.core.orm.mixins.ContentMixin

DeletableContentExtension

Extends any class that has a meta dictionary field with the ability to

Functions

_files_observer(→ None)

_content_file_link_observer(→ None)

Module Contents

class org.models.extensions.SupportsExtendForm[source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto(Protocol[T]):
    def meth(self) -> T:
        ...
extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]
class org.models.extensions.ContentExtension[source]

Extends classes based on onegov.core.orm.mixins.ContentMixin with custom data that is stored in either ‘meta’ or ‘content’.

meta: sqlalchemy.Column[dict[str, Any]][source]
property content_extensions: Iterator[type[ContentExtension]][source]

Returns all base classes of the current class which themselves have ContentExtension as baseclass.

with_content_extensions(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest, extensions: Iterable[type[SupportsExtendForm]] | None = None) type[onegov.form.types.FormT][source]

Takes the given form and request and extends the form with all content extensions in the order in which they occur in the base class list.

In other words, extends the forms with all used extension-fields.

abstract extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.AccessExtension[source]

Bases: ContentExtension

Extends any class that has a meta dictionary field with the ability to set one of the following access levels:

  • ‘public’ - The default, the model is listed and accessible.

  • ‘private’ - Neither listed nor accessible, except administrators

    and editors.

  • ‘member’ - Neither listed nor accessible except administrators, editors

    and members.

  • ‘secret’ - Not listed, but available for anyone that knows the URL.

  • ‘mtan’ - The model is listed but only accessible once an mTAN has been

    sent to the person and entered correctly.

  • ‘secret_mtan’ - Not listed and only accessible once an mTAN has been

    sent to the person and entered correctly.

see onegov.core.security.rules.has_permission_not_logged_in()

access: onegov.core.orm.mixins.dict_property[str][source]
extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.CoordinatesExtension[source]

Bases: ContentExtension, onegov.gis.CoordinatesMixin

Extends any class that has a data dictionary field with the ability to add coordinates to it.

extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.VisibleOnHomepageExtension[source]

Bases: ContentExtension

Extends any class that has a meta dictionary field with the ability to a boolean indicating if the page should be shown on the homepage or not.

is_visible_on_homepage: onegov.core.orm.mixins.dict_property[bool | None][source]
extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.ContactExtensionBase[source]

Common base class for extensions that add a contact field.

contact: onegov.core.orm.mixins.dict_property[str | None][source]
property contact_html: markupsafe.Markup | None[source]
get_contact_html(request: onegov.org.request.OrgRequest) markupsafe.Markup | None[source]
extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]
class org.models.extensions.ContactExtension[source]

Bases: ContactExtensionBase, ContentExtension

Extends any class that has a content dictionary field with a simple contacts field.

class org.models.extensions.InheritableContactExtension[source]

Bases: ContactExtensionBase, ContentExtension

Extends any class that has a content dictionary field with a simple contacts field, that can optionally be inherited from another topic.

inherit_contact: onegov.core.orm.mixins.dict_property[bool][source]
contact_inherited_from: onegov.core.orm.mixins.dict_property[int | None][source]
get_contact_html(request: onegov.org.request.OrgRequest) markupsafe.Markup | None[source]
extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.ContactHiddenOnPageExtension[source]

Bases: ContentExtension

Extends any class that has a content dictionary field with a simple contacts field.

hide_contact: onegov.core.orm.mixins.dict_property[bool][source]
extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.PeopleShownOnMainPageExtension[source]

Bases: ContentExtension

Extends any class that has a content dictionary field with a simple contacts field where people will be shown on bottom of main page.

Note: Feature limited to org and town6

show_people_on_main_page: onegov.core.orm.mixins.dict_property[bool][source]
extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.NewsletterExtension[source]

Bases: ContentExtension

Extends classes based on onegov.core.orm.mixins.ContentMixin with custom data that is stored in either ‘meta’ or ‘content’.

text_in_newsletter: onegov.core.orm.mixins.dict_property[bool][source]
extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.PersonWithFunction[source]

Bases: onegov.people.Person

A person.

person: str[source]
context_specific_function: str[source]
display_function_in_person_directory: bool[source]
class org.models.extensions.PersonLinkExtension[source]

Bases: ContentExtension

Extends any class that has a content dictionary field with the ability to reference people from onegov.people.PersonCollection.

western_name_order: onegov.core.orm.mixins.dict_property[bool][source]
property people: list[PersonWithFunction] | None[source]

Returns the people linked to this content or None.

The context specific function is temporarily stored on the context_specific_function attribute on each object in the resulting list. Similarly, to indicate if we want to show a particular function in the page of a person, display_function_in_person_directory is temporarily stored on each object of the resulting list.

get_selectable_people(request: onegov.org.request.OrgRequest) list[onegov.people.Person][source]

Returns a list of people which may be linked.

get_person_function_by_id(id: str) tuple[str, bool][source]
move_person(subject: str, target: str, direction: onegov.core.orm.abstract.MoveDirection) None[source]

Moves the subject below or above the target.

Subject:

The key of the person to be moved.

Target:

The key of the person above or below which the subject is moved.

Direction:

The direction relative to the target.

extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.ResourceValidationExtension[source]

Bases: ContentExtension

Extends classes based on onegov.core.orm.mixins.ContentMixin with custom data that is stored in either ‘meta’ or ‘content’.

extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.PublicationExtension[source]

Bases: ContentExtension

Extends classes based on onegov.core.orm.mixins.ContentMixin with custom data that is stored in either ‘meta’ or ‘content’.

extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.HoneyPotExtension[source]

Bases: ContentExtension

Extends classes based on onegov.core.orm.mixins.ContentMixin with custom data that is stored in either ‘meta’ or ‘content’.

honeypot[source]
extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.ImageExtension[source]

Bases: ContentExtension

Extends classes based on onegov.core.orm.mixins.ContentMixin with custom data that is stored in either ‘meta’ or ‘content’.

page_image[source]
show_preview_image[source]
show_page_image[source]
extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

org.models.extensions.FILE_URL_RE[source]
org.models.extensions._files_observer(self: GeneralFileLinkExtension, files: list[onegov.file.File], meta: set[str], publication_start: datetime | None = None, publication_end: datetime | None = None) None[source]
class org.models.extensions.GeneralFileLinkExtension[source]

Bases: ContentExtension

Extends any class that has a files relationship to reference files from onegov.org.models.file.GeneralFileCollection.

Additionally any files linked within the object’s content will be added to the explicit list of linked files and access is propagated from the owner of the link to the file.

id: Any[source]
extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.SidebarLinksExtension[source]

Bases: ContentExtension

Extends classes based on onegov.core.orm.mixins.ContentMixin with custom data that is stored in either ‘meta’ or ‘content’.

extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.

class org.models.extensions.DeletableContentExtension[source]

Bases: ContentExtension

Extends any class that has a meta dictionary field with the ability to mark the content as deletable after reaching the end date. A cronjob will periodically check for ‘deletable’ content with expired end date and delete it e.g. Directories.

delete_when_expired: onegov.core.orm.mixins.dict_property[bool][source]
extend_form(form_class: type[onegov.form.types.FormT], request: onegov.org.request.OrgRequest) type[onegov.form.types.FormT][source]

Must be implemented by each ContentExtension. Takes the form class without extension and adds the required fields to it.