web/views/boxes.py
branch3.5
changeset 2993 2d06451013ac
parent 2920 64322aa83a1d
child 3084 096d680c9da2
equal deleted inserted replaced
2992:a5b8bf107a1a 2993:2d06451013ac
    63                 menu.append(self.box_action(action))
    63                 menu.append(self.box_action(action))
    64         if self.rset and self.rset.rowcount == 1 and \
    64         if self.rset and self.rset.rowcount == 1 and \
    65                not self.schema[self.rset.description[0][0]].is_final() and \
    65                not self.schema[self.rset.description[0][0]].is_final() and \
    66                searchstate == 'normal':
    66                searchstate == 'normal':
    67             entity = self.rset.get_entity(0, 0)
    67             entity = self.rset.get_entity(0, 0)
    68             #entity.complete()
    68             for action in self.schema_actions(entity):
    69             if add_menu.items:
    69                 add_menu.append(action)
    70                 self.info('explicit actions defined, ignoring potential rtags for %s',
       
    71                           entity.e_schema)
       
    72             else:
       
    73                 # some addrelated actions may be specified but no one is selectable
       
    74                 # in which case we should not fallback to schema_actions. The proper
       
    75                 # way to avoid this is to override add_related_schemas() on the
       
    76                 # entity class to return an empty list
       
    77                 for action in self.schema_actions(entity):
       
    78                     add_menu.append(action)
       
    79             self.workflow_actions(entity, box)
    70             self.workflow_actions(entity, box)
    80         if box.is_empty() and not other_menu.is_empty():
    71         if box.is_empty() and not other_menu.is_empty():
    81             box.items = other_menu.items
    72             box.items = other_menu.items
    82             other_menu.items = []
    73             other_menu.items = []
    83         self.add_submenu(box, add_menu, _('add'))
    74         self.add_submenu(box, add_menu, _('add'))
   111 
   102 
   112     def add_related_schemas(self, entity):
   103     def add_related_schemas(self, entity):
   113         """this is actually used ui method to generate 'addrelated' actions from
   104         """this is actually used ui method to generate 'addrelated' actions from
   114         the schema.
   105         the schema.
   115 
   106 
   116         If you're using explicit 'addrelated' actions for an entity types, you
   107         If you don't want any auto-generated actions, you should overrides this
   117         should probably overrides this method to return an empty list else you
   108         method to return an empty list. If you only want some, you can configure
   118         may get some unexpected actions.
   109         them by using uicfg.actionbox_appearsin_addmenu
   119         """
   110         """
   120         req = self.req
   111         req = self.req
   121         eschema = entity.e_schema
   112         eschema = entity.e_schema
   122         for role, rschemas in (('subject', eschema.subject_relations()),
   113         for role, rschemas in (('subject', eschema.subject_relations()),
   123                                ('object', eschema.object_relations())):
   114                                ('object', eschema.object_relations())):