Code

Opened 7 years ago

Closed 17 months ago

#5681 closed Bug (fixed)

Save as new disappears on failed validation

Reported by: Uninen Owned by: nobody
Component: contrib.admin Version: master
Severity: Normal Keywords: admin, save
Cc: mathijs@… Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

When I have a model with admin attribute save_as = True , and save it via admin in a way that it triggers validation (ie. some fields are missing or incorrect), 'Save as new' button disappears from the page. After correcting the given values, when saving the object, it's saved on top of the old object and not as a new as was intended.

Attachments (2)

patch5681.diff (1.5 KB) - added by bastih 5 years ago.
against rev 10203
patch5681-1.diff (1.1 KB) - added by cornel 5 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 6 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Changed 5 years ago by bastih

against rev 10203

Changed 5 years ago by cornel

comment:2 Changed 5 years ago by cornel

If after pressing the "Save as new" button the form is not valid, the user should be presented the same form. (the "edit" form instead of the "add" form), because as long as the form is not valid the instance should be the same. The patch I uploaded solves this issue.

comment:3 Changed 3 years ago by ramiro

  • Needs tests set
  • Patch needs improvement set

comment:4 Changed 3 years ago by ramiro

  • Triage Stage changed from Accepted to Design decision needed

Use case: When I have a model with admin attribute save_as = True, and save it via admin in a way that it triggers validation errors (ie. some fields are missing or incorrect).

Users Uninen (the original reporter) and Cornel (in comment:2) report three issues here:

  1. In that case the user should be presented the same form (the "edit" form instead of the "add" form as it happens currently), because as long as the form is not valid the instance should be the same.
  2. Save as new button disappears from the page (it is replaced by the usual Save and add another button of an "add" form.)
  3. After correcting the given values, when saving the object, it's saved on top of the old object and not as a new as was intended.

Currently item 3 (the only that would cause data loss) doesn't happen anymore (possibly some other work in the area during the last three years fixed it). A new model instance is created when you press either the Save and add another, Save an continue editing or Save buttons.

I don't agree with items 1 and 2, once the user has made the decision she wants to create a clone copy of the original model instance, the form shown after a validation error doesn't have to be the one pointing to the original object. IMHO it is better the way it works now: An "add" form is shown with all the valid fields pre-filled and all the possible save options do create a new model instance without endangering the original one.

I'm moving back this ticket to Decision needed.

Last edited 3 years ago by ramiro (previous) (diff)

comment:5 Changed 3 years ago by dokterbob

  • Cc mathijs@… added

comment:6 Changed 3 years ago by gabrielhurley

  • Severity set to Normal
  • Type set to Bug

comment:7 Changed 3 years ago by carljm

  • Easy pickings unset
  • Resolution set to fixed
  • Status changed from new to closed
  • UI/UX unset

On the basis of ramiro's comment, closing this as fixed, since the real problem is that a new object was not created. Otherwise, existing behavior seems reasonable.

comment:8 follow-up: Changed 2 years ago by anonymous

  • Resolution fixed deleted
  • Status changed from closed to reopened

I can confirm that under some circumstances at least, using any Save option after a validation failure on Save as New does not create a new model instance. Instead, the original item is overwritten.

This is with 1.3.0 final. So, I think that this should not be considered resolved.

comment:9 in reply to: ↑ 8 Changed 17 months ago by ramiro

  • Resolution set to fixed
  • Status changed from reopened to closed

Replying to anonymous:

I can confirm that under some circumstances at least, using any Save option after a validation failure on Save as New does not create a new model instance. Instead, the original item is overwritten.

This is with 1.3.0 final. So, I think that this should not be considered resolved.

At this point we'd need a failing test case (with a models/admin setup as simple as possible) or script (as in a sequence of user actions) that shows the described behavior, using currently supported versions (1.4 and maybe in-development 1.5 or trunk). Feel free to reopen the ticket if you can provide any of these,

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.