diff -r 662f35236d1c -r 64322aa83a1d web/views/forms.py --- a/web/views/forms.py Thu Aug 20 17:33:05 2009 +0200 +++ b/web/views/forms.py Thu Aug 20 17:44:27 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)