Skip to content

Commit

Permalink
Forward port 0.9.9 to develop (#479)
Browse files Browse the repository at this point in the history
* Pin taggit version for 0.9 (#477)

Newly released version 0.24 has some breaking changes

* Fix thumbnail selection in post form (#478)

check that initial thumbnail fields are empty before overriding their value
  • Loading branch information
yakky committed Mar 5, 2019
1 parent 62d1250 commit 9576a4a
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 7 deletions.
7 changes: 7 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ History
* Dropped django CMS <3.5
* Dropped Python 3.4

******************
0.9.9 (2019-04-05)
******************

* Fixed issue with thumbnails not being preserved in admin form
* Pinned django-taggit version

******************
0.9.8 (2019-01-13)
******************
Expand Down
2 changes: 1 addition & 1 deletion djangocms_blog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

__author__ = 'Iacopo Spalletti'
__email__ = 'i.spalletti@nephila.it'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'

default_app_config = 'djangocms_blog.apps.BlogAppConfig'
10 changes: 6 additions & 4 deletions djangocms_blog/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ def __init__(self, *args, **kwargs):
self.fields['app_config'].widget.can_add_related = False

if self.app_config:
self.initial['main_image_full'] = \
self.app_config.app_data['config'].get('default_image_full')
self.initial['main_image_thumbnail'] = \
self.app_config.app_data['config'].get('default_image_thumbnail')
if not self.initial.get('main_image_full', ''):
self.initial['main_image_full'] = \
self.app_config.app_data['config'].get('default_image_full')
if not self.initial.get('main_image_thumbnail', ''):
self.initial['main_image_thumbnail'] = \
self.app_config.app_data['config'].get('default_image_thumbnail')
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
install_requires=[
'django-parler>=1.9',
'django-cms>=3.5',
'django-taggit>=0.12.2',
'django-filer>=1.3',
'django-taggit>=0.20,<0.24',
'django-filer>=1.4',
'pytz',
'django-taggit-templatetags',
'django-taggit-autosuggest',
Expand Down
43 changes: 43 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,49 @@ def setUp(self):
upscale=True,
)

def test_admin_thumbnails(self):
self.get_pages()

custom_thumbnail = ThumbnailOption.objects.create(
name='Custom thumbnail', width=120, height=120, crop=True, upscale=True,
)
custom_full = ThumbnailOption.objects.create(
name='Custom image', width=800, height=200, crop=True, upscale=True,
)

post_admin = admin.site._registry[Post]
request = self.get_page_request('/', self.user, r'/en/blog/', edit=False)

post = self._get_post(self._post_data[0]['en'])
post = self._get_post(self._post_data[0]['it'], post, 'it')

response = post_admin.change_view(request, str(post.pk))
response.render()
self.assertRegexpMatches(force_text(response.content), r'[^>]*>Custom image')
self.assertRegexpMatches(force_text(response.content), r'[^>]*>Custom thumbnail')
self.assertRegexpMatches(force_text(response.content), r'[^>]*>Blog image')
self.assertRegexpMatches(force_text(response.content), r'[^>]*>Blog thumbnail')

post.main_image_full = custom_full
post.main_image_thumbnail = custom_thumbnail
post.save()
response = post_admin.change_view(request, str(post.pk))
response.render()
self.assertRegexpMatches(force_text(response.content), r'selected[^>]*>Custom image')
self.assertRegexpMatches(force_text(response.content), r'selected[^>]*>Custom thumbnail')

self.app_config_1.app_data.config.default_image_full = self.default_full
self.app_config_1.app_data.config.default_image_thumbnail = self.default_thumbnail
self.app_config_1.save()
post.main_image_full = None
post.main_image_thumbnail = None
post.save()

response = post_admin.change_view(request, str(post.pk))
response.render()
self.assertRegexpMatches(force_text(response.content), r'selected[^>]*>Blog image')
self.assertRegexpMatches(force_text(response.content), r'selected[^>]*>Blog thumbnail')

def test_admin_post_views(self):
self.get_pages()

Expand Down

0 comments on commit 9576a4a

Please sign in to comment.