Exemple #1
0
def my_pre_ui_build(sender, **kw):
    self = settings.SITE
    if self.is_installed('contenttypes'):

        from django.db.utils import DatabaseError
        from django.db.models import FieldDoesNotExist
        try:

            HelpText = dd.resolve_model('system.HelpText')
            for ht in HelpText.objects.filter(help_text__isnull=False):
                #~ logger.info("20120629 %s.help_text", ht)
                try:
                    resolve_field(unicode(ht)).help_text = ht.help_text
                except FieldDoesNotExist as e:
                    #~ logger.debug("No help texts : %s",e)
                    pass
        except DatabaseError, e:
            logger.debug("No help texts : %s", e)
            pass
Exemple #2
0
    def lino_resolve_type(self):
        """
        Unlike attach_to_model, this is also called on virtual 
        fields that are defined on an Actor
        """
        # ~ logger.info("20120903 lino_resolve_type %s.%s", actor_or_model, name)
        # ~ if self.name is not None:
        # ~ if self.name != name:
        # ~ raise Exception("Tried to re-use %s.%s" % (actor_or_model,name))
        # ~ self.name = name

        if isinstance(self.return_type, basestring):
            self.return_type = resolve_field(self.return_type)

        # ~ self.return_type.name = self.name
        if isinstance(self.return_type, models.ForeignKey):
            f = self.return_type
            f.rel.to = resolve_model(f.rel.to)
            if f.verbose_name is None:
                # ~ if f.name is None:
                f.verbose_name = f.rel.to._meta.verbose_name
                # ~ from lino.core.kernel import set_default_verbose_name
                # ~ set_default_verbose_name(self.return_type)

        # ~ removed 20120919 self.return_type.editable = self.editable
        for k in """to_python choices save_form_data 
          value_to_string verbose_name max_length rel
          max_digits decimal_places
          help_text
          blank""".split():
            setattr(self, k, getattr(self.return_type, k, None))
        # ~ logger.info('20120831 VirtualField %s on %s',name,actor_or_model)

        # ~ store = self.model.get_default_table().get_handle().store
        # ~ self._lino_atomizer = store.create_field(self,self.name)
        # ~ self._lino_atomizer = self.return_type._lino_atomizer
        from lino.ui import store

        # ~ self._lino_atomizer = store.create_field(self,self.name)
        store.get_atomizer(self, self.name)