1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

newforms-admin: Fixed #6964 -- Implemented FileInput._has_changed. Before it was comparing the wrong values and causing it to trip up.

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7506 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Brian Rosner
2008-04-29 04:31:59 +00:00
parent c9c714f0f8
commit 95dcdf473e
2 changed files with 29 additions and 0 deletions

View File

@@ -202,6 +202,30 @@ u'<input type="file" class="fun" name="email" />'
>>> w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'})
u'<input type="file" class="fun" name="email" />'
Test for the behavior of _has_changed for FileInput. The value of data will
more than likely come from request.FILES. The value of initial data will
likely be a filename stored in the database. Since its value is of no use to
a FileInput it is ignored.
>>> w = FileInput()
# No file was uploaded and no initial data.
>>> w._has_changed(u'', None)
False
# A file was uploaded and no initial data.
>>> w._has_changed(u'', {'filename': 'resume.txt', 'content': 'My resume'})
True
# A file was not uploaded, but there is initial data
>>> w._has_changed(u'resume.txt', None)
False
# A file was uploaded and there is initial data (file identity is not dealt
# with here)
>>> w._has_changed('resume.txt', {'filename': 'resume.txt', 'content': 'My resume'})
True
# Textarea Widget #############################################################
>>> w = Textarea()