make post abstract optional (useful when only using post_text field for content)
This commit is contained in:
parent
8572c8fcdc
commit
41947f9b48
4 changed files with 9 additions and 3 deletions
|
@ -33,7 +33,7 @@ class PostAdmin(EnhancedModelAdminMixin, FrontendEditableAdminMixin,
|
|||
enhance_exclude = ('main_image', 'tags')
|
||||
_fieldsets = [
|
||||
(None, {
|
||||
'fields': [('title', 'categories', 'publish'), 'abstract']
|
||||
'fields': [('title', 'categories', 'publish')]
|
||||
}),
|
||||
('Info', {
|
||||
'fields': (['slug', 'tags'],
|
||||
|
@ -62,6 +62,8 @@ class PostAdmin(EnhancedModelAdminMixin, FrontendEditableAdminMixin,
|
|||
|
||||
def get_fieldsets(self, request, obj=None):
|
||||
fsets = deepcopy(self._fieldsets)
|
||||
if get_setting('USE_ABSTRACT'):
|
||||
fsets[0][1]['fields'].append('abstract')
|
||||
if not get_setting('USE_PLACEHOLDER'):
|
||||
fsets[0][1]['fields'].append('post_text')
|
||||
if get_setting('MULTISITE'):
|
||||
|
|
|
@ -5,6 +5,7 @@ from django.core.urlresolvers import reverse
|
|||
from django.utils.translation import ugettext as _
|
||||
|
||||
from .models import Post
|
||||
from .settings import get_setting
|
||||
|
||||
|
||||
class LatestEntriesFeed(Feed):
|
||||
|
@ -22,7 +23,9 @@ class LatestEntriesFeed(Feed):
|
|||
return item.safe_translation_getter('title')
|
||||
|
||||
def item_description(self, item):
|
||||
return item.safe_translation_getter('abstract')
|
||||
if get_setting('USE_ABSTRACT'):
|
||||
return item.safe_translation_getter('abstract')
|
||||
return item.safe_translation_getter('post_text')
|
||||
|
||||
|
||||
class TagFeed(LatestEntriesFeed):
|
||||
|
|
|
@ -106,7 +106,7 @@ class Post(ModelMeta, TranslatableModel):
|
|||
translations = TranslatedFields(
|
||||
title=models.CharField(_('Title'), max_length=255),
|
||||
slug=models.SlugField(_('slug'), blank=True, db_index=True),
|
||||
abstract=HTMLField(_('Abstract')),
|
||||
abstract=HTMLField(_('Abstract'), blank=True, default=''),
|
||||
meta_description=models.TextField(verbose_name=_(u'Post meta description'),
|
||||
blank=True, default=''),
|
||||
meta_keywords=models.TextField(verbose_name=_(u'Post meta keywords'),
|
||||
|
|
|
@ -47,6 +47,7 @@ def get_setting(name):
|
|||
'BLOG_GPLUS_AUTHOR': getattr(settings, 'BLOG_GPLUS_AUTHOR',
|
||||
'get_author_gplus'),
|
||||
'BLOG_ENABLE_COMMENTS': getattr(settings, 'BLOG_ENABLE_COMMENTS', True),
|
||||
'BLOG_USE_ABSTRACT': getattr(settings, 'BLOG_USE_ABSTRACT', True),
|
||||
'BLOG_USE_PLACEHOLDER': getattr(settings, 'BLOG_USE_PLACEHOLDER', True),
|
||||
'BLOG_MULTISITE': getattr(settings, 'BLOG_MULTISITE', True),
|
||||
'BLOG_AUTHOR_DEFAULT': getattr(settings, 'BLOG_AUTHOR_DEFAULT', True),
|
||||
|
|
Loading…
Reference in a new issue