diff options
Diffstat (limited to 'ishtar_common/wizards.py')
| -rw-r--r-- | ishtar_common/wizards.py | 28 | 
1 files changed, 16 insertions, 12 deletions
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index f028c15d8..1ac28d640 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -662,19 +662,23 @@ class Wizard(NamedUrlWizardView):                  frm = form.form                  if callable(frm):                      frm = frm() -                required_fields = [ki for ki in frm.fields -                                   if frm.fields[ki].required] -                base_key = None -                if required_fields: -                    base_key = required_fields[-1] -                elif frm.fields.keys(): -                    base_key = frm.fields.keys()[-1] -                init = self.get_form_initial(step, data=data) +                  total_field = 0 -                if base_key: -                    total_field = len([key for key in data.keys() -                                       if base_key in key.split('-') -                                       and data[key]]) +                if hasattr(frm, 'count_valid_fields'): +                    total_field = frm.count_valid_fields(data) +                else: +                    required_fields = [ki for ki in frm.fields +                                       if frm.fields[ki].required] +                    base_key = None +                    if required_fields: +                        base_key = required_fields[-1] +                    elif frm.fields.keys(): +                        base_key = frm.fields.keys()[-1] +                    if base_key: +                        total_field = len([key for key in data.keys() +                                           if base_key in key.split('-') +                                           and data[key]]) +                init = self.get_form_initial(step, data=data)                  if init and not to_delete and (                     not hasattr(self, 'form_initialized') or                     not self.form_initialized):  | 
