Skip to content

Commit

Permalink
Refactor migration dependencies to avoid issue when going backward
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed May 27, 2016
1 parent 0a5814c commit 8e6ab53
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
19 changes: 14 additions & 5 deletions djangocms_blog/migrations/0001_initial.py
Expand Up @@ -17,14 +17,23 @@

class Migration(migrations.Migration):

if 'cmsplugin_filer' not in thumbnail_model:
filer_dependencies = [
('filer', '0003_thumbnailoption'),
('cmsplugin_filer_image', '0006_auto_20160427_1438')
]
else:
filer_dependencies = [
('filer', '__first__'),
('cmsplugin_filer_image', '__first__'),
]

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
migrations.swappable_dependency(ACTUAL_FILER_IMAGE_MODEL),
('cms', '__latest__'),
('taggit', '__latest__'),
('filer', '__latest__'),
('cmsplugin_filer_image', '__latest__'),
]
('cms', '__first__'),
('taggit', '__first__'),
] + filer_dependencies

operations = [
migrations.CreateModel(
Expand Down
2 changes: 1 addition & 1 deletion djangocms_blog/migrations/0002_post_sites.py
Expand Up @@ -7,7 +7,7 @@
class Migration(migrations.Migration):

dependencies = [
('sites', '__latest__'),
('sites', '__first__'),
('djangocms_blog', '0001_initial'),
]

Expand Down
Expand Up @@ -31,7 +31,7 @@ def migrate_tags_reverse(apps, schema_editor):
class Migration(migrations.Migration):

dependencies = [
('taggit', '__latest__'),
('taggit', '__first__'),
('djangocms_blog', '0008_auto_20150814_0831'),
]

Expand Down
2 changes: 1 addition & 1 deletion djangocms_blog/migrations/0010_auto_20150923_1151.py
Expand Up @@ -10,7 +10,7 @@
class Migration(migrations.Migration):

dependencies = [
('cms', '__latest__'),
('cms', '__first__'),
('djangocms_blog', '0009_latestpostsplugin_tags_new'),
]

Expand Down
16 changes: 5 additions & 11 deletions djangocms_blog/models.py
Expand Up @@ -32,18 +32,12 @@
BLOG_CURRENT_POST_IDENTIFIER = get_setting('CURRENT_POST_IDENTIFIER')
BLOG_CURRENT_NAMESPACE = get_setting('CURRENT_NAMESPACE')

try:
from cmsplugin_filer_image.models import ThumbnailOption # NOQA
except ImportError:
try: # pragma: no cover
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
)
thumbnail_model = 'filer.ThumbnailOption'
except ImportError: # pragma: no cover
from cmsplugin_filer_image.models import ThumbnailOption # NOQA
thumbnail_model = 'cmsplugin_filer_image.ThumbnailOption'


try:
Expand Down

0 comments on commit 8e6ab53

Please sign in to comment.