Django

Code

Changeset 7517

Show
Ignore:
Timestamp:
05/05/08 13:08:07 (2 weeks ago)
Author:
brosner
Message:

newforms-admin: Fixed #7160 -- MultiWidget?._has_changed was short-circuiting while testing for changed data in its widgets. Added tests to ensure this won't get broken in the future.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/newforms-admin/django/newforms/widgets.py

    r7515 r7517  
    592592            initial = self.decompress(initial) 
    593593        for widget, initial, data in zip(self.widgets, initial, data): 
    594             if not widget._has_changed(initial, data): 
    595                 return Fals
    596         return Tru
     594            if widget._has_changed(initial, data): 
     595                return Tru
     596        return Fals
    597597 
    598598    def format_output(self, rendered_widgets): 
  • django/branches/newforms-admin/tests/regressiontests/forms/widgets.py

    r7515 r7517  
    964964 
    965965>>> w = MyMultiWidget(widgets=(TextInput(), TextInput())) 
    966 >>> w._has_changed(None, ['john', 'lennon']) 
    967 True 
    968 >>> w._has_changed('john__lennon', ['john', 'lennon']) 
    969 False 
     966# test with no initial data 
     967>>> w._has_changed(None, [u'john', u'lennon']) 
     968True 
     969# test when the data is the same as initial 
     970>>> w._has_changed(u'john__lennon', [u'john', u'lennon']) 
     971False 
     972# test when the first widget's data has changed 
     973>>> w._has_changed(u'john__lennon', [u'alfred', u'lennon']) 
     974True 
     975# test when the last widget's data has changed. this ensures that it is not 
     976# short circuiting while testing the widgets. 
     977>>> w._has_changed(u'john__lennon', [u'john', u'denver']) 
     978True 
    970979 
    971980# SplitDateTimeWidget #########################################################