Refactor settings

This commit is contained in:
Iacopo Spalletti 2014-10-11 12:23:36 +02:00
parent 04c5c9f35a
commit 1f44a4605d
7 changed files with 122 additions and 109 deletions

View file

@ -7,6 +7,7 @@ from django.conf import settings
from parler.admin import TranslatableAdmin from parler.admin import TranslatableAdmin
from .models import Post, BlogCategory from .models import Post, BlogCategory
from .settings import get_setting
class BlogCategoryAdmin(EnhancedModelAdminMixin, TranslatableAdmin): class BlogCategoryAdmin(EnhancedModelAdminMixin, TranslatableAdmin):
@ -47,11 +48,10 @@ class PostAdmin(EnhancedModelAdminMixin, FrontendEditableAdmin,
] ]
def get_fieldsets(self, request, obj=None): def get_fieldsets(self, request, obj=None):
from .settings import BLOG_USE_PLACEHOLDER, BLOG_MULTISITE
fsets = deepcopy(self._fieldsets) fsets = deepcopy(self._fieldsets)
if not BLOG_USE_PLACEHOLDER: if not get_setting('USE_PLACEHOLDER'):
fsets[0][1]['fields'].append('post_text') fsets[0][1]['fields'].append('post_text')
if BLOG_MULTISITE: if get_setting('MULTISITE'):
fsets[1][1]['fields'][0].append('sites') fsets[1][1]['fields'][0].append('sites')
if request.user.is_superuser: if request.user.is_superuser:
fsets[1][1]['fields'][0].append('author') fsets[1][1]['fields'][0].append('author')
@ -61,8 +61,7 @@ class PostAdmin(EnhancedModelAdminMixin, FrontendEditableAdmin,
return {'slug': ('title',)} return {'slug': ('title',)}
def save_model(self, request, obj, form, change): def save_model(self, request, obj, form, change):
from .settings import BLOG_AUTHOR_AUTO if not obj.author_id and get_setting('AUTHOR_AUTO'):
if not obj.author_id and BLOG_AUTHOR_AUTO:
obj.author = request.user obj.author = request.user
super(PostAdmin, self).save_model(request, obj, form, change) super(PostAdmin, self).save_model(request, obj, form, change)

View file

@ -7,7 +7,7 @@ from cms.plugin_pool import plugin_pool
from .models import AuthorEntriesPlugin, LatestPostsPlugin, Post, BlogCategory from .models import AuthorEntriesPlugin, LatestPostsPlugin, Post, BlogCategory
from .forms import LatestEntriesForm from .forms import LatestEntriesForm
from .settings import BLOG_POSTS_LIST_TRUNCWORDS_COUNT from .settings import get_setting
class BlogPlugin(CMSPluginBase): class BlogPlugin(CMSPluginBase):
@ -24,7 +24,7 @@ class BlogLatestEntriesPlugin(BlogPlugin):
def render(self, context, instance, placeholder): def render(self, context, instance, placeholder):
context['instance'] = instance context['instance'] = instance
context['TRUNCWORDS_COUNT'] = BLOG_POSTS_LIST_TRUNCWORDS_COUNT context['TRUNCWORDS_COUNT'] = get_setting('POSTS_LIST_TRUNCWORDS_COUNT')
return context return context

View file

@ -16,7 +16,7 @@ from parler.models import TranslatableModel, TranslatedFields
from parler.managers import TranslationManager from parler.managers import TranslationManager
from taggit_autosuggest.managers import TaggableManager from taggit_autosuggest.managers import TaggableManager
from . import settings from .settings import get_setting
from .managers import GenericDateTaggedManager from .managers import GenericDateTaggedManager
BLOG_CURRENT_POST_IDENTIFIER = 'djangocms_post_current' BLOG_CURRENT_POST_IDENTIFIER = 'djangocms_post_current'
@ -88,7 +88,7 @@ class Post(ModelMeta, TranslatableModel):
blank=True, null=True) blank=True, null=True)
enable_comments = models.BooleanField( enable_comments = models.BooleanField(
verbose_name=_(u'Enable comments on post'), verbose_name=_(u'Enable comments on post'),
default=settings.BLOG_ENABLE_COMMENTS default=get_setting('ENABLE_COMMENTS')
) )
sites = models.ManyToManyField(Site, verbose_name=_(u'Site(s'), blank=True, null=True, sites = models.ManyToManyField(Site, verbose_name=_(u'Site(s'), blank=True, null=True,
help_text=_(u'Select sites in which to show the post. If none is set it will be' help_text=_(u'Select sites in which to show the post. If none is set it will be'
@ -124,17 +124,17 @@ class Post(ModelMeta, TranslatableModel):
'keywords': 'get_keywords', 'keywords': 'get_keywords',
'locale': None, 'locale': None,
'image': 'get_image_full_url', 'image': 'get_image_full_url',
'object_type': settings.BLOG_TYPE, 'object_type': get_setting('TYPE'),
'og_type': settings.BLOG_FB_TYPE, 'og_type': get_setting('FB_TYPE'),
'og_app_id': settings.BLOG_FB_APPID, 'og_app_id': get_setting('FB_APPID'),
'og_profile_id': settings.BLOG_FB_PROFILE_ID, 'og_profile_id': get_setting('FB_PROFILE_ID'),
'og_publisher': settings.BLOG_FB_PUBLISHER, 'og_publisher': get_setting('FB_PUBLISHER'),
'og_author_url': settings.BLOG_FB_AUTHOR_URL, 'og_author_url': get_setting('FB_AUTHOR_URL'),
'twitter_type': settings.BLOG_TWITTER_TYPE, 'twitter_type': get_setting('TWITTER_TYPE'),
'twitter_site': settings.BLOG_TWITTER_SITE, 'twitter_site': get_setting('TWITTER_SITE'),
'twitter_author': settings.BLOG_TWITTER_AUTHOR, 'twitter_author': get_setting('TWITTER_AUTHOR'),
'gplus_type': settings.BLOG_GPLUS_TYPE, 'gplus_type': get_setting('GPLUS_TYPE'),
'gplus_author': settings.BLOG_GPLUS_AUTHOR, 'gplus_author': get_setting('GPLUS_AUTHOR'),
'published_time': 'date_published', 'published_time': 'date_published',
'modified_time': 'date_modified', 'modified_time': 'date_modified',
'expiration_time': 'date_published_end', 'expiration_time': 'date_published_end',
@ -199,13 +199,13 @@ class Post(ModelMeta, TranslatableModel):
if self.main_image_thumbnail_id: if self.main_image_thumbnail_id:
return self.main_image_thumbnail.as_dict return self.main_image_thumbnail.as_dict
else: else:
return settings.BLOG_IMAGE_THUMBNAIL_SIZE return get_setting('IMAGE_THUMBNAIL_SIZE')
def full_image_options(self): def full_image_options(self):
if self.main_image_full_id: if self.main_image_full_id:
return self.main_image_full.as_dict return self.main_image_full.as_dict
else: else:
return settings.BLOG_IMAGE_FULL_SIZE return get_setting('IMAGE_FULL_SIZE')
def get_full_url(self): def get_full_url(self):
return self.make_full_url(self.get_absolute_url()) return self.make_full_url(self.get_absolute_url())
@ -213,7 +213,7 @@ class Post(ModelMeta, TranslatableModel):
class LatestPostsPlugin(CMSPlugin): class LatestPostsPlugin(CMSPlugin):
latest_posts = models.IntegerField(_(u'Articles'), default=settings.BLOG_LATEST_POSTS, latest_posts = models.IntegerField(_(u'Articles'), default=get_setting('LATEST_POSTS'),
help_text=_('The number of latests articles to be displayed.')) help_text=_('The number of latests articles to be displayed.'))
tags = models.ManyToManyField('taggit.Tag', blank=True, tags = models.ManyToManyField('taggit.Tag', blank=True,
help_text=_('Show only the blog articles tagged with chosen tags.')) help_text=_('Show only the blog articles tagged with chosen tags.'))
@ -240,7 +240,7 @@ class AuthorEntriesPlugin(CMSPlugin):
limit_choices_to={'djangocms_blog_post_author__publish': True} limit_choices_to={'djangocms_blog_post_author__publish': True}
) )
latest_posts = models.IntegerField( latest_posts = models.IntegerField(
_(u'Articles'), default=settings.BLOG_LATEST_POSTS, _(u'Articles'), default=get_setting('LATEST_POSTS'),
help_text=_('The number of author articles to be displayed.') help_text=_('The number of author articles to be displayed.')
) )

View file

@ -1,37 +1,54 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.conf import settings
from meta_mixin import settings as meta_settings
BLOG_IMAGE_THUMBNAIL_SIZE = getattr(settings, 'BLOG_IMAGE_THUMBNAIL_SIZE', {
'size': '120x120',
'crop': True,
'upscale': False
})
BLOG_IMAGE_FULL_SIZE = getattr(settings, 'BLOG_IMAGE_FULL_SIZE', { def get_setting(name):
'size': '640x120', from django.conf import settings
'crop': True, from meta_mixin import settings as meta_settings
'upscale': False
})
BLOG_TAGCLOUD_MIN = getattr(settings, 'BLOG_TAGCLOUD_MIN', 1) default = {
BLOG_TAGCLOUD_MAX = getattr(settings, 'BLOG_TAGCLOUD_MAX', 10) 'BLOG_IMAGE_THUMBNAIL_SIZE': getattr(settings, 'BLOG_IMAGE_THUMBNAIL_SIZE', {
BLOG_PAGINATION = getattr(settings, 'BLOG_PAGINATION', 10) 'size': '120x120',
BLOG_LATEST_POSTS = getattr(settings, 'BLOG_LATEST_POSTS', 5) 'crop': True,
BLOG_POSTS_LIST_TRUNCWORDS_COUNT = getattr(settings, 'BLOG_POSTS_LIST_TRUNCWORDS_COUNT', 100) 'upscale': False
BLOG_TYPE = getattr(settings, 'BLOG_TYPE', 'Article') }),
BLOG_FB_TYPE = getattr(settings, 'BLOG_FB_TYPE', 'Article')
BLOG_FB_APPID = getattr(settings, 'BLOG_FB_APPID', meta_settings.FB_APPID) 'BLOG_IMAGE_FULL_SIZE': getattr(settings, 'BLOG_IMAGE_FULL_SIZE', {
BLOG_FB_PROFILE_ID = getattr(settings, 'BLOG_FB_PROFILE_ID', meta_settings.FB_PROFILE_ID) 'size': '640x120',
BLOG_FB_PUBLISHER = getattr(settings, 'BLOG_FB_PUBLISHER', meta_settings.FB_PUBLISHER) 'crop': True,
BLOG_FB_AUTHOR_URL = getattr(settings, 'BLOG_FB_AUTHOR_URL', 'get_author_url') 'upscale': False
BLOG_FB_AUTHOR = getattr(settings, 'BLOG_FB_AUTHOR', 'get_author_name') }),
BLOG_TWITTER_TYPE = getattr(settings, 'BLOG_TWITTER_TYPE', 'Summary')
BLOG_TWITTER_SITE = getattr(settings, 'BLOG_TWITTER_SITE', meta_settings.TWITTER_SITE) 'BLOG_TAGCLOUD_MIN': getattr(settings, 'BLOG_TAGCLOUD_MIN', 1),
BLOG_TWITTER_AUTHOR = getattr(settings, 'BLOG_TWITTER_AUTHOR', 'get_author_twitter') 'BLOG_TAGCLOUD_MAX': getattr(settings, 'BLOG_TAGCLOUD_MAX', 10),
BLOG_GPLUS_TYPE = getattr(settings, 'BLOG_GPLUS_SCOPE_CATEGORY', 'Blog') 'BLOG_PAGINATION': getattr(settings, 'BLOG_PAGINATION', 10),
BLOG_GPLUS_AUTHOR = getattr(settings, 'BLOG_GPLUS_AUTHOR', 'get_author_gplus') 'BLOG_LATEST_POSTS': getattr(settings, 'BLOG_LATEST_POSTS', 5),
BLOG_ENABLE_COMMENTS = getattr(settings, 'BLOG_ENABLE_COMMENTS', True) 'BLOG_POSTS_LIST_TRUNCWORDS_COUNT': getattr(settings,
BLOG_USE_PLACEHOLDER = getattr(settings, 'BLOG_USE_PLACEHOLDER', True) 'BLOG_POSTS_LIST_TRUNCWORDS_COUNT',
BLOG_MULTISITE = getattr(settings, 'BLOG_MULTISITE', True) 100),
BLOG_AUTHOR_AUTO = getattr(settings, 'BLOG_AUTHOR_AUTO', True) 'BLOG_TYPE': getattr(settings, 'BLOG_TYPE', 'Article'),
'BLOG_FB_TYPE': getattr(settings, 'BLOG_FB_TYPE', 'Article'),
'BLOG_FB_APPID': getattr(settings, 'BLOG_FB_APPID',
meta_settings.FB_APPID),
'BLOG_FB_PROFILE_ID': getattr(settings, 'BLOG_FB_PROFILE_ID',
meta_settings.FB_PROFILE_ID),
'BLOG_FB_PUBLISHER': getattr(settings, 'BLOG_FB_PUBLISHER',
meta_settings.FB_PUBLISHER),
'BLOG_FB_AUTHOR_URL': getattr(settings, 'BLOG_FB_AUTHOR_URL',
'get_author_url'),
'BLOG_FB_AUTHOR': getattr(settings, 'BLOG_FB_AUTHOR',
'get_author_name'),
'BLOG_TWITTER_TYPE': getattr(settings, 'BLOG_TWITTER_TYPE', 'Summary'),
'BLOG_TWITTER_SITE': getattr(settings, 'BLOG_TWITTER_SITE',
meta_settings.TWITTER_SITE),
'BLOG_TWITTER_AUTHOR': getattr(settings, 'BLOG_TWITTER_AUTHOR',
'get_author_twitter'),
'BLOG_GPLUS_TYPE': getattr(settings, 'BLOG_GPLUS_SCOPE_CATEGORY',
'Blog'),
'BLOG_GPLUS_AUTHOR': getattr(settings, 'BLOG_GPLUS_AUTHOR',
'get_author_gplus'),
'BLOG_ENABLE_COMMENTS': getattr(settings, 'BLOG_ENABLE_COMMENTS', True),
'BLOG_USE_PLACEHOLDER': getattr(settings, 'BLOG_USE_PLACEHOLDER', True),
'BLOG_MULTISITE': getattr(settings, 'BLOG_MULTISITE', True),
'BLOG_AUTHOR_AUTO': getattr(settings, 'BLOG_AUTHOR_AUTO', True),
}
return default['BLOG_%s' % name]

View file

@ -8,8 +8,7 @@ from django.views.generic import ListView, DetailView
from parler.views import ViewUrlMixin, TranslatableSlugMixin from parler.views import ViewUrlMixin, TranslatableSlugMixin
from .models import Post, BlogCategory, BLOG_CURRENT_POST_IDENTIFIER from .models import Post, BlogCategory, BLOG_CURRENT_POST_IDENTIFIER
from .settings import (BLOG_PAGINATION, BLOG_POSTS_LIST_TRUNCWORDS_COUNT, from .settings import get_setting
BLOG_USE_PLACEHOLDER)
User = get_user_model() User = get_user_model()
@ -32,12 +31,12 @@ class PostListView(BaseBlogView, ListView):
model = Post model = Post
context_object_name = 'post_list' context_object_name = 'post_list'
template_name = 'djangocms_blog/post_list.html' template_name = 'djangocms_blog/post_list.html'
paginate_by = BLOG_PAGINATION paginate_by = get_setting('PAGINATION')
view_url_name = 'djangocms_blog:posts-latest' view_url_name = 'djangocms_blog:posts-latest'
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(PostListView, self).get_context_data(**kwargs) context = super(PostListView, self).get_context_data(**kwargs)
context['TRUNCWORDS_COUNT'] = BLOG_POSTS_LIST_TRUNCWORDS_COUNT context['TRUNCWORDS_COUNT'] = get_setting('POSTS_LIST_TRUNCWORDS_COUNT')
return context return context
@ -51,7 +50,7 @@ class PostDetailView(TranslatableSlugMixin, BaseBlogView, DetailView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(PostDetailView, self).get_context_data(**kwargs) context = super(PostDetailView, self).get_context_data(**kwargs)
context['meta'] = self.get_object().as_meta() context['meta'] = self.get_object().as_meta()
context['use_placeholer'] = BLOG_USE_PLACEHOLDER context['use_placeholer'] = get_setting('USE_PLACEHOLDER')
setattr(self.request, BLOG_CURRENT_POST_IDENTIFIER, self.get_object()) setattr(self.request, BLOG_CURRENT_POST_IDENTIFIER, self.get_object())
return context return context
@ -63,7 +62,7 @@ class PostArchiveView(BaseBlogView, ListView):
date_field = 'date_published' date_field = 'date_published'
allow_empty = True allow_empty = True
allow_future = True allow_future = True
paginate_by = BLOG_PAGINATION paginate_by = get_setting('PAGINATION')
view_url_name = 'djangocms_blog:posts-archive' view_url_name = 'djangocms_blog:posts-archive'
def get_queryset(self): def get_queryset(self):
@ -86,7 +85,7 @@ class TaggedListView(BaseBlogView, ListView):
model = Post model = Post
context_object_name = 'post_list' context_object_name = 'post_list'
template_name = 'djangocms_blog/post_list.html' template_name = 'djangocms_blog/post_list.html'
paginate_by = BLOG_PAGINATION paginate_by = get_setting('PAGINATION')
view_url_name = 'djangocms_blog:posts-tagged' view_url_name = 'djangocms_blog:posts-tagged'
def get_queryset(self): def get_queryset(self):
@ -103,7 +102,7 @@ class AuthorEntriesView(BaseBlogView, ListView):
model = Post model = Post
context_object_name = 'post_list' context_object_name = 'post_list'
template_name = 'djangocms_blog/post_list.html' template_name = 'djangocms_blog/post_list.html'
paginate_by = BLOG_PAGINATION paginate_by = get_setting('PAGINATION')
view_url_name = 'djangocms_blog:posts-authors' view_url_name = 'djangocms_blog:posts-authors'
def get_queryset(self): def get_queryset(self):
@ -122,7 +121,7 @@ class CategoryEntriesView(BaseBlogView, ListView):
context_object_name = 'post_list' context_object_name = 'post_list'
template_name = 'djangocms_blog/post_list.html' template_name = 'djangocms_blog/post_list.html'
_category = None _category = None
paginate_by = BLOG_PAGINATION paginate_by = get_setting('PAGINATION')
view_url_name = 'djangocms_blog:posts-category' view_url_name = 'djangocms_blog:posts-category'
@property @property

View file

@ -13,7 +13,7 @@ import parler
from taggit.models import Tag from taggit.models import Tag
from djangocms_blog.models import Post from djangocms_blog.models import Post
from djangocms_blog import settings from djangocms_blog.settings import get_setting
from . import BaseTest from . import BaseTest
@ -25,21 +25,20 @@ class AdminTest(BaseTest):
request = self.get_page_request('/', self.user_staff, r'/en/blog/', edit=False) request = self.get_page_request('/', self.user_staff, r'/en/blog/', edit=False)
post_admin = admin.site._registry[Post] post_admin = admin.site._registry[Post]
settings.BLOG_USE_PLACEHOLDER = True with self.settings(BLOG_USE_PLACEHOLDER=True):
fsets = post_admin.get_fieldsets(request) fsets = post_admin.get_fieldsets(request)
self.assertFalse('post_text' in fsets[0][1]['fields']) self.assertFalse('post_text' in fsets[0][1]['fields'])
settings.BLOG_USE_PLACEHOLDER = False
fsets = post_admin.get_fieldsets(request)
self.assertTrue('post_text' in fsets[0][1]['fields'])
settings.BLOG_USE_PLACEHOLDER = True
settings.BLOG_MULTISITE = True with self.settings(BLOG_USE_PLACEHOLDER=False):
fsets = post_admin.get_fieldsets(request) fsets = post_admin.get_fieldsets(request)
self.assertTrue('sites' in fsets[1][1]['fields'][0]) self.assertTrue('post_text' in fsets[0][1]['fields'])
settings.BLOG_MULTISITE = False
fsets = post_admin.get_fieldsets(request) with self.settings(BLOG_MULTISITE=True):
self.assertFalse('sites' in fsets[1][1]['fields'][0]) fsets = post_admin.get_fieldsets(request)
settings.BLOG_MULTISITE = True self.assertTrue('sites' in fsets[1][1]['fields'][0])
with self.settings(BLOG_MULTISITE=False):
fsets = post_admin.get_fieldsets(request)
self.assertFalse('sites' in fsets[1][1]['fields'][0])
request = self.get_page_request('/', self.user, r'/en/blog/', edit=False) request = self.get_page_request('/', self.user, r'/en/blog/', edit=False)
fsets = post_admin.get_fieldsets(request) fsets = post_admin.get_fieldsets(request)
@ -49,30 +48,31 @@ class AdminTest(BaseTest):
page1, page2 = self.get_pages() page1, page2 = self.get_pages()
request = self.get_page_request('/', self.user_staff, r'/en/blog/', edit=False) request = self.get_page_request('/', self.user_staff, r'/en/blog/', edit=False)
data = deepcopy(self.data['en'][0]) data = deepcopy(self.data['en'][0])
data['date_published_0'] = now().strftime('%Y-%m-%d')
data['date_published_1'] = now().strftime('%H:%M:%S')
data['categories'] = self.category_1.pk
request = self.post_request(page1, 'en', data=data)
msg_mid = MessageMiddleware()
msg_mid.process_request(request)
post_admin = admin.site._registry[Post]
post_admin.add_view(request)
self.assertEqual(Post.objects.count(), 1)
self.assertEqual(Post.objects.get(translations__slug='first-post').author_id, 1)
settings.BLOG_AUTHOR_AUTO = False with self.settings(BLOG_AUTHOR_AUTO=True):
data = deepcopy(self.data['en'][1]) data['date_published_0'] = now().strftime('%Y-%m-%d')
data['date_published_0'] = now().strftime('%Y-%m-%d') data['date_published_1'] = now().strftime('%H:%M:%S')
data['date_published_1'] = now().strftime('%H:%M:%S') data['categories'] = self.category_1.pk
data['categories'] = self.category_1.pk request = self.post_request(page1, 'en', data=data)
request = self.post_request(page1, 'en', data=data) msg_mid = MessageMiddleware()
msg_mid = MessageMiddleware() msg_mid.process_request(request)
msg_mid.process_request(request) post_admin = admin.site._registry[Post]
post_admin = admin.site._registry[Post] post_admin.add_view(request)
post_admin.add_view(request) self.assertEqual(Post.objects.count(), 1)
self.assertEqual(Post.objects.count(), 2) self.assertEqual(Post.objects.get(translations__slug='first-post').author_id, 1)
self.assertEqual(Post.objects.get(translations__slug='second-post').author_id, None)
settings.BLOG_AUTHOR_AUTO = True with self.settings(BLOG_AUTHOR_AUTO=False):
data = deepcopy(self.data['en'][1])
data['date_published_0'] = now().strftime('%Y-%m-%d')
data['date_published_1'] = now().strftime('%H:%M:%S')
data['categories'] = self.category_1.pk
request = self.post_request(page1, 'en', data=data)
msg_mid = MessageMiddleware()
msg_mid.process_request(request)
post_admin = admin.site._registry[Post]
post_admin.add_view(request)
self.assertEqual(Post.objects.count(), 2)
self.assertEqual(Post.objects.get(translations__slug='second-post').author_id, None)
class ModelsTest(BaseTest): class ModelsTest(BaseTest):
@ -84,7 +84,7 @@ class ModelsTest(BaseTest):
post.save() post.save()
post.set_current_language('en') post.set_current_language('en')
meta_en = post.as_meta() meta_en = post.as_meta()
self.assertEqual(meta_en.og_type, settings.BLOG_FB_TYPE) self.assertEqual(meta_en.og_type, get_setting('FB_TYPE'))
self.assertEqual(meta_en.title, post.title) self.assertEqual(meta_en.title, post.title)
self.assertTrue(meta_en.url.endswith(post.get_absolute_url())) self.assertTrue(meta_en.url.endswith(post.get_absolute_url()))
self.assertEqual(meta_en.description, post.meta_description) self.assertEqual(meta_en.description, post.meta_description)
@ -119,8 +119,8 @@ class ModelsTest(BaseTest):
self.assertEqual(post.get_full_url(), 'http://example.com%s' % url_it) self.assertEqual(post.get_full_url(), 'http://example.com%s' % url_it)
self.assertEqual(post.get_image_full_url(), 'http://example.com%s' % post.main_image.url) self.assertEqual(post.get_image_full_url(), 'http://example.com%s' % post.main_image.url)
self.assertEqual(post.thumbnail_options(), settings.BLOG_IMAGE_THUMBNAIL_SIZE) self.assertEqual(post.thumbnail_options(), get_setting('IMAGE_THUMBNAIL_SIZE'))
self.assertEqual(post.full_image_options(), settings.BLOG_IMAGE_FULL_SIZE) self.assertEqual(post.full_image_options(), get_setting('IMAGE_FULL_SIZE'))
post.main_image_thumbnail = self.thumb_1 post.main_image_thumbnail = self.thumb_1
post.main_image_full = self.thumb_2 post.main_image_full = self.thumb_2

View file

@ -4,8 +4,6 @@ from django.http import Http404
from django.utils.translation import activate from django.utils.translation import activate
from django.utils.timezone import now from django.utils.timezone import now
from parler.utils.context import switch_language from parler.utils.context import switch_language
from cms.middleware.toolbar import ToolbarMiddleware
from djangocms_blog.models import Post, BlogCategory
from djangocms_blog.feeds import LatestEntriesFeed, TagFeed from djangocms_blog.feeds import LatestEntriesFeed, TagFeed
from djangocms_blog.sitemaps import BlogSitemap from djangocms_blog.sitemaps import BlogSitemap
from djangocms_blog.views import (PostListView, PostDetailView, from djangocms_blog.views import (PostListView, PostDetailView,