From 006a1cfbdb5f61b6725b7675c7f9117e85b5d367 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 27 May 2018 02:07:06 +0200 Subject: [PATCH] Reenable missing tests for custom image models --- filer/admin/imageadmin.py | 8 +- filer/test_utils/custom_image/models.py | 1 + filer/tests/admin.py | 145 ++++++++++++------------ 3 files changed, 79 insertions(+), 75 deletions(-) diff --git a/filer/admin/imageadmin.py b/filer/admin/imageadmin.py index af405616b..e91b9e886 100644 --- a/filer/admin/imageadmin.py +++ b/filer/admin/imageadmin.py @@ -90,11 +90,17 @@ class Media(object): class ImageAdmin(FileAdmin): + change_form_template = 'admin/filer/image/change_form.html' form = ImageAdminForm +if FILER_IMAGE_MODEL == 'filer.Image': + extra_main_fields = ('author', 'default_alt_text', 'default_caption',) +else: + extra_main_fields = ('default_alt_text', 'default_caption',) + ImageAdmin.fieldsets = ImageAdmin.build_fieldsets( - extra_main_fields=('author', 'default_alt_text', 'default_caption',), + extra_main_fields=extra_main_fields, extra_fieldsets=( (_('Subject location'), { 'fields': ('subject_location',), diff --git a/filer/test_utils/custom_image/models.py b/filer/test_utils/custom_image/models.py index 34e7a672b..6e81c4f98 100644 --- a/filer/test_utils/custom_image/models.py +++ b/filer/test_utils/custom_image/models.py @@ -11,6 +11,7 @@ class Image(BaseImage): extra_description = models.TextField() class Meta(BaseImage.Meta): + swappable = 'FILER_IMAGE_MODEL' app_label = 'custom_image' if GTE_DJANGO_1_10: default_manager_name = 'objects' diff --git a/filer/tests/admin.py b/filer/tests/admin.py index 60944176a..8a6d09562 100644 --- a/filer/tests/admin.py +++ b/filer/tests/admin.py @@ -920,9 +920,9 @@ class DontSearchOwnerEmailFolderAdmin(FolderAdmin): self.assertEqual(len(folder_qs), 0) def test_search_special_characters(self): - """ + """ Regression test for https://github.com/divio/django-filer/pull/945. - Because of a wrong unquoting function being used, searches with + Because of a wrong unquoting function being used, searches with some "_XX" sequences got unquoted as unicode characters. For example, "_ec" gets unquoted as u'ì'. """ @@ -1085,40 +1085,38 @@ def test_regular_mode_image_with_folder_delete(self): ) def test_pick_mode_image_save(self): - if not FILER_IMAGE_MODEL: - image = self.create_image(folder=None) - base_url = image.get_admin_change_url() - pick_url = base_url + '?_pick=file&_popup=1' - - response = self.client.get(pick_url) - self.assertEqual(response.status_code, 200) - self.assertContains(response, '