Projet

Général

Profil

0002-manager-avoid-validation-errors-on-dynamic-fields-in.patch

Valentin Deniaud, 16 mai 2022 17:44

Télécharger (1,88 ko)

Voir les différences:

Subject: [PATCH 2/2] manager: avoid validation errors on dynamic fields in
 cell edit form (#65163)

 combo/manager/views.py | 6 ++++--
 tests/test_dataviz.py  | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)
combo/manager/views.py
713 713
        for tab in self.object.get_manager_tabs():
714 714
            if tab.get('fields'):
715 715
                tab['form'] = forms.models.modelform_factory(self.object.__class__, fields=tab['fields'])
716
            # if current form had no errors, create it anew
716
            # if current form had no errors, create a new unbound form using current object
717 717
            # so it can get new dynamic fields
718
            form = tab_error_forms.get(tab['slug']) or tab['form'](**self.get_form_kwargs())
718
            form = tab_error_forms.get(tab['slug']) or tab['form'](
719
                instance=self.object, prefix=self.get_prefix(), initial={}
720
            )
719 721
            if tab['slug'] == 'general':
720 722
                form_name = 'form'
721 723
            else:
tests/test_dataviz.py
1625 1625
    resp.form[field_prefix + 'statistic'] = statistic.pk
1626 1626
    resp = app.post(resp.form.action, params=resp.form.submit_fields(), xhr=True)
1627 1627
    assert 'time_interval' in resp.json['tabs']['general']
1628
    assert 'This field is required.' not in resp.json['tabs']['general']
1628 1629

  
1629 1630

  
1630 1631
@with_httmock(new_api_mock)
1631
-