Fix support for new filer ThumbnailOption
This commit is contained in:
parent
758989ad24
commit
fffc2a633e
5 changed files with 78 additions and 25 deletions
35
djangocms_blog/migrations/0017_thumbnail_move.py
Normal file
35
djangocms_blog/migrations/0017_thumbnail_move.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
from djangocms_blog.models import thumbnail_model
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
if 'cmsplugin_filer' not in thumbnail_model:
|
||||||
|
dependencies = [
|
||||||
|
('djangocms_blog', '0016_auto_20160502_1741'),
|
||||||
|
('cmsplugin_filer_image', '0006_auto_20160427_1438')
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
dependencies = [
|
||||||
|
('djangocms_blog', '0016_auto_20160502_1741'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='post',
|
||||||
|
name='main_image_full',
|
||||||
|
field=models.ForeignKey(related_name='djangocms_blog_post_full',
|
||||||
|
verbose_name='Main image full', blank=True,
|
||||||
|
to=thumbnail_model, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='post',
|
||||||
|
name='main_image_thumbnail',
|
||||||
|
field=models.ForeignKey(related_name='djangocms_blog_post_thumbnail',
|
||||||
|
verbose_name='Main image thumbnail', blank=True,
|
||||||
|
to=thumbnail_model, null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -33,11 +33,18 @@ BLOG_CURRENT_POST_IDENTIFIER = get_setting('CURRENT_POST_IDENTIFIER')
|
||||||
BLOG_CURRENT_NAMESPACE = get_setting('CURRENT_NAMESPACE')
|
BLOG_CURRENT_NAMESPACE = get_setting('CURRENT_NAMESPACE')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from filer.models import ThumbnailOption # NOQA
|
|
||||||
thumbnail_model = 'filer.ThumbnailOption'
|
|
||||||
except ImportError:
|
|
||||||
from cmsplugin_filer_image.models import ThumbnailOption # NOQA
|
from cmsplugin_filer_image.models import ThumbnailOption # NOQA
|
||||||
thumbnail_model = 'cmsplugin_filer_image.ThumbnailOption'
|
except ImportError:
|
||||||
|
from filer.models import ThumbnailOption # NOQA
|
||||||
|
try:
|
||||||
|
thumbnail_model = '%s.%s' % (
|
||||||
|
ThumbnailOption._meta.app_label, ThumbnailOption._meta.model_name
|
||||||
|
)
|
||||||
|
except AttributeError:
|
||||||
|
thumbnail_model = '%s.%s' % (
|
||||||
|
ThumbnailOption._meta.app_label, ThumbnailOption._meta.module_name
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from knocker.mixins import KnockerModel
|
from knocker.mixins import KnockerModel
|
||||||
|
|
|
@ -3,31 +3,37 @@ from south.utils import datetime_utils as datetime
|
||||||
from south.db import db
|
from south.db import db
|
||||||
from south.v2 import SchemaMigration
|
from south.v2 import SchemaMigration
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from djangocms_blog.models import thumbnail_model
|
||||||
|
|
||||||
|
|
||||||
class Migration(SchemaMigration):
|
class Migration(SchemaMigration):
|
||||||
|
|
||||||
def forwards(self, orm):
|
if 'cmsplugin_filer' not in thumbnail_model:
|
||||||
|
dependencies = [
|
||||||
|
('cmsplugin_filer_image', '0014_auto__del_thumbnailoption__chg_field_filerimage_thumbnail_option')
|
||||||
|
]
|
||||||
|
|
||||||
# Changing field 'Post.main_image_full'
|
def forwards(self, orm):
|
||||||
db.alter_column(u'djangocms_blog_post', 'main_image_full_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, on_delete=models.SET_NULL, to=orm['cmsplugin_filer_image.ThumbnailOption']))
|
|
||||||
|
|
||||||
# Changing field 'Post.date_published'
|
# Changing field 'Post.date_published'
|
||||||
db.alter_column(u'djangocms_blog_post', 'date_published', self.gf('django.db.models.fields.DateTimeField')(null=True))
|
db.alter_column(u'djangocms_blog_post', 'date_published', self.gf('django.db.models.fields.DateTimeField')(null=True))
|
||||||
|
|
||||||
|
# Changing field 'Post.main_image_full'
|
||||||
|
db.alter_column(u'djangocms_blog_post', 'main_image_full_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.SET_NULL, null=True, to=orm[thumbnail_model]))
|
||||||
|
|
||||||
# Changing field 'Post.main_image_thumbnail'
|
# Changing field 'Post.main_image_thumbnail'
|
||||||
db.alter_column(u'djangocms_blog_post', 'main_image_thumbnail_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, on_delete=models.SET_NULL, to=orm['cmsplugin_filer_image.ThumbnailOption']))
|
db.alter_column(u'djangocms_blog_post', 'main_image_thumbnail_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.SET_NULL, null=True, to=orm[thumbnail_model]))
|
||||||
|
|
||||||
def backwards(self, orm):
|
def backwards(self, orm):
|
||||||
|
|
||||||
# Changing field 'Post.main_image_full'
|
|
||||||
db.alter_column(u'djangocms_blog_post', 'main_image_full_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm[thumbnail_model], null=True, on_delete=models.SET_NULL))
|
|
||||||
|
|
||||||
# Changing field 'Post.date_published'
|
# Changing field 'Post.date_published'
|
||||||
db.alter_column(u'djangocms_blog_post', 'date_published', self.gf('django.db.models.fields.DateTimeField')())
|
db.alter_column(u'djangocms_blog_post', 'date_published', self.gf('django.db.models.fields.DateTimeField')())
|
||||||
|
|
||||||
|
# Changing field 'Post.main_image_full'
|
||||||
|
db.alter_column(u'djangocms_blog_post', 'main_image_full_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.SET_NULL, null=True, to=orm[thumbnail_model]))
|
||||||
|
|
||||||
# Changing field 'Post.main_image_thumbnail'
|
# Changing field 'Post.main_image_thumbnail'
|
||||||
db.alter_column(u'djangocms_blog_post', 'main_image_thumbnail_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm[thumbnail_model], null=True, on_delete=models.SET_NULL))
|
db.alter_column(u'djangocms_blog_post', 'main_image_thumbnail_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.SET_NULL, null=True, to=orm[thumbnail_model]))
|
||||||
|
|
||||||
models = {
|
models = {
|
||||||
u'auth.group': {
|
u'auth.group': {
|
||||||
|
|
|
@ -3,20 +3,31 @@ from south.utils import datetime_utils as datetime
|
||||||
from south.db import db
|
from south.db import db
|
||||||
from south.v2 import SchemaMigration
|
from south.v2 import SchemaMigration
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from djangocms_blog.models import thumbnail_model
|
||||||
|
|
||||||
|
|
||||||
class Migration(SchemaMigration):
|
class Migration(SchemaMigration):
|
||||||
|
|
||||||
|
if 'cmsplugin_filer' not in thumbnail_model:
|
||||||
|
dependencies = [
|
||||||
|
('djangocms_blog', '0018_auto__chg_field_post_main_image_full__chg_field_post_main_image_thumbn'),
|
||||||
|
('cmsplugin_filer_image', '0014_auto__del_thumbnailoption__chg_field_filerimage_thumbnail_option')
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
dependencies = [
|
||||||
|
('djangocms_blog', '0018_auto__chg_field_post_main_image_full__chg_field_post_main_image_thumbn'),
|
||||||
|
]
|
||||||
|
|
||||||
def forwards(self, orm):
|
def forwards(self, orm):
|
||||||
|
|
||||||
# Changing field 'Post.author'
|
# Changing field 'Post.author'
|
||||||
db.alter_column('djangocms_blog_post', 'author_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['test_utils.CustomUser']))
|
db.alter_column('djangocms_blog_post', 'author_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['test_utils.CustomUser']))
|
||||||
|
|
||||||
# Changing field 'Post.main_image_full'
|
# Changing field 'Post.main_image_full'
|
||||||
db.alter_column('djangocms_blog_post', 'main_image_full_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.SET_NULL, null=True, to=orm['filer.ThumbnailOption']))
|
db.alter_column('djangocms_blog_post', 'main_image_full_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.SET_NULL, null=True, to=orm[thumbnail_model]))
|
||||||
|
|
||||||
# Changing field 'Post.main_image_thumbnail'
|
# Changing field 'Post.main_image_thumbnail'
|
||||||
db.alter_column('djangocms_blog_post', 'main_image_thumbnail_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.SET_NULL, null=True, to=orm['filer.ThumbnailOption']))
|
db.alter_column('djangocms_blog_post', 'main_image_thumbnail_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.SET_NULL, null=True, to=orm[thumbnail_model]))
|
||||||
|
|
||||||
def backwards(self, orm):
|
def backwards(self, orm):
|
||||||
|
|
||||||
|
@ -24,10 +35,10 @@ class Migration(SchemaMigration):
|
||||||
db.alter_column('djangocms_blog_post', 'author_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['auth.User']))
|
db.alter_column('djangocms_blog_post', 'author_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['auth.User']))
|
||||||
|
|
||||||
# Changing field 'Post.main_image_full'
|
# Changing field 'Post.main_image_full'
|
||||||
db.alter_column('djangocms_blog_post', 'main_image_full_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.SET_NULL, null=True, to=orm['cmsplugin_filer_image.ThumbnailOption']))
|
db.alter_column('djangocms_blog_post', 'main_image_full_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.SET_NULL, null=True, to=orm[thumbnail_model]))
|
||||||
|
|
||||||
# Changing field 'Post.main_image_thumbnail'
|
# Changing field 'Post.main_image_thumbnail'
|
||||||
db.alter_column('djangocms_blog_post', 'main_image_thumbnail_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.SET_NULL, null=True, to=orm['cmsplugin_filer_image.ThumbnailOption']))
|
db.alter_column('djangocms_blog_post', 'main_image_thumbnail_id', self.gf('django.db.models.fields.related.ForeignKey')(on_delete=models.SET_NULL, null=True, to=orm[thumbnail_model]))
|
||||||
|
|
||||||
models = {
|
models = {
|
||||||
'auth.group': {
|
'auth.group': {
|
||||||
|
|
|
@ -6,7 +6,6 @@ from copy import deepcopy
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.core.management import call_command
|
|
||||||
|
|
||||||
from djangocms_helper.base_test import BaseTestCase
|
from djangocms_helper.base_test import BaseTestCase
|
||||||
from haystack import connections
|
from haystack import connections
|
||||||
|
@ -14,12 +13,7 @@ from haystack.constants import DEFAULT_ALIAS
|
||||||
from parler.utils.context import smart_override
|
from parler.utils.context import smart_override
|
||||||
|
|
||||||
from djangocms_blog.cms_appconfig import BlogConfig
|
from djangocms_blog.cms_appconfig import BlogConfig
|
||||||
from djangocms_blog.models import BlogCategory, Post
|
from djangocms_blog.models import BlogCategory, Post, ThumbnailOption
|
||||||
|
|
||||||
try:
|
|
||||||
from filer.models import ThumbnailOption # NOQA
|
|
||||||
except ImportError:
|
|
||||||
from cmsplugin_filer_image.models import ThumbnailOption # NOQA
|
|
||||||
|
|
||||||
|
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
|
|
Loading…
Reference in a new issue