web/views/forms.py
changeset 2968 0e3460341023
parent 2890 fdcb8a2bb6eb
parent 2920 64322aa83a1d
child 3293 69c0ba095536
--- a/web/views/forms.py	Tue Aug 18 09:25:44 2009 +0200
+++ b/web/views/forms.py	Fri Aug 21 16:26:20 2009 +0200
@@ -529,24 +529,24 @@
                 break
         return result
 
-    def subject_in_state_vocabulary(self, rtype, limit=None):
-        """vocabulary method for the in_state relation, looking for relation's
-        object entities (i.e. self is the subject) according to initial_state,
-        state_of and next_state relation
-        """
-        entity = self.edited_entity
-        if not entity.has_eid() or not entity.in_state:
-            # get the initial state
-            rql = 'Any S where S state_of ET, ET name %(etype)s, ET initial_state S'
-            rset = self.req.execute(rql, {'etype': str(entity.e_schema)})
-            if rset:
-                return [(rset.get_entity(0, 0).view('combobox'), rset[0][0])]
-            return []
-        results = []
-        for tr in entity.in_state[0].transitions(entity):
-            state = tr.destination_state[0]
-            results.append((state.view('combobox'), state.eid))
-        return sorted(results)
+    # def subject_in_state_vocabulary(self, rtype, limit=None):
+    #     """vocabulary method for the in_state relation, looking for relation's
+    #     object entities (i.e. self is the subject) according to initial_state,
+    #     state_of and next_state relation
+    #     """
+    #     entity = self.edited_entity
+    #     if not entity.has_eid() or not entity.in_state:
+    #         # get the initial state
+    #         rql = 'Any S where S state_of ET, ET name %(etype)s, ET initial_state S'
+    #         rset = self.req.execute(rql, {'etype': str(entity.e_schema)})
+    #         if rset:
+    #             return [(rset.get_entity(0, 0).view('combobox'), rset[0][0])]
+    #         return []
+    #     results = []
+    #     for tr in entity.in_state[0].transitions(entity):
+    #         state = tr.destination_state[0]
+    #         results.append((state.view('combobox'), state.eid))
+    #     return sorted(results)
 
     def srelations_by_category(self, categories=None, permission=None):
         return ()
@@ -556,7 +556,7 @@
 
 
 class CompositeForm(FieldsForm):
-    """form composed for sub-forms"""
+    """form composed of sub-forms"""
     id = 'composite'
     form_renderer_id = id
 
@@ -568,3 +568,18 @@
         """mark given form as a subform and append it"""
         subform.is_subform = True
         self.forms.append(subform)
+
+
+class CompositeEntityForm(EntityFieldsForm):
+    """form composed of sub-forms"""
+    id = 'composite'
+    form_renderer_id = id
+
+    def __init__(self, *args, **kwargs):
+        super(CompositeEntityForm, self).__init__(*args, **kwargs)
+        self.forms = []
+
+    def form_add_subform(self, subform):
+        """mark given form as a subform and append it"""
+        subform.is_subform = True
+        self.forms.append(subform)