Merge pull request #156 from nephila/feature/cms_wizards

Add django CMS 3.2 wizard
This commit is contained in:
Iacopo Spalletti 2015-10-25 22:35:48 +01:00
commit 9c3efffa93
13 changed files with 419 additions and 15 deletions

View file

@ -134,7 +134,7 @@ class BlogConfigAdmin(BaseAppHookConfig, TranslatableAdmin):
def declared_fieldsets(self):
return [
(None, {
'fields': ('type', 'namespace', 'app_title')
'fields': ('type', 'namespace', 'app_title', 'object_name')
}),
('Generic', {
'fields': (

View file

@ -18,6 +18,7 @@ class BlogConfig(TranslatableModel, AppHookConfig):
"""
translations = TranslatedFields(
app_title=models.CharField(_('application title'), max_length=234),
object_name=models.CharField(_('object name'), max_length=234, default='Post'),
)
def get_app_title(self):

View file

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
try:
from cms.wizards.wizard_base import Wizard
from cms.wizards.wizard_pool import wizard_pool
from django.utils.text import slugify
from django.utils.translation import ugettext_lazy as _
from parler.forms import TranslatableModelForm
from .cms_appconfig import BlogConfig
from .models import Post
class PostWizardForm(TranslatableModelForm):
default_appconfig = None
def __init__(self, *args, **kwargs):
if kwargs.get('initial', False):
kwargs['initial']['app_config'] = self.default_appconfig
if kwargs.get('data', False):
kwargs['data']['1-app_config'] = self.default_appconfig
super(PostWizardForm, self).__init__(*args, **kwargs)
self.fields['app_config'].widget.attrs['disabled'] = True
class Meta:
model = Post
fields = ['app_config', 'title', 'abstract', 'categories']
class PostWizard(Wizard):
pass
for config in BlogConfig.objects.all().order_by('namespace'):
new_wizard = type(str(slugify(config.app_title)), (PostWizard,), {})
new_form = type(str('{0}Form').format(slugify(config.app_title)), (PostWizardForm,), {
'default_appconfig': config.pk
})
post_wizard = new_wizard(
title=_('New {0}').format(config.object_name),
weight=200,
form=new_form,
model=Post,
description=_('Create a new {0} in {1}').format(config.object_name, config.app_title),
)
wizard_pool.register(post_wizard)
except ImportError:
# For django CMS version not supporting wizards just ignore this file
pass

View file

@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.utils.timezone
import aldryn_apphooks_config.fields
class Migration(migrations.Migration):
dependencies = [
('djangocms_blog', '0010_auto_20150923_1151'),
]
operations = [
migrations.AddField(
model_name='blogconfigtranslation',
name='object_name',
field=models.CharField(verbose_name='object name', default='Post', max_length=234),
),
migrations.AlterField(
model_name='authorentriesplugin',
name='app_config',
field=aldryn_apphooks_config.fields.AppHookConfigField(blank=True, help_text='When selecting a value, the form is reloaded to get the updated default', to='djangocms_blog.BlogConfig', verbose_name='app. config', null=True),
),
migrations.AlterField(
model_name='blogcategory',
name='app_config',
field=aldryn_apphooks_config.fields.AppHookConfigField(help_text='When selecting a value, the form is reloaded to get the updated default', to='djangocms_blog.BlogConfig', verbose_name='app. config', null=True),
),
migrations.AlterField(
model_name='genericblogplugin',
name='app_config',
field=aldryn_apphooks_config.fields.AppHookConfigField(blank=True, help_text='When selecting a value, the form is reloaded to get the updated default', to='djangocms_blog.BlogConfig', verbose_name='app. config', null=True),
),
migrations.AlterField(
model_name='latestpostsplugin',
name='app_config',
field=aldryn_apphooks_config.fields.AppHookConfigField(blank=True, help_text='When selecting a value, the form is reloaded to get the updated default', to='djangocms_blog.BlogConfig', verbose_name='app. config', null=True),
),
migrations.AlterField(
model_name='post',
name='app_config',
field=aldryn_apphooks_config.fields.AppHookConfigField(help_text='When selecting a value, the form is reloaded to get the updated default', to='djangocms_blog.BlogConfig', verbose_name='app. config', null=True),
),
migrations.AlterField(
model_name='post',
name='date_published',
field=models.DateTimeField(verbose_name='published since', default=django.utils.timezone.now),
),
migrations.AlterField(
model_name='post',
name='date_published_end',
field=models.DateTimeField(blank=True, verbose_name='published until', null=True),
),
]

View file

@ -17,8 +17,6 @@ class PostIndex(get_index_base()):
keywords = indexes.CharField(null=True)
tags = indexes.CharField(null=True)
post_text = indexes.CharField(null=True)
# category_ids = indexes.MultiValueField(null=True)
# category_titles = indexes.MultiValueField(null=True)
def get_keywords(self, post):
return ','.join(post.get_keywords())
@ -54,7 +52,7 @@ class PostIndex(get_index_base()):
text_bits = [post.get_title()]
text_bits.append(strip_tags(abstract))
text_bits.append(post.get_description())
# text_bits.append(' '.join(post.get_keywords()))
text_bits.append(' '.join(post.get_keywords()))
for category in post.categories.all():
text_bits.append(
force_text(category.safe_translation_getter('name')))
@ -64,7 +62,7 @@ class PostIndex(get_index_base()):
plugins = post.content.cmsplugin_set.filter(language=language)
for base_plugin in plugins:
content = get_plugin_index_data(base_plugin, request)
text_bits.append(content)
text_bits.append(' '.join(content))
for attribute in optional_attributes:
value = force_text(getattr(post, attribute))
if value and value not in text_bits:

View file

@ -0,0 +1,221 @@
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'BlogConfigTranslation.object_name'
db.add_column('djangocms_blog_blogconfig_translation', 'object_name',
self.gf('django.db.models.fields.CharField')(default='Post', max_length=234),
keep_default=False)
def backwards(self, orm):
# Deleting field 'BlogConfigTranslation.object_name'
db.delete_column('djangocms_blog_blogconfig_translation', 'object_name')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'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', [], {'symmetrical': 'False', 'to': "orm['auth.Permission']", 'blank': 'True'})
},
'auth.permission': {
'Meta': {'object_name': 'Permission', 'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)"},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'blank': 'True', 'max_length': '75'}),
'first_name': ('django.db.models.fields.CharField', [], {'blank': 'True', 'max_length': '30'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['auth.Group']", 'related_name': "'user_set'", 'blank': 'True'}),
'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', [], {'blank': 'True', 'max_length': '30'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['auth.Permission']", 'related_name': "'user_set'", 'blank': 'True'}),
'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'}),
'depth': ('django.db.models.fields.PositiveIntegerField', [], {}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
'numchild': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'null': 'True', 'to': "orm['cms.CMSPlugin']", 'blank': 'True'}),
'path': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'null': 'True', 'to': "orm['cms.Placeholder']"}),
'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'})
},
'cms.placeholder': {
'Meta': {'object_name': 'Placeholder'},
'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'slot': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'})
},
'cmsplugin_filer_image.thumbnailoption': {
'Meta': {'object_name': 'ThumbnailOption', 'ordering': "('width', 'height')"},
'crop': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'height': ('django.db.models.fields.IntegerField', [], {}),
'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', [], {})
},
'contenttypes.contenttype': {
'Meta': {'db_table': "'django_content_type'", 'object_name': 'ContentType', 'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'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'})
},
'djangocms_blog.authorentriesplugin': {
'Meta': {'object_name': 'AuthorEntriesPlugin'},
'app_config': ('aldryn_apphooks_config.fields.AppHookConfigField', [], {'null': 'True', 'to': "orm['djangocms_blog.BlogConfig']", 'blank': 'True'}),
'authors': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['auth.User']"}),
'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'primary_key': 'True', 'to': "orm['cms.CMSPlugin']", 'unique': 'True'}),
'latest_posts': ('django.db.models.fields.IntegerField', [], {'default': '5'})
},
'djangocms_blog.blogcategory': {
'Meta': {'object_name': 'BlogCategory'},
'app_config': ('aldryn_apphooks_config.fields.AppHookConfigField', [], {'null': 'True', 'to': "orm['djangocms_blog.BlogConfig']"}),
'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'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'null': 'True', 'to': "orm['djangocms_blog.BlogCategory']", 'blank': 'True'})
},
'djangocms_blog.blogcategorytranslation': {
'Meta': {'db_table': "'djangocms_blog_blogcategory_translation'", 'object_name': 'BlogCategoryTranslation', 'unique_together': "[('language_code', 'slug'), ('language_code', 'master')]"},
'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', [], {'null': 'True', 'to': "orm['djangocms_blog.BlogCategory']", 'related_name': "'translations'"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'slug': ('django.db.models.fields.SlugField', [], {'blank': 'True', 'max_length': '50'})
},
'djangocms_blog.blogconfig': {
'Meta': {'object_name': 'BlogConfig'},
'app_data': ('app_data.fields.AppDataField', [], {'default': "'{}'"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'namespace': ('django.db.models.fields.CharField', [], {'default': 'None', 'unique': 'True', 'max_length': '100'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'djangocms_blog.blogconfigtranslation': {
'Meta': {'db_table': "'djangocms_blog_blogconfig_translation'", 'object_name': 'BlogConfigTranslation', 'unique_together': "[('language_code', 'master')]"},
'app_title': ('django.db.models.fields.CharField', [], {'max_length': '234'}),
'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', [], {'null': 'True', 'to': "orm['djangocms_blog.BlogConfig']", 'related_name': "'translations'"}),
'object_name': ('django.db.models.fields.CharField', [], {'default': "'Post'", 'max_length': '234'})
},
'djangocms_blog.genericblogplugin': {
'Meta': {'object_name': 'GenericBlogPlugin'},
'app_config': ('aldryn_apphooks_config.fields.AppHookConfigField', [], {'null': 'True', 'to': "orm['djangocms_blog.BlogConfig']", 'blank': 'True'}),
'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'primary_key': 'True', 'to': "orm['cms.CMSPlugin']", 'unique': 'True'})
},
'djangocms_blog.latestpostsplugin': {
'Meta': {'object_name': 'LatestPostsPlugin'},
'app_config': ('aldryn_apphooks_config.fields.AppHookConfigField', [], {'null': 'True', 'to': "orm['djangocms_blog.BlogConfig']", 'blank': 'True'}),
'categories': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['djangocms_blog.BlogCategory']", 'blank': 'True'}),
'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'primary_key': 'True', 'to': "orm['cms.CMSPlugin']", 'unique': 'True'}),
'latest_posts': ('django.db.models.fields.IntegerField', [], {'default': '5'})
},
'djangocms_blog.post': {
'Meta': {'object_name': 'Post', 'ordering': "('-date_published', '-date_created')"},
'app_config': ('aldryn_apphooks_config.fields.AppHookConfigField', [], {'null': 'True', 'to': "orm['djangocms_blog.BlogConfig']"}),
'author': ('django.db.models.fields.related.ForeignKey', [], {'null': 'True', 'to': "orm['auth.User']", 'related_name': "'djangocms_blog_post_author'", 'blank': 'True'}),
'categories': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['djangocms_blog.BlogCategory']", 'related_name': "'blog_posts'"}),
'content': ('django.db.models.fields.related.ForeignKey', [], {'null': 'True', 'to': "orm['cms.Placeholder']", 'related_name': "'post_content'"}),
'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'}),
'enable_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'main_image': ('django.db.models.fields.related.ForeignKey', [], {'on_delete': 'models.SET_NULL', 'null': 'True', 'to': "orm['filer.Image']", 'related_name': "'djangocms_blog_post_image'", 'blank': 'True'}),
'main_image_full': ('django.db.models.fields.related.ForeignKey', [], {'on_delete': 'models.SET_NULL', 'null': 'True', 'to': "orm['cmsplugin_filer_image.ThumbnailOption']", 'related_name': "'djangocms_blog_post_full'", 'blank': 'True'}),
'main_image_thumbnail': ('django.db.models.fields.related.ForeignKey', [], {'on_delete': 'models.SET_NULL', 'null': 'True', 'to': "orm['cmsplugin_filer_image.ThumbnailOption']", 'related_name': "'djangocms_blog_post_thumbnail'", 'blank': 'True'}),
'publish': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'sites': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['sites.Site']", 'blank': 'True'})
},
'djangocms_blog.posttranslation': {
'Meta': {'db_table': "'djangocms_blog_post_translation'", 'object_name': 'PostTranslation', 'unique_together': "[('language_code', 'slug'), ('language_code', 'master')]"},
'abstract': ('djangocms_text_ckeditor.fields.HTMLField', [], {'default': "''", 'blank': 'True'}),
'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', [], {'null': 'True', 'to': "orm['djangocms_blog.Post']", 'related_name': "'translations'"}),
'meta_description': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
'meta_keywords': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
'meta_title': ('django.db.models.fields.CharField', [], {'default': "''", 'blank': 'True', 'max_length': '255'}),
'post_text': ('djangocms_text_ckeditor.fields.HTMLField', [], {'default': "''", 'blank': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'blank': 'True', 'max_length': '50'}),
'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', [], {'null': 'True', 'blank': 'True', 'max_length': '255'}),
'folder': ('django.db.models.fields.related.ForeignKey', [], {'null': 'True', 'to': "orm['filer.Folder']", 'related_name': "'all_files'", 'blank': 'True'}),
'has_all_mandatory_data': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'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': "''", 'blank': 'True', 'max_length': '255'}),
'original_filename': ('django.db.models.fields.CharField', [], {'null': 'True', 'blank': 'True', 'max_length': '255'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'null': 'True', 'to': "orm['auth.User']", 'related_name': "'owned_files'", 'blank': 'True'}),
'polymorphic_ctype': ('django.db.models.fields.related.ForeignKey', [], {'null': 'True', 'to': "orm['contenttypes.ContentType']", 'related_name': "'polymorphic_filer.file_set+'"}),
'sha1': ('django.db.models.fields.CharField', [], {'default': "''", 'blank': 'True', 'max_length': '40'}),
'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'})
},
'filer.folder': {
'Meta': {'object_name': 'Folder', 'ordering': "('name',)", 'unique_together': "(('parent', 'name'),)"},
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'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', [], {'null': 'True', 'to': "orm['auth.User']", 'related_name': "'filer_owned_folders'", 'blank': 'True'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'null': 'True', 'to': "orm['filer.Folder']", 'related_name': "'children'", 'blank': 'True'}),
'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'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'},
'_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', [], {'null': 'True', 'blank': 'True', 'max_length': '255'}),
'date_taken': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'default_alt_text': ('django.db.models.fields.CharField', [], {'null': 'True', 'blank': 'True', 'max_length': '255'}),
'default_caption': ('django.db.models.fields.CharField', [], {'null': 'True', 'blank': 'True', 'max_length': '255'}),
'file_ptr': ('django.db.models.fields.related.OneToOneField', [], {'primary_key': 'True', 'to': "orm['filer.File']", 'unique': 'True'}),
'must_always_publish_author_credit': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'must_always_publish_copyright': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'subject_location': ('django.db.models.fields.CharField', [], {'default': 'None', 'null': 'True', 'blank': 'True', 'max_length': '64'})
},
'sites.site': {
'Meta': {'db_table': "'django_site'", 'object_name': 'Site', 'ordering': "('domain',)"},
'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
}
}
complete_apps = ['djangocms_blog']

View file

@ -7,3 +7,5 @@ django-nose>=1.2
flake8
https://github.com/nephila/djangocms-helper/archive/develop.zip
tox>=2.0
wheel
pysolr

View file

@ -1,3 +1 @@
-e .
wheel
pysolr

View file

@ -38,7 +38,7 @@ setup(
include_package_data=True,
install_requires=[
'django-parler>=1.2',
'django-cms>=3.0',
'django-cms',
'django-taggit>=0.12.2',
'django-filer',
'pytz',

View file

@ -107,10 +107,10 @@ class BaseTest(BaseTestCase):
name='main', width=200, height=200, crop=False, upscale=False
)
cls.app_config_1 = BlogConfig.objects.create(
namespace='sample_app', app_title='app1'
namespace='sample_app', app_title='app1', object_name='Blog'
)
cls.app_config_2 = BlogConfig.objects.create(
namespace='sample_app2', app_title='app2'
namespace='sample_app2', app_title='app2', object_name='Article'
)
cls.app_config_1.app_data.config.paginate_by = 1
cls.app_config_1.save()

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
from cms.api import add_plugin
from haystack.constants import DEFAULT_ALIAS
from haystack.query import SearchQuerySet
@ -10,6 +11,8 @@ from .base import BaseTest
class BlogIndexingTests(BaseTest):
sample_text = ('First post First post first line This is the description keyword1 '
'keyword2 category 1 a tag test body')
def setUp(self):
self.get_pages()
@ -18,13 +21,17 @@ class BlogIndexingTests(BaseTest):
"""This tests the indexing path way used by update_index mgmt command"""
post = self._get_post(self._post_data[0]['en'])
post = self._get_post(self._post_data[0]['it'], post, 'it')
post.tags.add('a tag')
add_plugin(post.content, 'TextPlugin', language='en', body='test body')
index = self.get_post_index()
index.index_queryset(DEFAULT_ALIAS) # initialises index._backend_alias
indexed = index.prepare(post)
self.assertEqual(post.get_title(), indexed['title'])
self.assertEqual(post.get_description(), indexed['description'])
self.assertEqual('First post First post first line This is the description category 1', indexed['text'])
self.assertEqual(self.sample_text, indexed['text'])
self.assertEqual(post.get_absolute_url(), indexed['url'])
#self.assertEqual(post.date_published.strftime("%Y-%m-%d %H:%M:%S"), indexed['pub_date'])
@ -32,13 +39,16 @@ class BlogIndexingTests(BaseTest):
"""This tests the indexing path way used by the RealTimeSignalProcessor"""
post = self._get_post(self._post_data[0]['en'])
post = self._get_post(self._post_data[0]['it'], post, 'it')
post.tags.add('a tag')
add_plugin(post.content, 'TextPlugin', language='en', body='test body')
index = self.get_post_index()
index.update_object(post, using=DEFAULT_ALIAS)
indexed = index.prepared_data
self.assertEqual(post.get_title(), indexed['title'])
self.assertEqual(post.get_description(), indexed['description'])
self.assertEqual('First post First post first line This is the description category 1', indexed['text'])
self.assertEqual(self.sample_text, indexed['text'])
self.assertEqual(post.get_absolute_url(), indexed['url'])
#self.assertEqual(post.date_published.strftime("%Y-%m-%d %H:%M:%S"), indexed['pub_date'])

71
tests/test_wizards.py Normal file
View file

@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
import sys
from distutils.version import LooseVersion
import cms
from .base import BaseTest
try:
from unittest import skipIf
except ImportError:
from unittest2 import skipIf
class WizardTest(BaseTest):
def setUp(self):
try:
from cms.wizards.wizard_pool import wizard_pool
delete = [
'djangocms_blog',
'djangocms_blog.cms_wizards',
]
for module in delete:
if module in sys.modules:
del sys.modules[module]
wizard_pool._reset()
except ImportError:
# Not in django CMS 3.2+, no cleanup needed
pass
@skipIf(LooseVersion(cms.__version__) < LooseVersion('3.2'),
reason='Wizards not available for django CMS < 3.2')
def test_wizard(self):
"""
Test that Blog wizard is present and contains all items
"""
from cms.wizards.wizard_pool import wizard_pool
self.get_pages()
titles = [entry.title for entry in wizard_pool.get_entries()]
self.assertTrue('New Blog' in titles)
self.assertTrue('New Article' in titles)
@skipIf(LooseVersion(cms.__version__) < LooseVersion('3.2'),
reason='Wizards not available for django CMS < 3.2')
def test_wizard_init(self):
from cms.wizards.wizard_pool import wizard_pool
from djangocms_blog.models import Post
self.get_pages()
wizs = [entry for entry in wizard_pool.get_entries() if entry.model == Post]
for wiz in wizs:
app_config = self.app_config_1.pk if wiz.title == 'New Blog' else self.app_config_2.pk
form = wiz.form()
self.assertTrue(form.fields['app_config'].widget.attrs['disabled'])
form = wiz.form(data={
'1-title': 'title',
'1-abstract': 'abstract',
'1-categories': [self.category_1.pk],
}, prefix=1)
self.assertEqual(form.default_appconfig, app_config)
self.assertTrue(form.is_valid())
self.assertTrue(form.cleaned_data['app_config'], app_config)
def test_wizard_import(self):
# The following import should to fail in any django CMS version
from djangocms_blog import cms_wizards # NOQA

View file

@ -4,14 +4,15 @@ envlist = pep8,isort,py{35,34,33,27}-django{19,18}-cms{32,31},py{34,33,27}-djang
[testenv]
commands = {env:COMMAND:python} cms_helper.py test djangocms_blog --no-migrate
deps =
-r{toxinidir}/requirements-test.txt
django16: Django>=1.6,<1.7
django17: Django>=1.7,<1.8
django18: Django>=1.7,<1.9
django18: https://github.com/stefanfoulis/django-filer/archive/develop.zip
django18: https://github.com/nephila/cmsplugin-filer/archive/fix/static_filer.zip
django18: https://github.com/stefanfoulis/cmsplugin-filer/archive/develop.zip
django19: Django==1.9a1
django19: https://github.com/stefanfoulis/django-filer/archive/develop.zip
django19: https://github.com/nephila/cmsplugin-filer/archive/fix/static_filer.zip
django19: https://github.com/stefanfoulis/cmsplugin-filer/archive/develop.zip
cms30: https://github.com/divio/django-cms/archive/support/3.0.x.zip
cms31: https://github.com/divio/django-cms/archive/support/3.1.x.zip
cms32: https://github.com/divio/django-cms/archive/develop.zip
@ -20,7 +21,6 @@ deps =
py26: unittest2
django-parler<1.5
https://github.com/aldryn/aldryn-apphooks-config/archive/master.zip
-r{toxinidir}/requirements-test.txt
[testenv:isort]
deps = isort