559 def subject_in_state_vocabulary(self, rschema, limit=None): |
559 def subject_in_state_vocabulary(self, rschema, limit=None): |
560 """vocabulary method for the in_state relation, looking for |
560 """vocabulary method for the in_state relation, looking for |
561 relation's object entities (i.e. self is the subject) according |
561 relation's object entities (i.e. self is the subject) according |
562 to initial_state, state_of and next_state relation |
562 to initial_state, state_of and next_state relation |
563 """ |
563 """ |
564 if not self.has_eid() or not self.in_state: |
564 entity = self.edited_entity |
|
565 if not entity.has_eid() or not entity.in_state: |
565 # get the initial state |
566 # get the initial state |
566 rql = 'Any S where S state_of ET, ET name %(etype)s, ET initial_state S' |
567 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 rset = self.req.execute(rql, {'etype': str(entity.e_schema)}) |
568 if rset: |
569 if rset: |
569 return [(rset.get_entity(0, 0).view('combobox'), rset[0][0])] |
570 return [(rset.get_entity(0, 0).view('combobox'), rset[0][0])] |
570 return [] |
571 return [] |
571 results = [] |
572 results = [] |
572 for tr in self.in_state[0].transitions(self): |
573 for tr in entity.in_state[0].transitions(entity): |
573 state = tr.destination_state[0] |
574 state = tr.destination_state[0] |
574 results.append((state.view('combobox'), state.eid)) |
575 results.append((state.view('combobox'), state.eid)) |
575 return sorted(results) |
576 return sorted(results) |
576 |
577 |
577 |
578 |