lino.utils.choosers¶
Extends the possibilities for defining choices for fields of a Django model.
Context-sensitive choices (see Introduction to Combo boxes)
Non-limiting choices (force_selection False) : specify a pick list of suggestions but leave the possibility to store manually entered values
Example values:
>>> import json
>>> s = '<a href="javascript:Lino.pcsw.Clients.detail.run(null,{ "record_id": 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,{ "record_id": 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
|
|
|
|
|
|
|
Decorator which turns the method into a chooser. |
|
|
|
|
|
|
|
used by |
Classes
|
|
|
Converter for |
|
|
|
Holds information about the possible choices of a field. |
|
|
|
|
|
|
|
|
|
Converter for ForeignKey fields. |
|
Converter for GenericForeignKey fields. |
|
A Converter for ForeignKey and ManyToManyField. |
|
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()
ordd.Model.get_data_elem()
ordd.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.