web/views/forms.py
branch3.5
changeset 2920 64322aa83a1d
parent 2657 de974465d381
child 2968 0e3460341023
child 3245 7ef021ac8dec
equal deleted inserted replaced
2919:662f35236d1c 2920:64322aa83a1d
   527                                                 rsetsize, done)
   527                                                 rsetsize, done)
   528             if limit is not None and len(result) >= limit:
   528             if limit is not None and len(result) >= limit:
   529                 break
   529                 break
   530         return result
   530         return result
   531 
   531 
   532     def subject_in_state_vocabulary(self, rtype, limit=None):
   532     # def subject_in_state_vocabulary(self, rtype, limit=None):
   533         """vocabulary method for the in_state relation, looking for relation's
   533     #     """vocabulary method for the in_state relation, looking for relation's
   534         object entities (i.e. self is the subject) according to initial_state,
   534     #     object entities (i.e. self is the subject) according to initial_state,
   535         state_of and next_state relation
   535     #     state_of and next_state relation
   536         """
   536     #     """
   537         entity = self.edited_entity
   537     #     entity = self.edited_entity
   538         if not entity.has_eid() or not entity.in_state:
   538     #     if not entity.has_eid() or not entity.in_state:
   539             # get the initial state
   539     #         # get the initial state
   540             rql = 'Any S where S state_of ET, ET name %(etype)s, ET initial_state S'
   540     #         rql = 'Any S where S state_of ET, ET name %(etype)s, ET initial_state S'
   541             rset = self.req.execute(rql, {'etype': str(entity.e_schema)})
   541     #         rset = self.req.execute(rql, {'etype': str(entity.e_schema)})
   542             if rset:
   542     #         if rset:
   543                 return [(rset.get_entity(0, 0).view('combobox'), rset[0][0])]
   543     #             return [(rset.get_entity(0, 0).view('combobox'), rset[0][0])]
   544             return []
   544     #         return []
   545         results = []
   545     #     results = []
   546         for tr in entity.in_state[0].transitions(entity):
   546     #     for tr in entity.in_state[0].transitions(entity):
   547             state = tr.destination_state[0]
   547     #         state = tr.destination_state[0]
   548             results.append((state.view('combobox'), state.eid))
   548     #         results.append((state.view('combobox'), state.eid))
   549         return sorted(results)
   549     #     return sorted(results)
   550 
   550 
   551     def srelations_by_category(self, categories=None, permission=None):
   551     def srelations_by_category(self, categories=None, permission=None):
   552         return ()
   552         return ()
   553 
   553 
   554     def should_display_add_new_relation_link(self, rschema, existant, card):
   554     def should_display_add_new_relation_link(self, rschema, existant, card):
   555         return False
   555         return False
   556 
   556 
   557 
   557 
   558 class CompositeForm(FieldsForm):
   558 class CompositeForm(FieldsForm):
   559     """form composed for sub-forms"""
   559     """form composed of sub-forms"""
   560     id = 'composite'
   560     id = 'composite'
   561     form_renderer_id = id
   561     form_renderer_id = id
   562 
   562 
   563     def __init__(self, *args, **kwargs):
   563     def __init__(self, *args, **kwargs):
   564         super(CompositeForm, self).__init__(*args, **kwargs)
   564         super(CompositeForm, self).__init__(*args, **kwargs)
   566 
   566 
   567     def form_add_subform(self, subform):
   567     def form_add_subform(self, subform):
   568         """mark given form as a subform and append it"""
   568         """mark given form as a subform and append it"""
   569         subform.is_subform = True
   569         subform.is_subform = True
   570         self.forms.append(subform)
   570         self.forms.append(subform)
       
   571 
       
   572 
       
   573 class CompositeEntityForm(EntityFieldsForm):
       
   574     """form composed of sub-forms"""
       
   575     id = 'composite'
       
   576     form_renderer_id = id
       
   577 
       
   578     def __init__(self, *args, **kwargs):
       
   579         super(CompositeEntityForm, self).__init__(*args, **kwargs)
       
   580         self.forms = []
       
   581 
       
   582     def form_add_subform(self, subform):
       
   583         """mark given form as a subform and append it"""
       
   584         subform.is_subform = True
       
   585         self.forms.append(subform)