mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #10002: inline file uploads now correctly display prior data. Thanks, dgouldin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10588 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
import re
|
||||
import datetime
|
||||
import os
|
||||
|
||||
from django.core.files import temp as tempfile
|
||||
from django.test import TestCase
|
||||
from django.contrib.auth.models import User, Permission
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
@@ -13,7 +15,10 @@ from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
|
||||
from django.utils.html import escape
|
||||
|
||||
# local test models
|
||||
from models import Article, CustomArticle, Section, ModelWithStringPrimaryKey, Person, Persona, FooAccount, BarAccount, Subscriber, ExternalSubscriber, Podcast, EmptyModel
|
||||
from models import (Article, BarAccount, CustomArticle, EmptyModel,
|
||||
ExternalSubscriber, FooAccount, Gallery,
|
||||
ModelWithStringPrimaryKey, Person, Persona, Picture,
|
||||
Podcast, Section, Subscriber)
|
||||
|
||||
try:
|
||||
set
|
||||
@@ -1039,7 +1044,6 @@ class TestInlineNotEditable(TestCase):
|
||||
response = self.client.get('/test_admin/admin/admin_views/parent/add/')
|
||||
self.failUnlessEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class AdminCustomQuerysetTest(TestCase):
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
||||
@@ -1062,3 +1066,47 @@ class AdminCustomQuerysetTest(TestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
else:
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
class AdminInlineFileUploadTest(TestCase):
|
||||
fixtures = ['admin-views-users.xml', 'admin-views-actions.xml']
|
||||
urlbit = 'admin'
|
||||
|
||||
def setUp(self):
|
||||
self.client.login(username='super', password='secret')
|
||||
|
||||
# Set up test Picture and Gallery.
|
||||
# These must be set up here instead of in fixtures in order to allow Picture
|
||||
# to use a NamedTemporaryFile.
|
||||
tdir = tempfile.gettempdir()
|
||||
file1 = tempfile.NamedTemporaryFile(suffix=".file1", dir=tdir)
|
||||
file1.write('a' * (2 ** 21))
|
||||
filename = file1.name
|
||||
file1.close()
|
||||
g = Gallery(name="Test Gallery")
|
||||
g.save()
|
||||
p = Picture(name="Test Picture", image=filename, gallery=g)
|
||||
p.save()
|
||||
|
||||
def tearDown(self):
|
||||
self.client.logout()
|
||||
|
||||
def test_inline_file_upload_edit_validation_error_post(self):
|
||||
"""
|
||||
Test that inline file uploads correctly display prior data (#10002).
|
||||
"""
|
||||
post_data = {
|
||||
"name": u"Test Gallery",
|
||||
"pictures-TOTAL_FORMS": u"2",
|
||||
"pictures-INITIAL_FORMS": u"1",
|
||||
"pictures-0-id": u"1",
|
||||
"pictures-0-gallery": u"1",
|
||||
"pictures-0-name": "Test Picture",
|
||||
"pictures-0-image": "",
|
||||
"pictures-1-id": "",
|
||||
"pictures-1-gallery": "1",
|
||||
"pictures-1-name": "Test Picture 2",
|
||||
"pictures-1-image": "",
|
||||
}
|
||||
response = self.client.post('/test_admin/%s/admin_views/gallery/1/' % self.urlbit, post_data)
|
||||
self.failUnless(response._container[0].find("Currently:") > -1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user