Code

Opened 4 years ago

Last modified 3 years ago

#13878 new New feature

Formset validation refactoring and valid_forms property of fieldsets

Reported by: Petr Marhoun <petr.marhoun@…> Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

This series of patch solves two problems:

  • Formsets validation is spread in four different methods so it is very difficult to comprehend the code and to solve possible problems.
  • There is no method which gives valid forms in all situation - especially, valid formset can contain invalid form if this form should be deleted. So this ticket adds new property valid_forms which returns all valid (and filled) forms, possible ordered.

There is wiki page and discussion in django-developers:

Attachments (6)

01-formset-refactoring.diff (8.9 KB) - added by Petr Marhoun <petr.marhoun@…> 4 years ago.
02-formset-refactoring-cleaned-data-tests.diff (1.9 KB) - added by Petr Marhoun <petr.marhoun@…> 4 years ago.
03-formset-refactoring-valid-forms-tests.diff (4.1 KB) - added by Petr Marhoun <petr.marhoun@…> 4 years ago.
01-formset-refactoring.2.diff (8.9 KB) - added by Petr Marhoun <petr.marhoun@…> 3 years ago.
02-formset-refactoring-cleaned-data-tests.2.diff (2.0 KB) - added by Petr Marhoun <petr.marhoun@…> 3 years ago.
03-formset-refactoring-valid-forms-tests.2.diff (4.2 KB) - added by Petr Marhoun <petr.marhoun@…> 3 years ago.

Download all attachments as: .zip

Change History (11)

Changed 4 years ago by Petr Marhoun <petr.marhoun@…>

Changed 4 years ago by Petr Marhoun <petr.marhoun@…>

Changed 4 years ago by Petr Marhoun <petr.marhoun@…>

comment:1 Changed 4 years ago by Petr Marhoun <petr.marhoun@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

The first patch (01-formset-refactoring.diff) contains changes of code. The second patch (02-formset-refactoring-cleaned-data-tests.diff) shows that cleaned_data as attribute of formsets or forms in formsets are problematic (this patch could be applied to trunk to expose the situation). The third patch (03-formset-refactoring-valid-forms-tests.diff) contains tests for new property valid_forms.

Changed 3 years ago by Petr Marhoun <petr.marhoun@…>

Changed 3 years ago by Petr Marhoun <petr.marhoun@…>

Changed 3 years ago by Petr Marhoun <petr.marhoun@…>

comment:2 Changed 3 years ago by russellm

  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

Marking accepted on the basis of the discussion on django-dev -- on principle, this sounds like a reasonable idea, but it needs a *very* detailed review. Widespread changes of this nature make me *very* nervous about backwards compatibility issues. The test coverage you have provided is a very good start, but I don't have complete confidence that the existing test suite covers all possible backwards compatibility issues.

Speaking of which -- the tests need to be updated to unittests; the patches don't currently apply cleanly.

comment:3 Changed 3 years ago by graham_king

  • Severity set to Normal
  • Type set to New feature

comment:4 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:5 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.