How to use the lino.api.dd function in lino

To help you get started, we’ve selected a few lino examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lino-framework / lino / lino / modlib / cal / models.py View on Github external
def on_analyze(cls, lino):
        #~ lino.TASK_AUTO_FIELDS = dd.fields_list(cls,
        cls.DISABLED_AUTO_FIELDS = dd.fields_list(
            cls, """start_date start_time summary""")
        super(Task, cls).on_analyze(lino)
github lino-framework / lino / lino / modlib / publisher / choicelists.py View on Github external
    @dd.virtualfield(models.BooleanField(_("published")))
    def is_published(cls, choice, ar):
        return choice.is_published
github lino-framework / lino / lino / modlib / forms / models.py View on Github external
"""
Database models for `lino.modlib.bootstrap3`.

.. autosummary::

"""


from django.conf import settings
from lino.core.tables import AbstractTable
from django.utils.translation import ugettext_lazy as _

from lino.api import dd


class ShowAsHtml(dd.Action):
    label = _("HTML")
    help_text = _('Show this table in Bootstrap3 interface')
    icon_name = 'html'
    sort_index = -15
    select_rows = False
    default_format = 'ajax'
    preprocessor = "Lino.get_current_grid_config"
    callable_from = 't'

    # def is_callable_from(self, caller):
    #     return isinstance(caller, dd.ShowTable)

    def run_from_ui(self, ar, **kw):
        url = dd.plugins.bootstrap3.renderer.get_request_url(ar)
        ar.success(open_url=url)
github lino-framework / lino / lino / modlib / pages / dummy.py View on Github external
logger = logging.getLogger(__name__)

from django.conf import settings
from django.db import models

from lino.utils import AttrDict
# from lino.core import web
from lino.api import dd

from lino.utils.restify import restify
from lino.utils.restify import doc2rst

DUMMY_PAGES = {}


@dd.python_2_unicode_compatible
class DummyPage(AttrDict):
    raw_html = False
    #~ special = False

    def __str__(self):
        return u'%s %s' % (self._meta.verbose_name, self.ref)

    def get_sidebar_html(self, request):
        return ''

    def full_clean(self):
        pass

    def save(self):
        pass
github lino-framework / lino / lino / modlib / notes / models.py View on Github external
def customize_siteconfig():
    """
    Injects application-specific fields to :class:`SiteConfig `.
    """
    dd.inject_field(
        'system.SiteConfig',
        'system_note_type',
        dd.ForeignKey(
            'notes.EventType',
            blank=True, null=True,
            verbose_name=_("Default system note type"),
            help_text=_("""\
Note Type used by system notes.
github lino-framework / lino / lino / modlib / comments / ui.py View on Github external
from django.contrib.humanize.templatetags.humanize import naturaltime

from lino.api import dd, rt
from lino.modlib.users.mixins import My
from etgen.html import E, tostring
# from lxml import etree
import lxml
# from lino.utils.soup import truncate_comment
from lino.core.gfks import gfk2lookup
from .roles import CommentsReader, CommentsUser, CommentsStaff
from .choicelists import CommentEvents
from lino import mixins
from lino.core.constants import CHOICES_BLANK_FILTER_VALUE


class CommentTypes(dd.Table):
    required_roles = dd.login_required(CommentsStaff)
    model = 'comments.CommentType'
    column_names = "name *"
    order_by = ["name"]

    insert_layout = """
    name
    id
    """

    detail_layout = """
    id name
    comments.CommentsByType
    """
github lino-framework / lino / lino / modlib / workflows / models.py View on Github external
If this is empty, the permission applies for all workflow actions of the actor.
          """)
        state = models.CharField(
            _("State"), max_length=settings.SITE.max_state_value_length,
            blank=True,
            help_text="""
          Permission applies only for objects in the given state.
          If this is empty, the permission applies for all states.
          """)
        #~ state_after = models.CharField(_("State after"),max_length=20)
        user_level = dd.UserLevels.field(blank=True,
            help_text="""
          If not empty, this permission applies only for users having at least the given level.
          """)
        # ~ user_groups = UserGroup.field(max_length=200,blank=True,force_selection=False) # TODO: multiple=True
        user_group = dd.UserGroups.field(
            help_text="""
          If not empty, this permission applies only for members of the given group.
          """)  # TODO: multiple=True
        #~ user_groups = models.CharField(_("user groups"),max_length=200,blank=True)
        owned_only = models.BooleanField(_("owned only"), default=False,
            help_text="""
          Allow this action only for objects owned by the user
          """)

        #~ def get_siblings(self):
            #~ "Overrides :meth:`lino.mixins.Sequenced.get_siblings`"
            #~ return self.__class__.objects.filter(actor_name=self.actor_name).order_by('seqno')

        @chooser()
        def actor_name_choices(cls):
            #~ return WORKFLOWABLE_ACTORS.items()
github lino-framework / lino / lino / modlib / outbox / models.py View on Github external
#~ detail_layout = """
    #~ mail owner
    #~ """


class AttachmentsByMail(Attachments):
    required_roles = dd.required(OfficeUser)
    master_key = 'mail'
    slave_grid_format = 'summary'


class AttachmentsByController(Attachments):
    master_key = 'owner'


dd.update_field(Mail, 'user', verbose_name=_("Sender"))
github lino-framework / lino / lino / modlib / gfks / models.py View on Github external
  @dd.receiver(dd.pre_ui_build)
  def my_pre_ui_build(sender, **kw):
    try:
        HelpText = rt.models.gfks.HelpText
        for ht in HelpText.objects.filter(help_text__isnull=False):
            # dd.logger.info("20120629 %s.help_text", ht)
            try:
                dd.resolve_field(str(ht)).help_text = ht.help_text
            except FieldDoesNotExist as e:
                #~ logger.debug("No help texts : %s",e)
                pass
    except DatabaseError as e:
        dd.logger.debug("No help texts : %s", e)
        pass
github lino-framework / lino / lino / modlib / dashboard / models.py View on Github external
def get_siblings(self):
        qs = super(Widget, self).get_siblings()
        return qs.filter(user=self.user)
    
    @dd.displayfield(_("Label"))
    def title(self, ar):
        a = settings.SITE.models.resolve(self.item_name)
        # might be invalid e.g. if the widget was created by a
        # previous version.
        if a is None:
            return _("Invalid item_name {} in {}").format(
                self.item_name, self._meta.verbose_name)
        return a.label
    

class Widgets(dd.Table):
    model = 'dashboard.Widget'

class AllWidgets(Widgets):
    label = _("All dashboard widgets")
    required_roles = dd.login_required(SiteAdmin)
    column_names = 'id user seqno move_buttons title visible *'
    order_by = ['id']
        
class WidgetsByUser(Widgets):
    label = _("Dashboard")
    master_key = 'user'
    column_names = 'seqno move_buttons title visible *'
    order_by = ['seqno']

    
def update_widgets_for(ar, user):