web/form.py
branchtls-sprint
changeset 1175 96747df28a1f
parent 1147 402e8a8b1d6a
child 1183 62afd820d3ae
equal deleted inserted replaced
1174:7dac5aeafb86 1175:96747df28a1f
   554                 continue
   554                 continue
   555             done.add(entity.eid)
   555             done.add(entity.eid)
   556             res.append((entity.view('combobox'), entity.eid))
   556             res.append((entity.view('combobox'), entity.eid))
   557         return res
   557         return res
   558 
   558 
       
   559     def subject_in_state_vocabulary(self, rschema, limit=None):
       
   560         """vocabulary method for the in_state relation, looking for
       
   561         relation's object entities (i.e. self is the subject) according
       
   562         to initial_state, state_of and next_state relation
       
   563         """
       
   564         if not self.has_eid() or not self.in_state:
       
   565             # get the initial state
       
   566             rql = 'Any S where S state_of ET, ET name %(etype)s, ET initial_state S'
       
   567             rset = self.req.execute(rql, {'etype': str(self.e_schema)})
       
   568             if rset:
       
   569                 return [(rset.get_entity(0, 0).view('combobox'), rset[0][0])]
       
   570             return []
       
   571         results = []
       
   572         for tr in self.in_state[0].transitions(self):
       
   573             state = tr.destination_state[0]
       
   574             results.append((state.view('combobox'), state.eid))
       
   575         return sorted(results)
       
   576 
   559 
   577 
   560 class CompositeForm(FieldsForm):
   578 class CompositeForm(FieldsForm):
   561     """form composed for sub-forms"""
   579     """form composed for sub-forms"""
   562     
   580     
   563     def __init__(self, *args, **kwargs):
   581     def __init__(self, *args, **kwargs):