summaryrefslogtreecommitdiff
path: root/tests/regressiontests/admin_views/models.py
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-04-18 20:29:55 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-04-18 20:29:55 +0000
commit1e4ad6f118007547c7e627f1d5bd11bfb2992bf9 (patch)
tree290125870f412765e36bf49cb69fb80ea8700d04 /tests/regressiontests/admin_views/models.py
parenta075422bfc433d196b2fd1e64b8c8b9dbbf32591 (diff)
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
Diffstat (limited to 'tests/regressiontests/admin_views/models.py')
-rw-r--r--tests/regressiontests/admin_views/models.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_views/models.py b/tests/regressiontests/admin_views/models.py
index f1c24c2e99..211851f7b7 100644
--- a/tests/regressiontests/admin_views/models.py
+++ b/tests/regressiontests/admin_views/models.py
@@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-
+import tempfile
+import os
+from django.core.files.storage import FileSystemStorage
from django.db import models
from django.contrib import admin
from django.core.mail import EmailMessage
@@ -291,6 +294,27 @@ class EmptyModelAdmin(admin.ModelAdmin):
class OldSubscriberAdmin(admin.ModelAdmin):
actions = None
+temp_storage = FileSystemStorage(tempfile.mkdtemp())
+UPLOAD_TO = os.path.join(temp_storage.location, 'test_upload')
+
+class Gallery(models.Model):
+ name = models.CharField(max_length=100)
+
+class Picture(models.Model):
+ name = models.CharField(max_length=100)
+ image = models.FileField(storage=temp_storage, upload_to='test_upload')
+ gallery = models.ForeignKey(Gallery, related_name="pictures")
+
+class PictureInline(admin.TabularInline):
+ model = Picture
+ extra = 1
+
+class GalleryAdmin(admin.ModelAdmin):
+ inlines = [PictureInline]
+
+class PictureAdmin(admin.ModelAdmin):
+ pass
+
admin.site.register(Article, ArticleAdmin)
admin.site.register(CustomArticle, CustomArticleAdmin)
admin.site.register(Section, save_as=True, inlines=[ArticleInline])
@@ -306,6 +330,8 @@ admin.site.register(Podcast, PodcastAdmin)
admin.site.register(Parent, ParentAdmin)
admin.site.register(EmptyModel, EmptyModelAdmin)
admin.site.register(Fabric, FabricAdmin)
+admin.site.register(Gallery, GalleryAdmin)
+admin.site.register(Picture, PictureAdmin)
# We intentionally register Promo and ChapterXtra1 but not Chapter nor ChapterXtra2.
# That way we cover all four cases: