Ejemplo n.º 1
0
  def _normalize_union_mform(self, union_mform):
    """
    Normalize the subunions in the MultiForm recursively.
    Returns a data dict.
    """
    data_dict = dict(
        bools = normalize_form_dict(union_mform.bool, ReportDesign._BOOL_ATTRS),
        conds = normalize_formset_dict(union_mform.conds, ReportDesign._COND_ATTRS))

    subunion_list = [ ]
    for name, subform in union_mform.get_subforms():
      if name.startswith(report_gen_views.SUB_UNION_PREFIX):
        dic = self._normalize_union_mform(subform)
        subunion_list.append(dic)
    data_dict['subunions'] = subunion_list
    return data_dict
Ejemplo n.º 2
0
 def __init__(self, form):
   """Initialize the design from form data. The form may be invalid."""
   assert isinstance(form, MultiForm)
   self._data_dict = dict(
       columns = normalize_formset_dict(form.columns, ReportDesign._COLUMN_ATTRS))
   self._data_dict['union'] = self._normalize_union_mform(form.union)