Coverage for lino/core/gfks.py : 52%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Copyright 2010-2015 Luc Saffre # License: BSD (see file COPYING for details) importable.
This defines some helper classes like
- :class:`Parametrizable` and :class:`Permittable` ("mixins" with common functionality for both actors and actions), - the volatile :class:`InstanceAction` object - the :class:`ParameterPanel` class (used e.g. by :class:`lino.mixins.periods.ObservedPeriod`) - :attr:`ContentType` and `GenericForeignKey`
"""
as DjangoGenericForeignKey
else: ContentType = UnresolvedModel GenericForeignKey = UnresolvedField
def is_foreignkey(fld): return isinstance(fld, ForeignKey)
"""Return a `dict` with the lookup keywords for the given GenericForeignKey field `gfk` on the given database object `obj`.
""" if obj is None: # 20120222 : here was only `pass`, and the two other lines # were uncommented. don't remember why I commented them out. # But it caused all tasks to appear in UploadsByController of # an insert window for uploads. kw[gfk.ct_field] = None kw[gfk.fk_field] = None else: ct = ContentType.objects.get_for_model(obj.__class__) kw[gfk.ct_field] = ct kw[gfk.fk_field] = obj.pk return kw
|