Code

Opened 7 years ago

Closed 7 years ago

#4236 closed (duplicate)

newforms in create_update views + several enhancements

Reported by: dmach@… Owned by: nobody
Component: Generic views Version: master
Severity: Keywords: newforms
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

this patch is similar to #3639, but comes with several enhancements

there are several more view arguments in this patch:
not_required_fields=None - list of field names; sets form.fields[field].required=False
hidden_fields=None - dictionary of fieldnames and values; these fields are supposed to be constants (they are not overwritten by post data)
default_data=None - dictionary of default values; used when creating new form instance
choices=None - list of tuples; allows value filtering of choice fields

Attachments (1)

create_update_newforms.diff (13.9 KB) - added by dmach@… 7 years ago.

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by dmach@…

comment:1 follow-up: Changed 7 years ago by mtredinnick

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

As usual, combining two features in one ticket reports leads to problem. It's difficult to evaluate and discuss the changes in isolation. So let's make this ticket about the new features you wish to add to a couple of generic views and keep #3639 (which is still open, so we don't need dupes of that ticket) to be about the port to newforms.

Are there problems with the patch in #3639 (aside from the one I mention in the last comment over there)? Is so, an updated patch to that ticket would be reasonable (attached to #3639). You are introducing some backwards incompatible changes in this patch: the follow attribute goes away. Will we miss that behaviour?

After applying whichever patch looks best from #3639, then we can look at the new features proposed here.

comment:2 in reply to: ↑ 1 Changed 7 years ago by dmach@…

Replying to mtredinnick:

As usual, combining two features in one ticket reports leads to problem. It's difficult to evaluate and discuss the changes in isolation. So let's make this ticket about the new features you wish to add to a couple of generic views and keep #3639 (which is still open, so we don't need dupes of that ticket) to be about the port to newforms.

You are right, I should have splitted the patch into two ones, I keep in mind for the next time.

Are there problems with the patch in #3639 (aside from the one I mention in the last comment over there)? Is so, an updated patch to that ticket would be reasonable (attached to #3639). You are introducing some backwards incompatible changes in this patch: the follow attribute goes away. Will we miss that behaviour?

My patch is only slightly better than #3639 in my opinion.
This is the list of important differences when comparing to the #3639 patch:

  • if extra_context is None: extra_context = {} is replaced by direct condition if extra_context:
  • if request.POST: is replaced by if request.method == 'POST'
  • follow attribute is dropped (see below)
  • code cleanup, more comments

Rest of the changes were supposed to add new features.

The follow attribute seems to be an oldforms feature that (probably) should dropped.
Please notice, that this attribute still exists in #3639 but isn't used any more.

Do you think that is reasonable to apply the changes I mentioned above to the #3639 patch?

comment:3 Changed 7 years ago by Gary Wilson <gary.wilson@…>

  • Triage Stage changed from Unreviewed to Design decision needed

comment:4 Changed 7 years ago by brosner

  • Resolution set to duplicate
  • Status changed from new to closed

This ticket is adding too much functionality that is not needed in the generic views. All of the proposed functionality can be easily accomplish with using the newforms customization tricks. I have attached a patch to #3639 that allows for form and formfield_callback overrides where you can make fields hidden, not required, default data, etc... Closing this as it is not needed any longer and half of this ticket is a duplicate with #3639.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


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

 
Note: See TracTickets for help on using tickets.