Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#445 closed defect (fixed)

allow partial object updates with manipulators

Reported by: hugo <gb@…> Owned by: Adrian Holovaty
Component: Metasystem Version:
Severity: normal Keywords: new-admin
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

currently the manipulators that are created from model modules (ChangeManipuator and AddManipulator) expects all fields of an object in the new_data dict. This is a bit cumbersome if somebody want's to put up a form that only should edit some fields of an object. The validation code will barf about every missing required field and the html2python conversion and data saving will require all data to be there.

An idea that came up on IRC was to give the ChangeManipulator constructor an optional parameter "only_fields" that receives a list of fieldnames that should be worked on in the manipulator. The ChangeManipulator already reads in the original object (and stores it as Manipulator.original_object internally) and so could use the "only_fields" list as a guide to what fields of the original_object should be overwritten with data from new_data.

Additionally the Manipulator would have to keep only the fields named in the "only_fields" list in it's internal fields dictionary so that the validation code and the html2python conversion only work with those fields.

With this change it would be possible to build a form with the standard ChangeManipulator code for situations where only part of the object should be edited - an example would be a user profile page that will allow the user only to edit the first_name, last_name and email fields.

Change History (8)

comment:1 by Stan Seibert <volsung@…>, 19 years ago

Is this implemented by ticket #420?

comment:2 by Adrian Holovaty, 19 years ago

Component: Core frameworkMetasystem

comment:3 by hugo <gb@…>, 19 years ago

It actually might be - I only don't know wether #420 (or actually the internal machine) does a preloading of the object or wether it constructs new objects. Because to work right the limited-set-of-fields would have to be run against a prepopulated object. First fetch the object, than run the modification from the POST data dict for the defined fields (excluding the excluded fields).

comment:4 by rjwittams, 19 years ago

Resolution: fixed
Status: newclosed

(In [773])

Added templates for 'funny' widgets here: django/conf/admin_templates/widget
Added a follow argument to manipulators. This allows you to exclude/include fields and related objects ( recursively), defaulting to current behaviour, meaning that forms can modify a subset of fields. This should fix #445. Fixed update generic view to use this (will change others soon). Merged to trunk r772.

comment:5 by rjwittams, 19 years ago

Resolution: fixed
Status: closedreopened

This is fixed in new-admin with the follow argument : http://code.djangoproject.com/wiki/NewAdminChanges

But reopening the ticket till it in trunk.

comment:6 by rjwittams, 19 years ago

Keywords: new-admin added

comment:7 by rjwittams, 19 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in new-admin merge.

comment:8 by Here, 19 years ago

Type: enhancementdefect
Note: See TracTickets for help on using tickets.
Back to Top