lino.mixins.registrable

This defines the Registable model mixin.

(This module's source code is available here.)

Classes

Registrable(*args, **kwargs)

Base class to anything that may be "registered" and "deregistered" (e.g.

RegistrableState([value, text, name])

Base class

ToggleState([label])

class lino.mixins.registrable.RegistrableState(value=None, text=None, name=None, **kwargs)

Bases: lino.core.workflows.State

Base class

is_editable = True

Whether the registrable object having this state should be editable or not.

class lino.mixins.registrable.Registrable(*args, **kwargs)

Bases: lino.core.model.Model

Base class to anything that may be "registered" and "deregistered" (e.g. Invoices, Vouchers, Declarations, Reservations,...). "Registered" means "this object has been taken account of". Registered objects are not editable.

state

The ChoiceList of this field must have at least two items named "draft" and "registered". There may be additional states. Every state must have an extra attribute "is_editable".

classmethod get_registrable_fields(site)

Return a list of the fields that are disabled when this is registered (i.e. state is not editable).

Usage example:

class MyModel(dd.Registrable):

    @classmethod
    def get_registrable_fields(self, site):
        for f in super(MyModel, self).get_registrable_fields(site):
            yield f
        yield 'user'
        yield 'date'
get_row_permission(ar, state, ba)

Only rows in an editable state may be edited.

Note that ba is the action being requested while ar.bound_action is the action from which the request was started.

register(ar)

Register this object. The base implementation just sets the state to "registered".

Subclasses may override this to add custom behaviour. Instead of subclassing you can also override set_workflow_state, before_state_change or after_state_change.

deregister(ar)

Deregister this object. The base implementation just sets the state to "draft".

Subclasses may override this to add custom behaviour. Instead of subclassing you can also override set_workflow_state, before_state_change or after_state_change.