lino.utils.choosers

Extends the possibilities for defining choices for fields of a Django model.

Example values:

>>> import json
>>> s = '<a href="javascript:Lino.pcsw.Clients.detail.run(null,{ &quot;record_id&quot;: 116 })">BASTIAENSEN Laurent (116)</a>'
>>> print(json.dumps(GFK_HACK.match(s).groups()))
["pcsw.Clients", "116"]
>>> s = '<a href="javascript:Lino.cal.Guests.detail.run(null,{ &quot;record_id&quot;: 6 })">Gast #6 ("Termin #51")</a>'
>>> print(json.dumps(GFK_HACK.match(s).groups()))
["cal.Guests", "6"]

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

Functions

_chooser(make, **options)

action_chooser(**options)

check_for_chooser(holder, field)

chooser(**options)

Decorator which turns the method into a chooser.

get_choosers_dict(holder)

make_converter(f[, lookup_fields])

noop(x)

uses_simple_values(holder, fld)

used by lino.core.store

Classes

BaseChooser()

ChoiceConverter(field)

Converter for ChoiceListField.

ChoicesChooser(field)

Chooser(model, field, meth)

Holds information about the possible choices of a field.

Converter(field)

DateConverter(field)

DecimalConverter(field)

FieldChooser(field)

ForeignKeyConverter(field, lookup_field)

Converter for ForeignKey fields.

GenericForeignKeyConverter(field)

Converter for GenericForeignKey fields.

LookupConverter(field, lookup_field)

A Converter for ForeignKey and ManyToManyField.

ManyToManyConverter(field, lookup_field)

Converter for ManyToMany fields.

class lino.utils.choosers.LookupConverter(field, lookup_field)

Bases: lino.utils.choosers.Converter

A Converter for ForeignKey and ManyToManyField. If the lookup_field is a BabelField, then it tries all available languages.

class lino.utils.choosers.ChoiceConverter(field)

Bases: lino.utils.choosers.Converter

Converter for ChoiceListField.

If you specify a string, then it can be a value or a name.

class lino.utils.choosers.ForeignKeyConverter(field, lookup_field)

Bases: lino.utils.choosers.LookupConverter

Converter for ForeignKey fields.

class lino.utils.choosers.GenericForeignKeyConverter(field)

Bases: lino.utils.choosers.Converter

Converter for GenericForeignKey fields.

class lino.utils.choosers.ManyToManyConverter(field, lookup_field)

Bases: lino.utils.choosers.LookupConverter

Converter for ManyToMany fields.

class lino.utils.choosers.Chooser(model, field, meth)

Bases: lino.utils.choosers.FieldChooser

Holds information about the possible choices of a field.

get_data_elem(name)

Calls dd.Actor.get_data_elem() or dd.Model.get_data_elem() or dd.Action.get_data_elem().

get_choices(**context)

Return a list of choices for this chooser, using keyword parameters as context.

get_request_choices(ar, tbl)

Return a list of choices for this chooser, using a HttpRequest to build the context.

lino.utils.choosers.uses_simple_values(holder, fld)

used by lino.core.store

lino.utils.choosers.chooser(**options)

Decorator which turns the method into a chooser.