Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Tadas Dailyda 2014-12-10 11:26:19 +00:00
commit 31939af387
31 changed files with 634 additions and 499 deletions

View file

@ -30,8 +30,6 @@ matrix:
env: DJANGO='django>=1.7,<1.8' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1
allow_failures:
- python: 2.7
env: DJANGO='django>=1.7,<1.8' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1
- python: 3.3
env: DJANGO='django>=1.5,<1.6' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1
- python: 3.3
@ -43,4 +41,4 @@ matrix:
- python: 3.4
env: DJANGO='django>=1.6,<1.7' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1
- python: 3.4
env: DJANGO='django>=1.7,<1.8' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1
env: DJANGO='django>=1.7,<1.8' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1

View file

@ -10,7 +10,14 @@ History
* Configurable default author support
* Refactored settings
* Fix multilanguage issues
* Fix SEO fields length.
* Fix SEO fields length
* Post absolute url is generated from the title in any language if current is
not available
* If djangocms-page-meta and djangocms-page-tags are installed, the relevant
toolbar items are removed from the toolbar in the post detail view to avoid
confusings page meta / tags with post ones
* Plugin API changed to filter out posts according to the request.
* Django 1.7 support
0.2.0 (2014-09-24)
++++++++++++++++++

View file

@ -30,6 +30,7 @@ Supported Django versions:
* Django 1.5
* Django 1.6
* Django 1.7
Supported django CMS versions:
@ -40,6 +41,18 @@ Supported django CMS versions:
defaults for search engines. Existing data will not be affected,
but widgets that enforce the length for new data is now being used.
.. warning:: Starting from 0.3 BlogLatestEntriesPlugin and BlogAuthorPostsPlugin
the plugin API has changed: ``BlogLatestEntriesPlugin.get_posts``,
``BlogAuthorPostsPlugin.get_authors`` requires the ``request``
argument. Templates has been changed to use a context variable
instead. Please update your plugin templates accordingly.
.. warning:: To ease migration to version 0.3, djangocms-blog depends on south
even on Django 1.7; while this is unnecessary for Dajngo 1.7, it
makes transition to version 0.3 painless. Hard dependency will be
removed in 0.5.
Quickstart
----------

View file

@ -73,6 +73,11 @@ HELPER_SETTINGS = {
'MIDDLEWARE_CLASSES': [
'django.contrib.messages.middleware.MessageMiddleware',
],
'MIGRATION_MODULES': {
'filer': 'filer.migrations_django',
'cmsplugin_filer_image': 'cmsplugin_filer_image.migrations_django',
'djangocms_text_ckeditor': 'djangocms_text_ckeditor.migrations_django',
},
'META_SITE_PROTOCOL': 'http',
'META_SITE_DOMAIN': 'example.com',
'META_USE_OG_PROPERTIES': True,
@ -88,4 +93,4 @@ HELPER_SETTINGS = {
'SITE_ID': 1
}
if 'test' in sys.argv:
HELPER_SETTINGS['INSTALLED_APPS'].append('django_nose')
HELPER_SETTINGS['INSTALLED_APPS'].append('django_nose')

View file

@ -2,4 +2,4 @@
# -*- coding: utf-8 -*-
__author__ = 'Iacopo Spalletti'
__email__ = 'i.spalletti@nephila.it'
__version__ = '0.3.0.b1'
__version__ = '0.3.0.b3'

View file

@ -24,6 +24,7 @@ class BlogLatestEntriesPlugin(BlogPlugin):
def render(self, context, instance, placeholder):
context['instance'] = instance
context['posts_list'] = instance.get_posts(context['request'])
context['TRUNCWORDS_COUNT'] = get_setting('POSTS_LIST_TRUNCWORDS_COUNT')
return context
@ -38,6 +39,7 @@ class BlogAuthorPostsPlugin(BlogPlugin):
def render(self, context, instance, placeholder):
context['instance'] = instance
context['authors_list'] = instance.get_authors()
return context

View file

@ -26,3 +26,23 @@ class BlogToolbar(CMSToolbar):
admin_menu.add_modal_item(_('Edit Post'), reverse(
'admin:djangocms_blog_post_change', args=(current_post.pk,)),
active=True)
def post_template_populate(self):
current_post = getattr(self.request, BLOG_CURRENT_POST_IDENTIFIER, None)
if current_post and self.request.user.has_perm('djangocms_blog.change_post'): # pragma: no cover
# removing page meta menu, if present, to avoid confusion
try: # pragma: no cover
import djangocms_page_meta
menu = self.request.toolbar.get_or_create_menu('page')
pagemeta = menu.get_or_create_menu('pagemeta', 'meta')
menu.remove_item(pagemeta)
except ImportError:
pass
# removing page tags menu, if present, to avoid confusion
try: # pragma: no cover
import djangocms_page_tags
menu = self.request.toolbar.get_or_create_menu('page')
pagetags = menu.get_or_create_menu('pagetags', 'tags')
menu.remove_item(pagetags)
except ImportError:
pass

View file

@ -32,4 +32,4 @@ class PostAdminForm(TranslatableModelForm):
class Meta:
model = Post
exclude = ()
exclude = ()

View file

@ -1,342 +1,136 @@
# -*- coding: utf-8 -*-
from django.contrib.auth import get_user_model
from django.utils import timezone
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
from __future__ import unicode_literals
from django.db import models, migrations
import taggit_autosuggest.managers
import filer.fields.image
import meta_mixin.models
import djangocms_text_ckeditor.fields
import cms.models.fields
import django.utils.timezone
from django.conf import settings
from django.conf import settings
User = get_user_model()
user_orm_label = '%s.%s' % (User._meta.app_label, User._meta.object_name)
user_model_label = '%s.%s' % (User._meta.app_label, User._meta.module_name)
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('cms', '0003_auto_20140926_2347'),
('taggit', '__first__'),
('filer', '0001_initial'),
('cmsplugin_filer_image', '0001_initial'),
]
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'BlogCategoryTranslation'
db.create_table(u'djangocms_blog_blogcategory_translation', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('language_code', self.gf('django.db.models.fields.CharField')(max_length=15, db_index=True)),
('name', self.gf('django.db.models.fields.CharField')(max_length=200)),
('slug', self.gf('django.db.models.fields.SlugField')(max_length=50, blank=True, db_index=True)),
('master', self.gf('django.db.models.fields.related.ForeignKey')(related_name='translations', null=True, to=orm['djangocms_blog.BlogCategory'])),
))
db.send_create_signal(u'djangocms_blog', ['BlogCategoryTranslation'])
# Adding unique constraint on 'BlogCategoryTranslation', fields ['language_code', 'slug']
db.create_unique(u'djangocms_blog_blogcategory_translation', ['language_code', 'slug'])
# Adding unique constraint on 'BlogCategoryTranslation', fields ['language_code', 'master']
db.create_unique(u'djangocms_blog_blogcategory_translation', ['language_code', 'master_id'])
# Adding model 'BlogCategory'
db.create_table(u'djangocms_blog_blogcategory', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('parent', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['djangocms_blog.BlogCategory'], null=True, blank=True)),
('date_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
('date_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
))
db.send_create_signal(u'djangocms_blog', ['BlogCategory'])
# Adding model 'PostTranslation'
db.create_table(u'djangocms_blog_post_translation', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('language_code', self.gf('django.db.models.fields.CharField')(max_length=15, db_index=True)),
('title', self.gf('django.db.models.fields.CharField')(max_length=255)),
('slug', self.gf('django.db.models.fields.SlugField')(db_index=True, max_length=50, blank=True)),
('abstract', self.gf('djangocms_text_ckeditor.fields.HTMLField')()),
('master', self.gf('django.db.models.fields.related.ForeignKey')(related_name='translations', null=True, to=orm['djangocms_blog.Post'])),
))
db.send_create_signal(u'djangocms_blog', ['PostTranslation'])
# Adding unique constraint on 'PostTranslation', fields ['language_code', 'slug']
db.create_unique(u'djangocms_blog_post_translation', ['language_code', 'slug'])
# Adding unique constraint on 'PostTranslation', fields ['language_code', 'master']
db.create_unique(u'djangocms_blog_post_translation', ['language_code', 'master_id'])
# Adding model 'Post'
db.create_table(u'djangocms_blog_post', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('author', self.gf('django.db.models.fields.related.ForeignKey')(to=orm[user_orm_label])),
('date_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
('date_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
('date_published', self.gf('django.db.models.fields.DateTimeField')(default=timezone.now)),
('date_published_end', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
('publish', self.gf('django.db.models.fields.BooleanField')(default=False)),
('main_image', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['filer.Image'], null=True, blank=True)),
('main_image_thumbnail', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='blog_post_thumbnail', null=True, to=orm['cmsplugin_filer_image.ThumbnailOption'])),
('main_image_full', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='blog_post_full', null=True, to=orm['cmsplugin_filer_image.ThumbnailOption'])),
('content', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cms.Placeholder'], null=True)),
))
db.send_create_signal(u'djangocms_blog', ['Post'])
# Adding M2M table for field categories on 'Post'
m2m_table_name = db.shorten_name(u'djangocms_blog_post_categories')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('post', models.ForeignKey(orm[u'djangocms_blog.post'], null=False)),
('blogcategory', models.ForeignKey(orm[u'djangocms_blog.blogcategory'], null=False))
))
db.create_unique(m2m_table_name, ['post_id', 'blogcategory_id'])
# Adding model 'LatestPostsPlugin'
db.create_table(u'cmsplugin_latestpostsplugin', (
(u'cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
('latest_posts', self.gf('django.db.models.fields.IntegerField')(default=5)),
))
db.send_create_signal(u'djangocms_blog', ['LatestPostsPlugin'])
# Adding M2M table for field tags on 'LatestPostsPlugin'
m2m_table_name = db.shorten_name(u'djangocms_blog_latestpostsplugin_tags')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('latestpostsplugin', models.ForeignKey(orm[u'djangocms_blog.latestpostsplugin'], null=False)),
('tag', models.ForeignKey(orm[u'taggit.tag'], null=False))
))
db.create_unique(m2m_table_name, ['latestpostsplugin_id', 'tag_id'])
# Adding M2M table for field categories on 'LatestPostsPlugin'
m2m_table_name = db.shorten_name(u'djangocms_blog_latestpostsplugin_categories')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('latestpostsplugin', models.ForeignKey(orm[u'djangocms_blog.latestpostsplugin'], null=False)),
('blogcategory', models.ForeignKey(orm[u'djangocms_blog.blogcategory'], null=False))
))
db.create_unique(m2m_table_name, ['latestpostsplugin_id', 'blogcategory_id'])
# Adding model 'AuthorEntriesPlugin'
db.create_table(u'cmsplugin_authorentriesplugin', (
(u'cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
('latest_posts', self.gf('django.db.models.fields.IntegerField')(default=5)),
))
db.send_create_signal(u'djangocms_blog', ['AuthorEntriesPlugin'])
# Adding M2M table for field authors on 'AuthorEntriesPlugin'
m2m_table_name = db.shorten_name(u'djangocms_blog_authorentriesplugin_authors')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('authorentriesplugin', models.ForeignKey(orm[u'djangocms_blog.authorentriesplugin'], null=False)),
('user', models.ForeignKey(orm[user_orm_label], null=False))
))
db.create_unique(m2m_table_name, ['authorentriesplugin_id', 'user_id'])
def backwards(self, orm):
# Removing unique constraint on 'PostTranslation', fields ['language_code', 'master']
db.delete_unique(u'djangocms_blog_post_translation', ['language_code', 'master_id'])
# Removing unique constraint on 'PostTranslation', fields ['language_code', 'slug']
db.delete_unique(u'djangocms_blog_post_translation', ['language_code', 'slug'])
# Removing unique constraint on 'BlogCategoryTranslation', fields ['language_code', 'master']
db.delete_unique(u'djangocms_blog_blogcategory_translation', ['language_code', 'master_id'])
# Removing unique constraint on 'BlogCategoryTranslation', fields ['language_code', 'slug']
db.delete_unique(u'djangocms_blog_blogcategory_translation', ['language_code', 'slug'])
# Deleting model 'BlogCategoryTranslation'
db.delete_table(u'djangocms_blog_blogcategory_translation')
# Deleting model 'BlogCategory'
db.delete_table(u'djangocms_blog_blogcategory')
# Deleting model 'PostTranslation'
db.delete_table(u'djangocms_blog_post_translation')
# Deleting model 'Post'
db.delete_table(u'djangocms_blog_post')
# Removing M2M table for field categories on 'Post'
db.delete_table(db.shorten_name(u'djangocms_blog_post_categories'))
# Deleting model 'LatestPostsPlugin'
db.delete_table(u'cmsplugin_latestpostsplugin')
# Removing M2M table for field tags on 'LatestPostsPlugin'
db.delete_table(db.shorten_name(u'djangocms_blog_latestpostsplugin_tags'))
# Removing M2M table for field categories on 'LatestPostsPlugin'
db.delete_table(db.shorten_name(u'djangocms_blog_latestpostsplugin_categories'))
# Deleting model 'AuthorEntriesPlugin'
db.delete_table(u'cmsplugin_authorentriesplugin')
# Removing M2M table for field authors on 'AuthorEntriesPlugin'
db.delete_table(db.shorten_name(u'djangocms_blog_authorentriesplugin_authors'))
models = {
u'auth.group': {
'Meta': {'object_name': 'Group'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
u'auth.permission': {
'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
user_model_label: {
'Meta': {'object_name': User.__name__, 'db_table': "'%s'" % User._meta.db_table},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'cms.cmsplugin': {
'Meta': {'object_name': 'CMSPlugin'},
'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}),
'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
},
'cms.placeholder': {
'Meta': {'object_name': 'Placeholder'},
'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
},
u'cmsplugin_filer_image.thumbnailoption': {
'Meta': {'ordering': "('width', 'height')", 'object_name': 'ThumbnailOption'},
'crop': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'height': ('django.db.models.fields.IntegerField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'upscale': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'width': ('django.db.models.fields.IntegerField', [], {})
},
u'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
u'djangocms_blog.authorentriesplugin': {
'Meta': {'object_name': 'AuthorEntriesPlugin', 'db_table': "u'cmsplugin_authorentriesplugin'", '_ormbases': ['cms.CMSPlugin']},
'authors': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['%s']" % user_orm_label, 'symmetrical': 'False'}),
u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
'latest_posts': ('django.db.models.fields.IntegerField', [], {'default': '5'})
},
u'djangocms_blog.blogcategory': {
'Meta': {'object_name': 'BlogCategory'},
'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'date_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['djangocms_blog.BlogCategory']", 'null': 'True', 'blank': 'True'})
},
u'djangocms_blog.blogcategorytranslation': {
'Meta': {'unique_together': "[('language_code', 'slug'), ('language_code', 'master')]", 'object_name': 'BlogCategoryTranslation', 'db_table': "u'djangocms_blog_blogcategory_translation'"},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['djangocms_blog.BlogCategory']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'})
},
u'djangocms_blog.latestpostsplugin': {
'Meta': {'object_name': 'LatestPostsPlugin', 'db_table': "u'cmsplugin_latestpostsplugin'", '_ormbases': ['cms.CMSPlugin']},
'categories': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['djangocms_blog.BlogCategory']", 'symmetrical': 'False', 'blank': 'True'}),
u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
'latest_posts': ('django.db.models.fields.IntegerField', [], {'default': '5'}),
'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['taggit.Tag']", 'symmetrical': 'False', 'blank': 'True'})
},
u'djangocms_blog.post': {
'Meta': {'ordering': "('-date_published', '-date_created')", 'object_name': 'Post'},
'author': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s']" % user_orm_label}),
'categories': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'blog_posts'", 'symmetrical': 'False', 'to': u"orm['djangocms_blog.BlogCategory']"}),
'content': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'date_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'date_published': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'date_published_end': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'main_image': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['filer.Image']", 'null': 'True', 'blank': 'True'}),
'main_image_full': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'blog_post_full'", 'null': 'True', 'to': u"orm['cmsplugin_filer_image.ThumbnailOption']"}),
'main_image_thumbnail': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'blog_post_thumbnail'", 'null': 'True', 'to': u"orm['cmsplugin_filer_image.ThumbnailOption']"}),
'publish': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
},
u'djangocms_blog.posttranslation': {
'Meta': {'unique_together': "[('language_code', 'slug'), ('language_code', 'master')]", 'object_name': 'PostTranslation', 'db_table': "u'djangocms_blog_post_translation'"},
'abstract': ('djangocms_text_ckeditor.fields.HTMLField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['djangocms_blog.Post']"}),
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'blank': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
},
'filer.file': {
'Meta': {'object_name': 'File'},
'_file_size': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'folder': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'all_files'", 'null': 'True', 'to': "orm['filer.Folder']"}),
'has_all_mandatory_data': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'modified_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
'original_filename': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'owned_files'", 'null': 'True', 'to': u"orm['%s']" % user_orm_label}),
'polymorphic_ctype': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'polymorphic_filer.file_set'", 'null': 'True', 'to': u"orm['contenttypes.ContentType']"}),
'sha1': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '40', 'blank': 'True'}),
'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'})
},
'filer.folder': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('parent', 'name'),)", 'object_name': 'Folder'},
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
u'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
u'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'modified_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'filer_owned_folders'", 'null': 'True', 'to': u"orm['%s']" % user_orm_label}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['filer.Folder']"}),
u'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
u'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'})
},
'filer.image': {
'Meta': {'object_name': 'Image', '_ormbases': ['filer.File']},
'_height': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'_width': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'author': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'date_taken': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'default_alt_text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'default_caption': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
u'file_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['filer.File']", 'unique': 'True', 'primary_key': 'True'}),
'must_always_publish_author_credit': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'must_always_publish_copyright': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'related_url': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
'subject_location': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '64', 'null': 'True', 'blank': 'True'})
},
u'taggit.tag': {
'Meta': {'object_name': 'Tag'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100'})
}
}
complete_apps = ['djangocms_blog']
operations = [
migrations.CreateModel(
name='AuthorEntriesPlugin',
fields=[
('cmsplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
('latest_posts', models.IntegerField(default=5, help_text='The number of author articles to be displayed.', verbose_name='Articles')),
('authors', models.ManyToManyField(to=settings.AUTH_USER_MODEL, verbose_name='Authors')),
],
options={
'abstract': False,
},
bases=('cms.cmsplugin',),
),
migrations.CreateModel(
name='BlogCategory',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('date_created', models.DateTimeField(auto_now_add=True, verbose_name='created at')),
('date_modified', models.DateTimeField(auto_now=True, verbose_name='modified at')),
('parent', models.ForeignKey(verbose_name='parent', blank=True, to='djangocms_blog.BlogCategory', null=True)),
],
options={
'verbose_name': 'blog category',
'verbose_name_plural': 'blog categories',
},
bases=(models.Model,),
),
migrations.CreateModel(
name='BlogCategoryTranslation',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('language_code', models.CharField(db_index=True, max_length=15, verbose_name='Language', choices=settings.LANGUAGES)),
('name', models.CharField(max_length=255, verbose_name='name')),
('slug', models.SlugField(verbose_name='slug', blank=True)),
('master', models.ForeignKey(related_name='translations', editable=False, to='djangocms_blog.BlogCategory', null=True)),
],
options={
'db_table': 'djangocms_blog_blogcategory_translation',
'verbose_name': 'blog category Translation',
'default_permissions': (),
},
bases=(models.Model,),
),
migrations.CreateModel(
name='LatestPostsPlugin',
fields=[
('cmsplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
('latest_posts', models.IntegerField(default=5, help_text='The number of latests articles to be displayed.', verbose_name='Articles')),
('categories', models.ManyToManyField(help_text='Show only the blog articles tagged with chosen categories.', to='djangocms_blog.BlogCategory', blank=True)),
('tags', models.ManyToManyField(help_text='Show only the blog articles tagged with chosen tags.', to='taggit.Tag', blank=True)),
],
options={
'abstract': False,
},
bases=('cms.cmsplugin',),
),
migrations.CreateModel(
name='Post',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('date_created', models.DateTimeField(auto_now_add=True)),
('date_modified', models.DateTimeField(auto_now=True)),
('date_published', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Published Since')),
('date_published_end', models.DateTimeField(null=True, verbose_name='Published Until', blank=True)),
('publish', models.BooleanField(default=False, verbose_name='Publish')),
('enable_comments', models.BooleanField(default=True, verbose_name='Enable comments on post')),
('author', models.ForeignKey(related_name='djangocms_blog_post_author', verbose_name='Author', blank=True, to=settings.AUTH_USER_MODEL, null=True)),
('categories', models.ManyToManyField(related_name='blog_posts', verbose_name='category', to='djangocms_blog.BlogCategory')),
('content', cms.models.fields.PlaceholderField(slotname=b'post_content', editable=False, to='cms.Placeholder', null=True)),
('main_image', filer.fields.image.FilerImageField(related_name='djangocms_blog_post_image', verbose_name='Main image', blank=True, to='filer.Image', null=True)),
('main_image_full', models.ForeignKey(related_name='djangocms_blog_post_full', verbose_name='Main image full', blank=True, to='cmsplugin_filer_image.ThumbnailOption', null=True)),
('main_image_thumbnail', models.ForeignKey(related_name='djangocms_blog_post_thumbnail', verbose_name='Main image thumbnail', blank=True, to='cmsplugin_filer_image.ThumbnailOption', null=True)),
('tags', taggit_autosuggest.managers.TaggableManager(to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags')),
],
options={
'ordering': ('-date_published', '-date_created'),
'get_latest_by': 'date_published',
'verbose_name': 'blog article',
'verbose_name_plural': 'blog articles',
},
bases=(meta_mixin.models.ModelMeta, models.Model),
),
migrations.CreateModel(
name='PostTranslation',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('language_code', models.CharField(db_index=True, max_length=15, verbose_name='Language', choices=settings.LANGUAGES)),
('title', models.CharField(max_length=255, verbose_name='Title')),
('slug', models.SlugField(verbose_name='slug', blank=True)),
('abstract', djangocms_text_ckeditor.fields.HTMLField(verbose_name='Abstract')),
('meta_description', models.TextField(default=b'', verbose_name='Post meta description', blank=True)),
('meta_keywords', models.TextField(default=b'', verbose_name='Post meta keywords', blank=True)),
('meta_title', models.CharField(default=b'', help_text='used in title tag and social sharing', max_length=255, verbose_name='Post meta title', blank=True)),
('post_text', djangocms_text_ckeditor.fields.HTMLField(default=b'', verbose_name='Text', blank=True)),
('master', models.ForeignKey(related_name='translations', editable=False, to='djangocms_blog.Post', null=True)),
],
options={
'db_table': 'djangocms_blog_post_translation',
'verbose_name': 'blog article Translation',
'default_permissions': (),
},
bases=(models.Model,),
),
migrations.AlterUniqueTogether(
name='posttranslation',
unique_together=set([('language_code', 'master'), ('language_code', 'slug')]),
),
migrations.AlterUniqueTogether(
name='blogcategorytranslation',
unique_together=set([('language_code', 'master'), ('language_code', 'slug')]),
),
]

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('djangocms_blog', '0002_post_sites'),
]
operations = [
migrations.AlterField(
model_name='post',
name='sites',
field=models.ManyToManyField(help_text='Select sites in which to show the post. If none is set it will be visible in all the configured sites.', to='sites.Site', null=True, verbose_name='Site(s)', blank=True),
preserve_default=True,
),
]

View file

@ -1,135 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import taggit_autosuggest.managers
import filer.fields.image
import meta_mixin.models
import djangocms_text_ckeditor.fields
import cms.models.fields
import django.utils.timezone
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('cms', '0003_auto_20140926_2347'),
('taggit', '__first__'),
('filer', '0001_initial'),
('cmsplugin_filer_image', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='AuthorEntriesPlugin',
fields=[
('cmsplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
('latest_posts', models.IntegerField(default=5, help_text='The number of author articles to be displayed.', verbose_name='Articles')),
('authors', models.ManyToManyField(to=settings.AUTH_USER_MODEL, verbose_name='Authors')),
],
options={
'abstract': False,
},
bases=('cms.cmsplugin',),
),
migrations.CreateModel(
name='BlogCategory',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('date_created', models.DateTimeField(auto_now_add=True, verbose_name='created at')),
('date_modified', models.DateTimeField(auto_now=True, verbose_name='modified at')),
('parent', models.ForeignKey(verbose_name='parent', blank=True, to='djangocms_blog.BlogCategory', null=True)),
],
options={
'verbose_name': 'blog category',
'verbose_name_plural': 'blog categories',
},
bases=(models.Model,),
),
migrations.CreateModel(
name='BlogCategoryTranslation',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('language_code', models.CharField(db_index=True, max_length=15, verbose_name='Language', choices=[(b'lt', b'Lithuanian'), (b'en', b'English')])),
('name', models.CharField(max_length=255, verbose_name='name')),
('slug', models.SlugField(verbose_name='slug', blank=True)),
('master', models.ForeignKey(related_name='translations', editable=False, to='djangocms_blog.BlogCategory', null=True)),
],
options={
'db_table': 'djangocms_blog_blogcategory_translation',
'verbose_name': 'blog category Translation',
'default_permissions': (),
},
bases=(models.Model,),
),
migrations.CreateModel(
name='LatestPostsPlugin',
fields=[
('cmsplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
('latest_posts', models.IntegerField(default=5, help_text='The number of latests articles to be displayed.', verbose_name='Articles')),
('categories', models.ManyToManyField(help_text='Show only the blog articles tagged with chosen categories.', to='djangocms_blog.BlogCategory', blank=True)),
('tags', models.ManyToManyField(help_text='Show only the blog articles tagged with chosen tags.', to='taggit.Tag', blank=True)),
],
options={
'abstract': False,
},
bases=('cms.cmsplugin',),
),
migrations.CreateModel(
name='Post',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('date_created', models.DateTimeField(auto_now_add=True)),
('date_modified', models.DateTimeField(auto_now=True)),
('date_published', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Published Since')),
('date_published_end', models.DateTimeField(null=True, verbose_name='Published Until', blank=True)),
('publish', models.BooleanField(default=False, verbose_name='Publish')),
('enable_comments', models.BooleanField(default=True, verbose_name='Enable comments on post')),
('author', models.ForeignKey(related_name='djangocms_blog_post_author', verbose_name='Author', blank=True, to=settings.AUTH_USER_MODEL, null=True)),
('categories', models.ManyToManyField(related_name='blog_posts', verbose_name='category', to='djangocms_blog.BlogCategory')),
('content', cms.models.fields.PlaceholderField(slotname=b'post_content', editable=False, to='cms.Placeholder', null=True)),
('main_image', filer.fields.image.FilerImageField(related_name='djangocms_blog_post_image', verbose_name='Main image', blank=True, to='filer.Image', null=True)),
('main_image_full', models.ForeignKey(related_name='djangocms_blog_post_full', verbose_name='Main image full', blank=True, to='cmsplugin_filer_image.ThumbnailOption', null=True)),
('main_image_thumbnail', models.ForeignKey(related_name='djangocms_blog_post_thumbnail', verbose_name='Main image thumbnail', blank=True, to='cmsplugin_filer_image.ThumbnailOption', null=True)),
('tags', taggit_autosuggest.managers.TaggableManager(to='taggit.Tag', through='taggit.TaggedItem', blank=True, help_text='A comma-separated list of tags.', verbose_name='Tags')),
],
options={
'ordering': ('-date_published', '-date_created'),
'get_latest_by': 'date_published',
'verbose_name': 'blog article',
'verbose_name_plural': 'blog articles',
},
bases=(meta_mixin.models.ModelMeta, models.Model),
),
migrations.CreateModel(
name='PostTranslation',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('language_code', models.CharField(db_index=True, max_length=15, verbose_name='Language', choices=[(b'lt', b'Lithuanian'), (b'en', b'English')])),
('title', models.CharField(max_length=255, verbose_name='Title')),
('slug', models.SlugField(verbose_name='slug', blank=True)),
('abstract', djangocms_text_ckeditor.fields.HTMLField(verbose_name='Abstract')),
('meta_description', models.TextField(default=b'', verbose_name='Post meta description', blank=True)),
('meta_keywords', models.TextField(default=b'', verbose_name='Post meta keywords', blank=True)),
('meta_title', models.CharField(default=b'', help_text='used in title tag and social sharing', max_length=255, verbose_name='Post meta title', blank=True)),
('post_text', djangocms_text_ckeditor.fields.HTMLField(default=b'', verbose_name='Text', blank=True)),
('master', models.ForeignKey(related_name='translations', editable=False, to='djangocms_blog.Post', null=True)),
],
options={
'db_table': 'djangocms_blog_post_translation',
'verbose_name': 'blog article Translation',
'default_permissions': (),
},
bases=(models.Model,),
),
migrations.AlterUniqueTogether(
name='posttranslation',
unique_together=set([('language_code', 'master'), ('language_code', 'slug')]),
),
migrations.AlterUniqueTogether(
name='blogcategorytranslation',
unique_together=set([('language_code', 'master'), ('language_code', 'slug')]),
),
]

View file

@ -197,7 +197,9 @@ class Post(ModelMeta, TranslatableModel):
kwargs = {'year': self.date_published.year,
'month': '%02d' % self.date_published.month,
'day': '%02d' % self.date_published.day,
'slug': self.safe_translation_getter('slug', language_code=get_language())}
'slug': self.safe_translation_getter('slug',
language_code=get_language(),
any_language=True)}
return reverse('djangocms_blog:post-detail', kwargs=kwargs)
def thumbnail_options(self):
@ -217,7 +219,23 @@ class Post(ModelMeta, TranslatableModel):
@python_2_unicode_compatible
class LatestPostsPlugin(CMSPlugin):
class BasePostPlugin(CMSPlugin):
class Meta:
abstract = True
def post_queryset(self, request):
language = get_language()
posts = Post._default_manager.active_translations(language_code=language)
if not request.toolbar or not request.toolbar.edit_mode:
posts = posts.published()
return posts
def __str__(self):
return unicode(self.latest_posts)
class LatestPostsPlugin(BasePostPlugin):
latest_posts = models.IntegerField(_(u'Articles'), default=get_setting('LATEST_POSTS'),
help_text=_('The number of latests articles to be displayed.'))
@ -232,16 +250,15 @@ class LatestPostsPlugin(CMSPlugin):
def copy_relations(self, oldinstance):
self.tags = oldinstance.tags.all()
def get_posts(self):
posts = Post.objects.published()
def get_posts(self, request):
posts = self.post_queryset(request)
tags = list(self.tags.all())
if tags:
posts = posts.filter(tags__in=tags)
return posts[:self.latest_posts]
@python_2_unicode_compatible
class AuthorEntriesPlugin(CMSPlugin):
class AuthorEntriesPlugin(BasePostPlugin):
authors = models.ManyToManyField(
dj_settings.AUTH_USER_MODEL, verbose_name=_('Authors'),
limit_choices_to={'djangocms_blog_post_author__publish': True}
@ -257,8 +274,8 @@ class AuthorEntriesPlugin(CMSPlugin):
def copy_relations(self, oldinstance):
self.authors = oldinstance.authors.all()
def get_posts(self):
posts = (Post.objects.published().filter(author__in=self.authors.all()))
def get_posts(self, request):
posts = self.post_queryset(request)
return posts[:self.latest_posts]
def get_authors(self):

View file

@ -0,0 +1,342 @@
# -*- coding: utf-8 -*-
from django.contrib.auth import get_user_model
from django.utils import timezone
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
User = get_user_model()
user_orm_label = '%s.%s' % (User._meta.app_label, User._meta.object_name)
user_model_label = '%s.%s' % (User._meta.app_label, User._meta.module_name)
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'BlogCategoryTranslation'
db.create_table(u'djangocms_blog_blogcategory_translation', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('language_code', self.gf('django.db.models.fields.CharField')(max_length=15, db_index=True)),
('name', self.gf('django.db.models.fields.CharField')(max_length=200)),
('slug', self.gf('django.db.models.fields.SlugField')(max_length=50, blank=True, db_index=True)),
('master', self.gf('django.db.models.fields.related.ForeignKey')(related_name='translations', null=True, to=orm['djangocms_blog.BlogCategory'])),
))
db.send_create_signal(u'djangocms_blog', ['BlogCategoryTranslation'])
# Adding unique constraint on 'BlogCategoryTranslation', fields ['language_code', 'slug']
db.create_unique(u'djangocms_blog_blogcategory_translation', ['language_code', 'slug'])
# Adding unique constraint on 'BlogCategoryTranslation', fields ['language_code', 'master']
db.create_unique(u'djangocms_blog_blogcategory_translation', ['language_code', 'master_id'])
# Adding model 'BlogCategory'
db.create_table(u'djangocms_blog_blogcategory', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('parent', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['djangocms_blog.BlogCategory'], null=True, blank=True)),
('date_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
('date_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
))
db.send_create_signal(u'djangocms_blog', ['BlogCategory'])
# Adding model 'PostTranslation'
db.create_table(u'djangocms_blog_post_translation', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('language_code', self.gf('django.db.models.fields.CharField')(max_length=15, db_index=True)),
('title', self.gf('django.db.models.fields.CharField')(max_length=255)),
('slug', self.gf('django.db.models.fields.SlugField')(db_index=True, max_length=50, blank=True)),
('abstract', self.gf('djangocms_text_ckeditor.fields.HTMLField')()),
('master', self.gf('django.db.models.fields.related.ForeignKey')(related_name='translations', null=True, to=orm['djangocms_blog.Post'])),
))
db.send_create_signal(u'djangocms_blog', ['PostTranslation'])
# Adding unique constraint on 'PostTranslation', fields ['language_code', 'slug']
db.create_unique(u'djangocms_blog_post_translation', ['language_code', 'slug'])
# Adding unique constraint on 'PostTranslation', fields ['language_code', 'master']
db.create_unique(u'djangocms_blog_post_translation', ['language_code', 'master_id'])
# Adding model 'Post'
db.create_table(u'djangocms_blog_post', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('author', self.gf('django.db.models.fields.related.ForeignKey')(to=orm[user_orm_label])),
('date_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
('date_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
('date_published', self.gf('django.db.models.fields.DateTimeField')(default=timezone.now)),
('date_published_end', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
('publish', self.gf('django.db.models.fields.BooleanField')(default=False)),
('main_image', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['filer.Image'], null=True, blank=True)),
('main_image_thumbnail', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='blog_post_thumbnail', null=True, to=orm['cmsplugin_filer_image.ThumbnailOption'])),
('main_image_full', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='blog_post_full', null=True, to=orm['cmsplugin_filer_image.ThumbnailOption'])),
('content', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cms.Placeholder'], null=True)),
))
db.send_create_signal(u'djangocms_blog', ['Post'])
# Adding M2M table for field categories on 'Post'
m2m_table_name = db.shorten_name(u'djangocms_blog_post_categories')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('post', models.ForeignKey(orm[u'djangocms_blog.post'], null=False)),
('blogcategory', models.ForeignKey(orm[u'djangocms_blog.blogcategory'], null=False))
))
db.create_unique(m2m_table_name, ['post_id', 'blogcategory_id'])
# Adding model 'LatestPostsPlugin'
db.create_table(u'cmsplugin_latestpostsplugin', (
(u'cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
('latest_posts', self.gf('django.db.models.fields.IntegerField')(default=5)),
))
db.send_create_signal(u'djangocms_blog', ['LatestPostsPlugin'])
# Adding M2M table for field tags on 'LatestPostsPlugin'
m2m_table_name = db.shorten_name(u'djangocms_blog_latestpostsplugin_tags')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('latestpostsplugin', models.ForeignKey(orm[u'djangocms_blog.latestpostsplugin'], null=False)),
('tag', models.ForeignKey(orm[u'taggit.tag'], null=False))
))
db.create_unique(m2m_table_name, ['latestpostsplugin_id', 'tag_id'])
# Adding M2M table for field categories on 'LatestPostsPlugin'
m2m_table_name = db.shorten_name(u'djangocms_blog_latestpostsplugin_categories')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('latestpostsplugin', models.ForeignKey(orm[u'djangocms_blog.latestpostsplugin'], null=False)),
('blogcategory', models.ForeignKey(orm[u'djangocms_blog.blogcategory'], null=False))
))
db.create_unique(m2m_table_name, ['latestpostsplugin_id', 'blogcategory_id'])
# Adding model 'AuthorEntriesPlugin'
db.create_table(u'cmsplugin_authorentriesplugin', (
(u'cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
('latest_posts', self.gf('django.db.models.fields.IntegerField')(default=5)),
))
db.send_create_signal(u'djangocms_blog', ['AuthorEntriesPlugin'])
# Adding M2M table for field authors on 'AuthorEntriesPlugin'
m2m_table_name = db.shorten_name(u'djangocms_blog_authorentriesplugin_authors')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('authorentriesplugin', models.ForeignKey(orm[u'djangocms_blog.authorentriesplugin'], null=False)),
('user', models.ForeignKey(orm[user_orm_label], null=False))
))
db.create_unique(m2m_table_name, ['authorentriesplugin_id', 'user_id'])
def backwards(self, orm):
# Removing unique constraint on 'PostTranslation', fields ['language_code', 'master']
db.delete_unique(u'djangocms_blog_post_translation', ['language_code', 'master_id'])
# Removing unique constraint on 'PostTranslation', fields ['language_code', 'slug']
db.delete_unique(u'djangocms_blog_post_translation', ['language_code', 'slug'])
# Removing unique constraint on 'BlogCategoryTranslation', fields ['language_code', 'master']
db.delete_unique(u'djangocms_blog_blogcategory_translation', ['language_code', 'master_id'])
# Removing unique constraint on 'BlogCategoryTranslation', fields ['language_code', 'slug']
db.delete_unique(u'djangocms_blog_blogcategory_translation', ['language_code', 'slug'])
# Deleting model 'BlogCategoryTranslation'
db.delete_table(u'djangocms_blog_blogcategory_translation')
# Deleting model 'BlogCategory'
db.delete_table(u'djangocms_blog_blogcategory')
# Deleting model 'PostTranslation'
db.delete_table(u'djangocms_blog_post_translation')
# Deleting model 'Post'
db.delete_table(u'djangocms_blog_post')
# Removing M2M table for field categories on 'Post'
db.delete_table(db.shorten_name(u'djangocms_blog_post_categories'))
# Deleting model 'LatestPostsPlugin'
db.delete_table(u'cmsplugin_latestpostsplugin')
# Removing M2M table for field tags on 'LatestPostsPlugin'
db.delete_table(db.shorten_name(u'djangocms_blog_latestpostsplugin_tags'))
# Removing M2M table for field categories on 'LatestPostsPlugin'
db.delete_table(db.shorten_name(u'djangocms_blog_latestpostsplugin_categories'))
# Deleting model 'AuthorEntriesPlugin'
db.delete_table(u'cmsplugin_authorentriesplugin')
# Removing M2M table for field authors on 'AuthorEntriesPlugin'
db.delete_table(db.shorten_name(u'djangocms_blog_authorentriesplugin_authors'))
models = {
u'auth.group': {
'Meta': {'object_name': 'Group'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
u'auth.permission': {
'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
user_model_label: {
'Meta': {'object_name': User.__name__, 'db_table': "'%s'" % User._meta.db_table},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'cms.cmsplugin': {
'Meta': {'object_name': 'CMSPlugin'},
'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}),
'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
},
'cms.placeholder': {
'Meta': {'object_name': 'Placeholder'},
'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
},
u'cmsplugin_filer_image.thumbnailoption': {
'Meta': {'ordering': "('width', 'height')", 'object_name': 'ThumbnailOption'},
'crop': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'height': ('django.db.models.fields.IntegerField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'upscale': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'width': ('django.db.models.fields.IntegerField', [], {})
},
u'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
u'djangocms_blog.authorentriesplugin': {
'Meta': {'object_name': 'AuthorEntriesPlugin', 'db_table': "u'cmsplugin_authorentriesplugin'", '_ormbases': ['cms.CMSPlugin']},
'authors': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['%s']" % user_orm_label, 'symmetrical': 'False'}),
u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
'latest_posts': ('django.db.models.fields.IntegerField', [], {'default': '5'})
},
u'djangocms_blog.blogcategory': {
'Meta': {'object_name': 'BlogCategory'},
'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'date_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['djangocms_blog.BlogCategory']", 'null': 'True', 'blank': 'True'})
},
u'djangocms_blog.blogcategorytranslation': {
'Meta': {'unique_together': "[('language_code', 'slug'), ('language_code', 'master')]", 'object_name': 'BlogCategoryTranslation', 'db_table': "u'djangocms_blog_blogcategory_translation'"},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['djangocms_blog.BlogCategory']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'})
},
u'djangocms_blog.latestpostsplugin': {
'Meta': {'object_name': 'LatestPostsPlugin', 'db_table': "u'cmsplugin_latestpostsplugin'", '_ormbases': ['cms.CMSPlugin']},
'categories': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['djangocms_blog.BlogCategory']", 'symmetrical': 'False', 'blank': 'True'}),
u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
'latest_posts': ('django.db.models.fields.IntegerField', [], {'default': '5'}),
'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['taggit.Tag']", 'symmetrical': 'False', 'blank': 'True'})
},
u'djangocms_blog.post': {
'Meta': {'ordering': "('-date_published', '-date_created')", 'object_name': 'Post'},
'author': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s']" % user_orm_label}),
'categories': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'blog_posts'", 'symmetrical': 'False', 'to': u"orm['djangocms_blog.BlogCategory']"}),
'content': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'date_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'date_published': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'date_published_end': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'main_image': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['filer.Image']", 'null': 'True', 'blank': 'True'}),
'main_image_full': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'blog_post_full'", 'null': 'True', 'to': u"orm['cmsplugin_filer_image.ThumbnailOption']"}),
'main_image_thumbnail': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'blog_post_thumbnail'", 'null': 'True', 'to': u"orm['cmsplugin_filer_image.ThumbnailOption']"}),
'publish': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
},
u'djangocms_blog.posttranslation': {
'Meta': {'unique_together': "[('language_code', 'slug'), ('language_code', 'master')]", 'object_name': 'PostTranslation', 'db_table': "u'djangocms_blog_post_translation'"},
'abstract': ('djangocms_text_ckeditor.fields.HTMLField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['djangocms_blog.Post']"}),
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'blank': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
},
'filer.file': {
'Meta': {'object_name': 'File'},
'_file_size': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'folder': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'all_files'", 'null': 'True', 'to': "orm['filer.Folder']"}),
'has_all_mandatory_data': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'modified_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
'original_filename': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'owned_files'", 'null': 'True', 'to': u"orm['%s']" % user_orm_label}),
'polymorphic_ctype': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'polymorphic_filer.file_set'", 'null': 'True', 'to': u"orm['contenttypes.ContentType']"}),
'sha1': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '40', 'blank': 'True'}),
'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'})
},
'filer.folder': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('parent', 'name'),)", 'object_name': 'Folder'},
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
u'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
u'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'modified_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'filer_owned_folders'", 'null': 'True', 'to': u"orm['%s']" % user_orm_label}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['filer.Folder']"}),
u'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
u'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'})
},
'filer.image': {
'Meta': {'object_name': 'Image', '_ormbases': ['filer.File']},
'_height': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'_width': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'author': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'date_taken': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'default_alt_text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'default_caption': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
u'file_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['filer.File']", 'unique': 'True', 'primary_key': 'True'}),
'must_always_publish_author_credit': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'must_always_publish_copyright': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'related_url': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
'subject_location': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '64', 'null': 'True', 'blank': 'True'})
},
u'taggit.tag': {
'Meta': {'object_name': 'Tag'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100'})
}
}
complete_apps = ['djangocms_blog']

View file

@ -2,7 +2,7 @@
<div class="plugin plugin-blog">
<h3>{% trans "Authors" %}</h3>
<ul class="blog-authors">
{% for author in instance.get_authors %}
{% for author in authors_list %}
<li><a href="{% url 'djangocms_blog:posts-author' author.get_username %}">
{{ author.get_full_name }}
<span>(

View file

@ -1,7 +1,7 @@
{% load i18n %}{% spaceless %}
<div class="plugin plugin-blog">
<div class="blog-latest-entries">
{% for post in instance.get_posts %}
{% for post in posts_list %}
{% include "djangocms_blog/includes/blog_item.html" with post=post TRUNCWORDS_COUNT=TRUNCWORDS_COUNT %}
{% empty %}
<p class="blog-empty">{% trans "No article found." %}</p>

View file

@ -17,7 +17,7 @@ class BaseBlogView(ViewUrlMixin):
def get_queryset(self):
language = get_language()
queryset = self.model._default_manager.language(language_code=language)
queryset = self.model._default_manager.active_translations(language_code=language)
if not self.request.toolbar or not self.request.toolbar.edit_mode:
queryset = queryset.published()
return queryset.on_site()

View file

@ -5,5 +5,5 @@ mock>=1.0.1
nose>=1.3.0
django-nose>=1.2
flake8
djangocms-helper>=0.4
tox>=1.8
https://github.com/nephila/djangocms-helper/archive/django_17.zip
tox>=1.8

View file

@ -36,7 +36,7 @@ setup(
],
include_package_data=True,
install_requires=[
'django-parler>=1.1',
'django-parler>=1.2',
'django-cms>=3.0',
'django-taggit',
'django-filer',
@ -49,6 +49,7 @@ setup(
'cmsplugin-filer',
'django-meta>=0.2',
'django-meta-mixin>=0.1.1',
'south>=1.0.1',
],
license="BSD",
zip_safe=False,

View file

@ -4,6 +4,7 @@ from cms.utils.copy_plugins import copy_plugins_to
from cms.utils.plugins import downcast_plugins
from copy import deepcopy
from django.contrib import admin
from django.contrib.auth.models import AnonymousUser
from django.contrib.messages.middleware import MessageMiddleware
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
@ -243,13 +244,22 @@ class ModelsTest(BaseTest):
post2 = self._get_post(self.data['en'][1])
post1.tags.add('tag 1')
post1.save()
request = self.get_page_request('/', AnonymousUser(), r'/en/blog/', edit=False)
request_auth = self.get_page_request('/', self.user_staff, r'/en/blog/', edit=False)
request_edit = self.get_page_request('/', self.user_staff, r'/en/blog/', edit=True)
plugin = add_plugin(post1.content, 'BlogLatestEntriesPlugin', language='en')
tag = Tag.objects.get(slug='tag-1')
plugin.tags.add(tag)
self.assertEqual(len(plugin.get_posts()), 0)
# unauthenticated users get no post
self.assertEqual(len(plugin.get_posts(request)), 0)
# staff users not in edit mode get no post
self.assertEqual(len(plugin.get_posts(request_auth)), 0)
# staff users in edit mode get the post
self.assertEqual(len(plugin.get_posts(request_edit)), 1)
post1.publish = True
post1.save()
self.assertEqual(len(plugin.get_posts()), 1)
self.assertEqual(len(plugin.get_posts(request)), 1)
def test_copy_plugin_latest(self):
post1 = self._get_post(self.data['en'][0])
@ -265,19 +275,20 @@ class ModelsTest(BaseTest):
def test_plugin_author(self):
post1 = self._get_post(self.data['en'][0])
post2 = self._get_post(self.data['en'][1])
request = self.get_page_request('/', AnonymousUser(), r'/en/blog/', edit=False)
plugin = add_plugin(post1.content, 'BlogAuthorPostsPlugin', language='en')
plugin.authors.add(self.user)
self.assertEqual(len(plugin.get_posts()), 0)
self.assertEqual(len(plugin.get_posts(request)), 0)
self.assertEqual(plugin.get_authors()[0].count, 0)
post1.publish = True
post1.save()
self.assertEqual(len(plugin.get_posts()), 1)
self.assertEqual(len(plugin.get_posts(request)), 1)
self.assertEqual(plugin.get_authors()[0].count, 1)
post2.publish = True
post2.save()
self.assertEqual(len(plugin.get_posts()), 2)
self.assertEqual(len(plugin.get_posts(request)), 2)
self.assertEqual(plugin.get_authors()[0].count, 2)
def test_copy_plugin_author(self):

View file

@ -3,6 +3,8 @@ from django.contrib.auth.models import AnonymousUser
from django.http import Http404
from django.utils.translation import activate
from django.utils.timezone import now
from parler.tests.utils import override_parler_settings
from parler.utils.conf import add_default_language_settings
from parler.utils.context import switch_language
from djangocms_blog.feeds import LatestEntriesFeed, TagFeed
from djangocms_blog.sitemaps import BlogSitemap
@ -58,6 +60,43 @@ class ViewTest(BaseTest):
response = view_obj.render_to_response(context)
self.assertContains(response, context['post_list'][0].get_absolute_url())
def test_post_list_view_fallback(self):
page1, page2 = self.get_pages()
post1, post2 = self.get_posts()
PARLER_FALLBACK = {
1: (
{'code': 'en'},
{'code': 'it'},
{'code': 'fr', 'hide_untranslated': True,},
),
'default': {
'fallback': 'en',
'hide_untranslated': False,
}
}
view_obj = PostListView()
request = self.get_page_request(page1, self.user, r'/fr/blog/', lang_code='fr', edit=True)
activate('fr')
view_obj.request = request
view_obj.kwargs = {}
view_obj.object_list = view_obj.get_queryset()
context = view_obj.get_context_data(object_list=view_obj.object_list)
self.assertEqual(view_obj.get_queryset().count(), 2)
PARLER_FALLBACK = add_default_language_settings(PARLER_FALLBACK)
with override_parler_settings(PARLER_LANGUAGES=PARLER_FALLBACK):
view_obj = PostListView()
request = self.get_page_request(page1, self.user, r'/fr/blog/', lang_code='fr', edit=True)
activate('fr')
view_obj.request = request
view_obj.kwargs = {}
view_obj.object_list = view_obj.get_queryset()
context = view_obj.get_context_data(object_list=view_obj.object_list)
self.assertEqual(view_obj.get_queryset().count(), 0)
def test_post_detail_view(self):
page1, page2 = self.get_pages()
post1, post2 = self.get_posts()

View file

@ -1,5 +1,5 @@
[tox]
envlist = {py26,py27}-django{15,16}
envlist = {py26,py27}-django{15,16},{py27}-django{17}
[testenv]
basepython =
@ -8,6 +8,7 @@ basepython =
deps =
django15: Django>=1.5,<1.6
django16: Django>=1.6,<1.7
django17: Django>=1.7,<1.8
py26: unittest2
-r{toxinidir}/requirements-test.txt
commands = djangocms-helper djangocms_blog test --cms --nose