Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

lino.core.dbtables

This defines the Table class.

Functions

add_gridfilters(qs, gridfilters)

Converts a filter request in the format used by http://extjs-ux.org/ext-docs/?class=Ext.ux.grid.GridFilters into a Django field lookup on a django.db.models.query.QuerySet.

base_attrs(cl)

column_choices(rptname)

has_fk(ar, name)

model2actor(m)

rc_name(rptclass)

table_factory(model)

Automatically define a Table class for the specified model.

Classes

Table(*args, **kw)

An AbstractTable that works on a Django Model using a QuerySet.

lino.core.dbtables.add_gridfilters(qs, gridfilters)

Converts a filter request in the format used by http://extjs-ux.org/ext-docs/?class=Ext.ux.grid.GridFilters into a Django field lookup on a django.db.models.query.QuerySet.

Parameters:
  • qs – the queryset to be modified.

  • gridfilters – a list of dictionaries, each having 3 keys field, type and value.

class lino.core.dbtables.Table(*args, **kw)

Bases: AbstractTable

An AbstractTable that works on a Django Model using a QuerySet.

A Table inherits from AbstractTable and adds attributes like model and master and master_key who are important because Lino handles relations automagically.

Another class of attributes are filter, exclude and sort_order which are thin wrappers to Django’s query lookup parameters of same name.

See dd.Table.

model = None

See lino.core.actors.Actor.model

screenshot_profiles = ['admin']

The user user_type(s) for which we want a screenshot of this table.

use_as_default_table = True

Set this to False if this actor should not become the model’s default table.

live_panel_update = False

Whether the front end should update panels on this table when the underlying database has been modified. This doesn’t work unless there is a linod running. Currently works only under the React front end.

expand_memos = False

(No longer used; see https://gitlab.com/lino-framework/lino/blob/master/docs/tickets/44). Whether multi-line text fields in Grid views should be expanded in by default or not.

use_detail_params_value = False

If when in a detail view will override default param values with the detail’s pv values.

Specifies whether this table uses PostgreSQL’s full text search capabilities.

Shuts off the lino’s quick search feature.

classmethod add_quick_search_filter(qs, search_text)

Add a filter to the given queryset qs in order to apply a quick search for the given search_text.

classmethod get_detail_sets()

Yield a list of (app_label,name) tuples for which the kernel should try to create a Detail Set.

classmethod get_row_by_pk(ar, pk)

Implements get_row_by_pk for a database table.

Note: ar must not be None.

classmethod get_row_permission(obj, ar, state, ba)

Returns True if the given action is allowed for the given instance obj and the given user.

classmethod disable_delete(obj, ar)

Return either None if the given obj is allowed to be deleted by action request ar, or a string with a message explaining why, if not.

classmethod create_instance(ar, **kw)

Create a model instance using the specified keyword args, calling also lino.core.model.Model.on_create().

classmethod after_create_instance(obj, ar)

A hook for code to be executed when a new instance has been created in this table.

This is for actor-specific behaviour. You can do the equivalent for every table on a model by defining an after_ui_create method on the model.

Usage example: lino_xl.lib.cal.GuestsByPartner.

lino.core.dbtables.table_factory(model)

Automatically define a Table class for the specified model. This is used during kernel setup to create default tables for models who have no Table.