예제 #1
0
    def _collect_actions(cls):
        """
        Loops through the class dict and collects all Action instances,
        calling `_attach_action` which will set their `actor` attribute.
        Before this we create `insert_action` and `detail_action` if necessary.
        Also fill _actions_list.
        """

        default_action = cls.get_default_action()

        if default_action is not None:
            cls.default_action = cls._bind_action(default_action)

        if cls.detail_layout:
            if default_action and isinstance(default_action,
                                             actions.ShowDetail):
                cls.detail_action = cls._bind_action(default_action)
            else:
                cls.detail_action = cls._bind_action(actions.ShowDetail())
            if cls.editable:
                cls.submit_detail = cls._bind_action(actions.SubmitDetail())

        if cls.editable:
            if cls.allow_create:
                # cls.create_action = cls._bind_action(actions.SubmitInsert())
                if cls.detail_action and not cls.hide_top_toolbar:
                    cls.insert_action = cls._bind_action(
                        cls.get_insert_action())
            if not cls.hide_top_toolbar:
                cls.delete_action = cls._bind_action(actions.DeleteSelected())
            cls.update_action = cls._bind_action(actions.SaveRow())
            if cls.detail_layout:
                cls.validate_form = cls._bind_action(actions.ValidateForm())

        if isinstance(cls.workflow_owner_field, string_types):
            cls.workflow_owner_field = cls.get_data_elem(
                cls.workflow_owner_field)
        if isinstance(cls.workflow_state_field, string_types):
            cls.workflow_state_field = cls.get_data_elem(
                cls.workflow_state_field)

        # note that the fld may be None e.g. cal.Component
        if cls.workflow_state_field is not None:
            for a in cls.workflow_state_field.choicelist.workflow_actions:
                setattr(cls, a.action_name, a)

        # bind all my actions, including those inherited from parent actors:
        for b in cls.mro():
            for k, v in list(b.__dict__.items()):
                # Allow disabling inherited actions by setting them to
                # None in subclass.
                v = cls.__dict__.get(k, v)
                if isinstance(v, actions.Action):
                    if not k in cls.actions:
                        if v.attach_to_actor(cls, k):
                            cls._bind_action(v)

        cls._actions_list.sort(key=lambda a: a.action.sort_index)
예제 #2
0
class SiteConfigs(dd.Table):
    """
    The table used to present the :class:`SiteConfig` row in a Detail form.
    See also :meth:`lino.Lino.get_site_config`.
    Deserves more documentation.
    """
    model = 'system.SiteConfig'
    required_roles = dd.required(SiteStaff)
    default_action = actions.ShowDetail()
    #~ has_navigator = False
    hide_top_toolbar = True
    #~ can_delete = perms.never
    detail_layout = """
    default_build_method
    # lino.ModelsBySite
    """

    do_build = BuildSiteCache()
예제 #3
0
파일: models.py 프로젝트: gary-ops/lino
 def get_default_action(cls):
     return actions.ShowDetail(cls.detail_layout)
예제 #4
0
파일: desktop.py 프로젝트: TonisPiip/lino
 def get_default_action(cls):
     return actions.ShowDetail()
예제 #5
0
 def get_default_action(cls):
     return actions.ShowDetail(cls.detail_layout, hide_navigator=True)