gazette.models.notice

Classes

CachedUserNameMixin

Mixin providing a cached version of the user name.

CachedGroupNameMixin

Mixin providing a cached version of the group name.

GazetteNoticeFile

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

GazetteNotice

An official notice with extras.

GazetteNoticeChange

A changelog entry for an official notice.

Module Contents

class gazette.models.notice.CachedUserNameMixin[source]

Mixin providing a cached version of the user name.

There needs to be:

  • a user relationship (which has no dynamic backref)

  • a meta column

The observer needs to be registered in the children:

@observes('user', 'user.realname', 'user.username')
def user_observer(self, user, realname, username):
    if hasattr(self, '_user_observer'):
        self._user_observer(user, realname, username)
user: sqlalchemy.orm.relationship[onegov.user.User | None] | sqlalchemy.orm.relationship[onegov.user.User][source]
_user_name: onegov.core.orm.mixins.dict_property[str | None][source]
property user_name: str | None[source]

Returns the name of the owner.

If the user has been deleted, the last known name in brackets is returned.

_user_observer(user: onegov.user.User | None, realname: str | None, username: str | None) None[source]

Upates the last known name of the owner.

This never deletes the stored name, set self._user_name yourself if you want to clear it.

class gazette.models.notice.CachedGroupNameMixin[source]

Mixin providing a cached version of the group name.

There needs to be:

  • a group relationship (which has no dynamic backref)

  • a meta column

The observer needs to be registered in the children:

@observes('group', 'group.name')
def group_observer(self, group, name):
    if hasattr(self, '_group_observerr'):
        self._group_observerr(user, realname, username)
group: sqlalchemy.orm.relationship[onegov.user.UserGroup | None] | sqlalchemy.orm.relationship[onegov.user.UserGroup][source]
_group_name: onegov.core.orm.mixins.dict_property[str | None][source]
property group_name: str | None[source]

Returns the name of the group this notice belongs to.

If the group has been deleted, the last known name in brackets is returned.

_group_observer(group: UserGroup | None, name: str | None) None[source]

Upates the last known name of the group.

This never deletes the stored name, set self._group_name yourself if you want to clear it.

class gazette.models.notice.GazetteNoticeFile[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_official_notices: sqlalchemy.orm.relationship[list[GazetteNotice]][source]
class gazette.models.notice.GazetteNotice[source]

Bases: onegov.notice.OfficialNotice, CachedUserNameMixin, CachedGroupNameMixin, onegov.file.AssociatedFiles

An official notice with extras.

We use a combination of the categories/organizations HSTORE and the individual category/organization columns. The ID of the category/ organization is stored in the HSTORE column and the actual name ist copied when calling apply_meta.

We store only the issue names (year-number) in the HSTORE.

It’s possible to add a changelog entry by calling add_change. Changelog entries are created for state changes by default.

The user name accessible by user_name gets cached in case the user is deleted.

The group name accessible by group_name gets cached in case the group is deleted.

__mapper_args__[source]
print_only: onegov.core.orm.mixins.dict_property[bool | None][source]
at_cost: onegov.core.orm.mixins.dict_property[bool | None][source]
billing_address: onegov.core.orm.mixins.dict_property[str | None][source]
changes: relationship[AppenderQuery[GazetteNoticeChange]][source]
user_observer(user: onegov.user.User | None, realname: str | None, username: str | None) None[source]
group_observer(group: UserGroup | None, name: str | None) None[source]
add_change(request: onegov.gazette.request.GazetteRequest, event: str, text: str | None = None) None[source]

Adds en entry to the changelog.

submit(request: onegov.gazette.request.GazetteRequest) None[source]

Submit a drafted notice.

This automatically adds en entry to the changelog.

reject(request: onegov.gazette.request.GazetteRequest, comment: str) None[source]

Reject a submitted notice.

This automatically adds en entry to the changelog.

accept(request: onegov.gazette.request.GazetteRequest) None[source]

Accept a submitted notice.

This automatically adds en entry to the changelog.

publish(request: onegov.gazette.request.GazetteRequest) None[source]

Publish an accepted notice.

This automatically adds en entry to the changelog.

property rejected_comment: str[source]

Returns the comment of the last rejected change log entry.

property issues: dict[str, str | None][source]

Returns the issues sorted (by year/number).

property issue_objects: list[onegov.gazette.models.issue.Issue][source]
set_publication_number(issue: str, number: int) None[source]
property category_id: str | None[source]

The ID of the category. We store this the ID in the HSTORE (we use only one!) and additionaly store the title of the category in the category column.

property category_object: onegov.gazette.models.category.Category | None[source]
property organization_id: str | None[source]

The ID of the organization. We store this the ID in the HSTORE (we use only one!) and additionaly store the title of the organization in the organization column.

property organization_object: onegov.gazette.models.organization.Organization | None[source]
property overdue_issues: bool[source]

Returns True, if any of the issue’s deadline is reached.

property expired_issues: bool[source]

Returns True, if any of the issue’s issue date is reached.

property invalid_category: bool[source]

Returns True, if the category is invalid or inactive.

property invalid_organization: bool[source]

Returns True, if the organization is invalid or inactive.

apply_meta(session: sqlalchemy.orm.Session) None[source]

Updates the category, organization and issue date from the meta values.

class gazette.models.notice.GazetteNoticeChange[source]

Bases: onegov.chat.Message, CachedUserNameMixin

A changelog entry for an official notice.

__mapper_args__[source]
user: relationship[User | None][source]
user_observer(user: onegov.user.User | None, realname: str | None, username: str | None) None[source]
notice: relationship[GazetteNotice][source]
event: onegov.core.orm.mixins.dict_property[str | None][source]