Add future
This commit is contained in:
parent
c6ae227adf
commit
093dff43c4
21 changed files with 72 additions and 32 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
|
|
||||||
gettext = lambda s: s
|
gettext = lambda s: s
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from cms.admin.placeholderadmin import FrontendEditableAdminMixin, PlaceholderAdminMixin
|
from cms.admin.placeholderadmin import FrontendEditableAdminMixin, PlaceholderAdminMixin
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from cms.app_base import CMSApp
|
from cms.app_base import CMSApp
|
||||||
from cms.apphook_pool import apphook_pool
|
from cms.apphook_pool import apphook_pool
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from cms.models.pluginmodel import CMSPlugin
|
from cms.models.pluginmodel import CMSPlugin
|
||||||
from cms.plugin_base import CMSPluginBase
|
from cms.plugin_base import CMSPluginBase
|
||||||
from cms.plugin_pool import plugin_pool
|
from cms.plugin_pool import plugin_pool
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from cms.toolbar_base import CMSToolbar
|
from cms.toolbar_base import CMSToolbar
|
||||||
from cms.toolbar_pool import toolbar_pool
|
from cms.toolbar_pool import toolbar_pool
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from heapq import nlargest
|
from heapq import nlargest
|
||||||
from itertools import ifilter, repeat
|
from itertools import ifilter, repeat
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
from django.contrib.syndication.views import Feed
|
from django.contrib.syndication.views import Feed
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from taggit_autosuggest.widgets import TagAutoSuggest
|
from taggit_autosuggest.widgets import TagAutoSuggest
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from cms.menu_bases import CMSAttachMenu
|
from cms.menu_bases import CMSAttachMenu
|
||||||
from django.db.models.signals import post_delete, post_save
|
from django.db.models.signals import post_delete, post_save
|
||||||
from django.utils.translation import get_language, ugettext_lazy as _
|
from django.utils.translation import get_language, ugettext_lazy as _
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from cms.models import CMSPlugin, PlaceholderField
|
from cms.models import CMSPlugin, PlaceholderField
|
||||||
from django.conf import settings as dj_settings
|
from django.conf import settings as dj_settings
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
|
@ -74,52 +76,52 @@ class Post(ModelMeta, TranslatableModel):
|
||||||
Blog post
|
Blog post
|
||||||
"""
|
"""
|
||||||
author = models.ForeignKey(dj_settings.AUTH_USER_MODEL,
|
author = models.ForeignKey(dj_settings.AUTH_USER_MODEL,
|
||||||
verbose_name=_(u'author'), null=True, blank=True,
|
verbose_name=_('author'), null=True, blank=True,
|
||||||
related_name='djangocms_blog_post_author')
|
related_name='djangocms_blog_post_author')
|
||||||
|
|
||||||
date_created = models.DateTimeField(_(u'created'), auto_now_add=True)
|
date_created = models.DateTimeField(_('created'), auto_now_add=True)
|
||||||
date_modified = models.DateTimeField(_(u'last modified'), auto_now=True)
|
date_modified = models.DateTimeField(_('last modified'), auto_now=True)
|
||||||
date_published = models.DateTimeField(_(u'published Since'),
|
date_published = models.DateTimeField(_('published Since'),
|
||||||
default=timezone.now)
|
default=timezone.now)
|
||||||
date_published_end = models.DateTimeField(_(u'published Until'), null=True,
|
date_published_end = models.DateTimeField(_('published Until'), null=True,
|
||||||
blank=True)
|
blank=True)
|
||||||
publish = models.BooleanField(_(u'publish'), default=False)
|
publish = models.BooleanField(_('publish'), default=False)
|
||||||
categories = models.ManyToManyField('djangocms_blog.BlogCategory', verbose_name=_(u'category'),
|
categories = models.ManyToManyField('djangocms_blog.BlogCategory', verbose_name=_('category'),
|
||||||
related_name='blog_posts',)
|
related_name='blog_posts',)
|
||||||
main_image = FilerImageField(verbose_name=_(u'main image'), blank=True, null=True,
|
main_image = FilerImageField(verbose_name=_('main image'), blank=True, null=True,
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
related_name='djangocms_blog_post_image')
|
related_name='djangocms_blog_post_image')
|
||||||
main_image_thumbnail = models.ForeignKey('cmsplugin_filer_image.ThumbnailOption',
|
main_image_thumbnail = models.ForeignKey('cmsplugin_filer_image.ThumbnailOption',
|
||||||
verbose_name=_(u'main image thumbnail'),
|
verbose_name=_('main image thumbnail'),
|
||||||
related_name='djangocms_blog_post_thumbnail',
|
related_name='djangocms_blog_post_thumbnail',
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
blank=True, null=True)
|
blank=True, null=True)
|
||||||
main_image_full = models.ForeignKey('cmsplugin_filer_image.ThumbnailOption',
|
main_image_full = models.ForeignKey('cmsplugin_filer_image.ThumbnailOption',
|
||||||
verbose_name=_(u'main image full'),
|
verbose_name=_('main image full'),
|
||||||
related_name='djangocms_blog_post_full',
|
related_name='djangocms_blog_post_full',
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
blank=True, null=True)
|
blank=True, null=True)
|
||||||
enable_comments = models.BooleanField(verbose_name=_(u'enable comments on post'),
|
enable_comments = models.BooleanField(verbose_name=_('enable comments on post'),
|
||||||
default=get_setting('ENABLE_COMMENTS'))
|
default=get_setting('ENABLE_COMMENTS'))
|
||||||
sites = models.ManyToManyField('sites.Site', verbose_name=_(u'Site(s)'), blank=True,
|
sites = models.ManyToManyField('sites.Site', verbose_name=_('Site(s)'), blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
help_text=_(u'Select sites in which to show the post. '
|
help_text=_('Select sites in which to show the post. '
|
||||||
u'If none is set it will be '
|
u'If none is set it will be '
|
||||||
u'visible in all the configured sites.'))
|
u'visible in all the configured sites.'))
|
||||||
|
|
||||||
translations = TranslatedFields(
|
translations = TranslatedFields(
|
||||||
title=models.CharField(_(u'title'), max_length=255),
|
title=models.CharField(_('title'), max_length=255),
|
||||||
slug=models.SlugField(_(u'slug'), blank=True, db_index=True),
|
slug=models.SlugField(_('slug'), blank=True, db_index=True),
|
||||||
abstract=HTMLField(_(u'abstract'), blank=True, default=''),
|
abstract=HTMLField(_('abstract'), blank=True, default=''),
|
||||||
meta_description=models.TextField(verbose_name=_(u'post meta description'),
|
meta_description=models.TextField(verbose_name=_('post meta description'),
|
||||||
blank=True, default=''),
|
blank=True, default=''),
|
||||||
meta_keywords=models.TextField(verbose_name=_(u'post meta keywords'),
|
meta_keywords=models.TextField(verbose_name=_('post meta keywords'),
|
||||||
blank=True, default=''),
|
blank=True, default=''),
|
||||||
meta_title=models.CharField(verbose_name=_(u'post meta title'),
|
meta_title=models.CharField(verbose_name=_('post meta title'),
|
||||||
help_text=_(u'used in title tag and social sharing'),
|
help_text=_('used in title tag and social sharing'),
|
||||||
max_length=255,
|
max_length=255,
|
||||||
blank=True, default=''),
|
blank=True, default=''),
|
||||||
post_text=HTMLField(_(u'text'), default='', blank=True),
|
post_text=HTMLField(_('text'), default='', blank=True),
|
||||||
meta={'unique_together': (('language_code', 'slug'),)}
|
meta={'unique_together': (('language_code', 'slug'),)}
|
||||||
)
|
)
|
||||||
content = PlaceholderField('post_content', related_name='post_content')
|
content = PlaceholderField('post_content', related_name='post_content')
|
||||||
|
|
@ -239,19 +241,19 @@ class BasePostPlugin(CMSPlugin):
|
||||||
|
|
||||||
class LatestPostsPlugin(BasePostPlugin):
|
class LatestPostsPlugin(BasePostPlugin):
|
||||||
|
|
||||||
latest_posts = models.IntegerField(_(u'articles'), default=get_setting('LATEST_POSTS'),
|
latest_posts = models.IntegerField(_('articles'), default=get_setting('LATEST_POSTS'),
|
||||||
help_text=_(u'The number of latests '
|
help_text=_('The number of latests '
|
||||||
u'articles to be displayed.'))
|
u'articles to be displayed.'))
|
||||||
tags = TaggableManager(_(u'filter by tag'), blank=True,
|
tags = TaggableManager(_('filter by tag'), blank=True,
|
||||||
help_text=_(u'Show only the blog articles tagged with chosen tags.'),
|
help_text=_('Show only the blog articles tagged with chosen tags.'),
|
||||||
related_name='djangocms_blog_latest_post')
|
related_name='djangocms_blog_latest_post')
|
||||||
categories = models.ManyToManyField('djangocms_blog.BlogCategory', blank=True,
|
categories = models.ManyToManyField('djangocms_blog.BlogCategory', blank=True,
|
||||||
verbose_name=_(u'filter by category'),
|
verbose_name=_('filter by category'),
|
||||||
help_text=_(u'Show only the blog articles tagged '
|
help_text=_('Show only the blog articles tagged '
|
||||||
u'with chosen categories.'))
|
u'with chosen categories.'))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return _(u'%s latest articles by tag') % self.latest_posts
|
return _('%s latest articles by tag') % self.latest_posts
|
||||||
|
|
||||||
def copy_relations(self, oldinstance):
|
def copy_relations(self, oldinstance):
|
||||||
for tag in oldinstance.tags.all():
|
for tag in oldinstance.tags.all():
|
||||||
|
|
@ -272,12 +274,12 @@ class AuthorEntriesPlugin(BasePostPlugin):
|
||||||
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=get_setting('LATEST_POSTS'),
|
_('articles'), default=get_setting('LATEST_POSTS'),
|
||||||
help_text=_(u'The number of author articles to be displayed.')
|
help_text=_('The number of author articles to be displayed.')
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return _(u'%s latest articles by author') % self.latest_posts
|
return _('%s latest articles by author') % self.latest_posts
|
||||||
|
|
||||||
def copy_relations(self, oldinstance):
|
def copy_relations(self, oldinstance):
|
||||||
self.authors = oldinstance.authors.all()
|
self.authors = oldinstance.authors.all()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
|
|
||||||
def get_setting(name):
|
def get_setting(name):
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from django.contrib.sitemaps import Sitemap
|
from django.contrib.sitemaps import Sitemap
|
||||||
|
|
||||||
from ..models import Post
|
from ..models import Post
|
||||||
|
|
||||||
|
|
||||||
class BlogSitemap(Sitemap):
|
class BlogSitemap(Sitemap):
|
||||||
changefreq = "never"
|
changefreq = 'never'
|
||||||
priority = 0.5
|
priority = 0.5
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from django.conf.urls import patterns, url
|
from django.conf.urls import patterns, url
|
||||||
|
|
||||||
from .feeds import LatestEntriesFeed, TagFeed
|
from .feeds import LatestEntriesFeed, TagFeed
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.core.urlresolvers import resolve
|
from django.core.urlresolvers import resolve
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
"""
|
"""
|
||||||
Tests for `djangocms_blog` module.
|
Tests for `djangocms_blog` module.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from cmsplugin_filer_image.models import ThumbnailOption
|
from cmsplugin_filer_image.models import ThumbnailOption
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from django.utils.translation import activate
|
from django.utils.translation import activate
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
import parler
|
import parler
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from cms.api import add_plugin
|
from cms.api import add_plugin
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from cms.toolbar.items import ModalItem
|
from cms.toolbar.items import ModalItem
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from cms.utils.conf import get_cms_setting
|
from cms.utils.conf import get_cms_setting
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import include, patterns, url
|
from django.conf.urls import include, patterns, url
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
from django.contrib.auth.models import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue