Ticket #10643: 10643.diff
File 10643.diff, 1.7 KB (added by , 16 years ago) |
---|
-
django/contrib/formtools/utils.py
15 15 order, pickles the result with the SECRET_KEY setting, then takes an md5 16 16 hash of that. 17 17 """ 18 19 data = [(bf.name, bf.field.clean(bf.data) or '') for bf in form] 18 if form.empty_permitted and not form.has_changed(): 19 data = [(bf.name, bf.data or '') for bf in form] 20 else: 21 data = [(bf.name, bf.field.clean(bf.data) or '') for bf in form] 20 22 data.extend(args) 21 23 data.append(settings.SECRET_KEY) 22 24 -
tests/regressiontests/forms/tests.py
67 67 'widgets_tests': widgets_tests, 68 68 } 69 69 70 from django.test import TestCase 71 72 class Regression10643(TestCase): 73 def test10643(self): 74 """Check that formtools.utils.security_hash handles forms with 75 empty_permitted=True""" 76 from django import forms 77 78 class BlankForm(forms.Form): 79 name = forms.CharField(max_length=10, required=False) 80 class NotBlankForm(forms.Form): 81 name = forms.CharField(max_length=10) 82 blank_form = BlankForm({}) 83 not_blank_form = NotBlankForm({}, empty_permitted=True) 84 85 from django.contrib.formtools.utils import security_hash 86 self.assertEqual(security_hash(None, blank_form), security_hash(None, not_blank_form)) 87 70 88 if __name__ == "__main__": 71 89 import doctest 72 90 doctest.testmod()