From b2fbf1123c1746d5b4cb10bd2390e88f270a54b7 Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Fri, 7 Apr 2017 13:09:51 +0530 Subject: [PATCH 01/19] Realted post field added --- djangocms_blog/admin.py | 2 +- .../migrations/0029_post_related.py | 20 +++++++++++++++++++ djangocms_blog/models.py | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 djangocms_blog/migrations/0029_post_related.py diff --git a/djangocms_blog/admin.py b/djangocms_blog/admin.py index e6f4555..e01c5e3 100755 --- a/djangocms_blog/admin.py +++ b/djangocms_blog/admin.py @@ -86,7 +86,7 @@ class PostAdmin(PlaceholderAdminMixin, FrontendEditableAdminMixin, enhance_exclude = ('main_image', 'tags') _fieldsets = [ (None, { - 'fields': [['title', 'categories', 'publish', 'app_config']] + 'fields': [['title', 'categories', 'publish', 'app_config'], ['related',]] }), (_('Info'), { 'fields': [['slug', 'tags'], diff --git a/djangocms_blog/migrations/0029_post_related.py b/djangocms_blog/migrations/0029_post_related.py new file mode 100644 index 0000000..1a252db --- /dev/null +++ b/djangocms_blog/migrations/0029_post_related.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-04-07 07:35 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('djangocms_blog', '0028_auto_20170304_1040'), + ] + + operations = [ + migrations.AddField( + model_name='post', + name='related', + field=models.ManyToManyField(blank=True, to='djangocms_blog.Post', verbose_name='Related Posts'), + ), + ] diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 63ab67a..47a343f 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -191,6 +191,8 @@ class Post(KnockerModel, ModelMeta, TranslatableModel): objects = GenericDateTaggedManager() tags = TaggableManager(blank=True, related_name='djangocms_blog_tags') + related = models.ManyToManyField('self', verbose_name=_('Related Posts'), blank=True, symmetrical=False) + _metadata = { 'title': 'get_title', 'description': 'get_description', From c2b97edb24002b3cc60764ce9b43707dcd4cec6e Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Fri, 7 Apr 2017 13:18:36 +0530 Subject: [PATCH 02/19] Code format corrected --- djangocms_blog/admin.py | 3 +-- djangocms_blog/models.py | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/djangocms_blog/admin.py b/djangocms_blog/admin.py index e01c5e3..159bb9d 100755 --- a/djangocms_blog/admin.py +++ b/djangocms_blog/admin.py @@ -86,7 +86,7 @@ class PostAdmin(PlaceholderAdminMixin, FrontendEditableAdminMixin, enhance_exclude = ('main_image', 'tags') _fieldsets = [ (None, { - 'fields': [['title', 'categories', 'publish', 'app_config'], ['related',]] + 'fields': [['title', 'categories', 'publish', 'app_config'], ['related', ]] }), (_('Info'), { 'fields': [['slug', 'tags'], @@ -289,7 +289,6 @@ class PostAdmin(PlaceholderAdminMixin, FrontendEditableAdminMixin, class BlogConfigAdmin(BaseAppHookConfig, TranslatableAdmin): - @property def declared_fieldsets(self): return self.get_fieldsets(None) diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 47a343f..8d34aac 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -191,7 +191,10 @@ class Post(KnockerModel, ModelMeta, TranslatableModel): objects = GenericDateTaggedManager() tags = TaggableManager(blank=True, related_name='djangocms_blog_tags') - related = models.ManyToManyField('self', verbose_name=_('Related Posts'), blank=True, symmetrical=False) + related = models.ManyToManyField('self', + verbose_name=_('Related Posts'), + blank=True, + symmetrical=False) _metadata = { 'title': 'get_title', From eebe16c8f5d502353249243135700590ead1fa43 Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Tue, 11 Apr 2017 15:06:37 +0530 Subject: [PATCH 03/19] Post ordering functionality added --- djangocms_blog/admin.py | 3 ++- .../migrations/0030_auto_20170411_1456.py | 24 +++++++++++++++++++ djangocms_blog/models.py | 6 +++-- setup.py | 1 + 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 djangocms_blog/migrations/0030_auto_20170411_1456.py diff --git a/djangocms_blog/admin.py b/djangocms_blog/admin.py index 159bb9d..8392996 100755 --- a/djangocms_blog/admin.py +++ b/djangocms_blog/admin.py @@ -3,6 +3,7 @@ from __future__ import absolute_import, print_function, unicode_literals from copy import deepcopy +from adminsortable.admin import SortableAdmin from aldryn_apphooks_config.admin import BaseAppHookConfig, ModelAppHookConfig from cms.admin.placeholderadmin import FrontendEditableAdminMixin, PlaceholderAdminMixin from cms.models import CMSPlugin, ValidationError @@ -73,7 +74,7 @@ class BlogCategoryAdmin(EnhancedModelAdminMixin, ModelAppHookConfig, Translatabl class PostAdmin(PlaceholderAdminMixin, FrontendEditableAdminMixin, - ModelAppHookConfig, TranslatableAdmin): + ModelAppHookConfig, TranslatableAdmin, SortableAdmin): form = PostAdminForm list_display = [ 'title', 'author', 'date_published', 'app_config', 'all_languages_column', diff --git a/djangocms_blog/migrations/0030_auto_20170411_1456.py b/djangocms_blog/migrations/0030_auto_20170411_1456.py new file mode 100644 index 0000000..91ae84b --- /dev/null +++ b/djangocms_blog/migrations/0030_auto_20170411_1456.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-04-11 09:26 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('djangocms_blog', '0029_post_related'), + ] + + operations = [ + migrations.AlterModelOptions( + name='post', + options={'get_latest_by': 'date_published', 'ordering': ('post_order', '-date_published', '-date_created'), 'verbose_name': 'blog article', 'verbose_name_plural': 'blog articles'}, + ), + migrations.AddField( + model_name='post', + name='post_order', + field=models.PositiveIntegerField(db_index=True, default=0, editable=False), + ), + ] diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 8d34aac..c8d832c 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -3,6 +3,7 @@ from __future__ import absolute_import, print_function, unicode_literals import hashlib +from adminsortable.models import SortableMixin from aldryn_apphooks_config.fields import AppHookConfigField from aldryn_apphooks_config.managers.parler import AppHookConfigTranslatableManager from cms.models import CMSPlugin, PlaceholderField @@ -130,7 +131,7 @@ class BlogCategory(TranslatableModel): @python_2_unicode_compatible -class Post(KnockerModel, ModelMeta, TranslatableModel): +class Post(SortableMixin, KnockerModel, ModelMeta, TranslatableModel): """ Blog post """ @@ -195,6 +196,7 @@ class Post(KnockerModel, ModelMeta, TranslatableModel): verbose_name=_('Related Posts'), blank=True, symmetrical=False) + post_order = models.PositiveIntegerField(default=0, editable=False, db_index=True) _metadata = { 'title': 'get_title', @@ -227,7 +229,7 @@ class Post(KnockerModel, ModelMeta, TranslatableModel): class Meta: verbose_name = _('blog article') verbose_name_plural = _('blog articles') - ordering = ('-date_published', '-date_created') + ordering = ('post_order', '-date_published', '-date_created') get_latest_by = 'date_published' def __str__(self): diff --git a/setup.py b/setup.py index 55bce8d..c9642d2 100755 --- a/setup.py +++ b/setup.py @@ -40,6 +40,7 @@ setup( 'django-meta-mixin>=0.3', 'aldryn-apphooks-config>=0.2.6', 'djangocms-apphook-setup', + 'django-admin-sortable', ], extras_require={ 'search': ['aldryn-search'], From ca685d5879eeebc42eff66633b2892765db02123 Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Tue, 11 Apr 2017 17:19:38 +0530 Subject: [PATCH 04/19] Default ordering changed --- .../migrations/0031_auto_20170411_1719.py | 19 +++++++++++++++++++ djangocms_blog/models.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 djangocms_blog/migrations/0031_auto_20170411_1719.py diff --git a/djangocms_blog/migrations/0031_auto_20170411_1719.py b/djangocms_blog/migrations/0031_auto_20170411_1719.py new file mode 100644 index 0000000..958e889 --- /dev/null +++ b/djangocms_blog/migrations/0031_auto_20170411_1719.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-04-11 11:49 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('djangocms_blog', '0030_auto_20170411_1456'), + ] + + operations = [ + migrations.AlterModelOptions( + name='post', + options={'get_latest_by': 'date_published', 'ordering': ('-post_order', '-date_published', '-date_created'), 'verbose_name': 'blog article', 'verbose_name_plural': 'blog articles'}, + ), + ] diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index c8d832c..f86ee73 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -229,7 +229,7 @@ class Post(SortableMixin, KnockerModel, ModelMeta, TranslatableModel): class Meta: verbose_name = _('blog article') verbose_name_plural = _('blog articles') - ordering = ('post_order', '-date_published', '-date_created') + ordering = ('-post_order', '-date_published', '-date_created') get_latest_by = 'date_published' def __str__(self): From cbd64d2e43c90476d697b1b701c899adcc8b076e Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Tue, 2 May 2017 18:11:34 +0530 Subject: [PATCH 05/19] fixed related field issue when topic has not translations for other language --- djangocms_blog/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index f86ee73..1be2cd4 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -233,7 +233,7 @@ class Post(SortableMixin, KnockerModel, ModelMeta, TranslatableModel): get_latest_by = 'date_published' def __str__(self): - return self.safe_translation_getter('title') + return self.safe_translation_getter('title', any_language=True) @property def guid(self, language=None): From 8d446ec0c077804dcc901135cd8599af8f9aeab6 Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Tue, 9 May 2017 18:33:18 +0530 Subject: [PATCH 06/19] Allow allow_unicode slug field --- .../migrations/0032_auto_20170509_1831.py | 20 +++++++++++++++++++ djangocms_blog/models.py | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 djangocms_blog/migrations/0032_auto_20170509_1831.py diff --git a/djangocms_blog/migrations/0032_auto_20170509_1831.py b/djangocms_blog/migrations/0032_auto_20170509_1831.py new file mode 100644 index 0000000..05bd4c6 --- /dev/null +++ b/djangocms_blog/migrations/0032_auto_20170509_1831.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-05-09 13:01 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('djangocms_blog', '0031_auto_20170411_1719'), + ] + + operations = [ + migrations.AlterField( + model_name='posttranslation', + name='slug', + field=models.SlugField(allow_unicode=True, blank=True, max_length=255, verbose_name='slug'), + ), + ] diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 1be2cd4..fe3c6c5 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -172,7 +172,7 @@ class Post(SortableMixin, KnockerModel, ModelMeta, TranslatableModel): translations = TranslatedFields( title=models.CharField(_('title'), max_length=255), - slug=models.SlugField(_('slug'), max_length=255, blank=True, db_index=True), + slug=models.SlugField(_('slug'), max_length=255, blank=True, db_index=True, allow_unicode=True), abstract=HTMLField(_('abstract'), blank=True, default=''), meta_description=models.TextField(verbose_name=_('post meta description'), blank=True, default=''), @@ -258,7 +258,7 @@ class Post(SortableMixin, KnockerModel, ModelMeta, TranslatableModel): if self.publish and self.date_published is None: self.date_published = timezone.now() if not self.slug and self.title: - self.slug = slugify(self.title) + self.slug = slugify(self.title, allow_unicode=True) super(Post, self).save(*args, **kwargs) def save_translation(self, translation, *args, **kwargs): From 1bb0ac8c756740656466ab3fe7b462d61dc9ed0f Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Tue, 6 Jun 2017 09:06:51 +0530 Subject: [PATCH 07/19] Revert "Default ordering changed" This reverts commit ca685d5879eeebc42eff66633b2892765db02123. --- .../migrations/0031_auto_20170411_1719.py | 19 ------------------- djangocms_blog/models.py | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 djangocms_blog/migrations/0031_auto_20170411_1719.py diff --git a/djangocms_blog/migrations/0031_auto_20170411_1719.py b/djangocms_blog/migrations/0031_auto_20170411_1719.py deleted file mode 100644 index 958e889..0000000 --- a/djangocms_blog/migrations/0031_auto_20170411_1719.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.5 on 2017-04-11 11:49 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('djangocms_blog', '0030_auto_20170411_1456'), - ] - - operations = [ - migrations.AlterModelOptions( - name='post', - options={'get_latest_by': 'date_published', 'ordering': ('-post_order', '-date_published', '-date_created'), 'verbose_name': 'blog article', 'verbose_name_plural': 'blog articles'}, - ), - ] diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index fe3c6c5..44fd329 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -229,7 +229,7 @@ class Post(SortableMixin, KnockerModel, ModelMeta, TranslatableModel): class Meta: verbose_name = _('blog article') verbose_name_plural = _('blog articles') - ordering = ('-post_order', '-date_published', '-date_created') + ordering = ('post_order', '-date_published', '-date_created') get_latest_by = 'date_published' def __str__(self): From fbd9eb00660dd1e8172262b8b24173950a831d7f Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Tue, 6 Jun 2017 09:07:32 +0530 Subject: [PATCH 08/19] Revert "Post ordering functionality added" This reverts commit eebe16c8f5d502353249243135700590ead1fa43. --- djangocms_blog/admin.py | 3 +-- .../migrations/0030_auto_20170411_1456.py | 24 ------------------- djangocms_blog/models.py | 6 ++--- setup.py | 1 - 4 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 djangocms_blog/migrations/0030_auto_20170411_1456.py diff --git a/djangocms_blog/admin.py b/djangocms_blog/admin.py index 8392996..159bb9d 100755 --- a/djangocms_blog/admin.py +++ b/djangocms_blog/admin.py @@ -3,7 +3,6 @@ from __future__ import absolute_import, print_function, unicode_literals from copy import deepcopy -from adminsortable.admin import SortableAdmin from aldryn_apphooks_config.admin import BaseAppHookConfig, ModelAppHookConfig from cms.admin.placeholderadmin import FrontendEditableAdminMixin, PlaceholderAdminMixin from cms.models import CMSPlugin, ValidationError @@ -74,7 +73,7 @@ class BlogCategoryAdmin(EnhancedModelAdminMixin, ModelAppHookConfig, Translatabl class PostAdmin(PlaceholderAdminMixin, FrontendEditableAdminMixin, - ModelAppHookConfig, TranslatableAdmin, SortableAdmin): + ModelAppHookConfig, TranslatableAdmin): form = PostAdminForm list_display = [ 'title', 'author', 'date_published', 'app_config', 'all_languages_column', diff --git a/djangocms_blog/migrations/0030_auto_20170411_1456.py b/djangocms_blog/migrations/0030_auto_20170411_1456.py deleted file mode 100644 index 91ae84b..0000000 --- a/djangocms_blog/migrations/0030_auto_20170411_1456.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.5 on 2017-04-11 09:26 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('djangocms_blog', '0029_post_related'), - ] - - operations = [ - migrations.AlterModelOptions( - name='post', - options={'get_latest_by': 'date_published', 'ordering': ('post_order', '-date_published', '-date_created'), 'verbose_name': 'blog article', 'verbose_name_plural': 'blog articles'}, - ), - migrations.AddField( - model_name='post', - name='post_order', - field=models.PositiveIntegerField(db_index=True, default=0, editable=False), - ), - ] diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 44fd329..3c12251 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -3,7 +3,6 @@ from __future__ import absolute_import, print_function, unicode_literals import hashlib -from adminsortable.models import SortableMixin from aldryn_apphooks_config.fields import AppHookConfigField from aldryn_apphooks_config.managers.parler import AppHookConfigTranslatableManager from cms.models import CMSPlugin, PlaceholderField @@ -131,7 +130,7 @@ class BlogCategory(TranslatableModel): @python_2_unicode_compatible -class Post(SortableMixin, KnockerModel, ModelMeta, TranslatableModel): +class Post(KnockerModel, ModelMeta, TranslatableModel): """ Blog post """ @@ -196,7 +195,6 @@ class Post(SortableMixin, KnockerModel, ModelMeta, TranslatableModel): verbose_name=_('Related Posts'), blank=True, symmetrical=False) - post_order = models.PositiveIntegerField(default=0, editable=False, db_index=True) _metadata = { 'title': 'get_title', @@ -229,7 +227,7 @@ class Post(SortableMixin, KnockerModel, ModelMeta, TranslatableModel): class Meta: verbose_name = _('blog article') verbose_name_plural = _('blog articles') - ordering = ('post_order', '-date_published', '-date_created') + ordering = ('-date_published', '-date_created') get_latest_by = 'date_published' def __str__(self): diff --git a/setup.py b/setup.py index c9642d2..55bce8d 100755 --- a/setup.py +++ b/setup.py @@ -40,7 +40,6 @@ setup( 'django-meta-mixin>=0.3', 'aldryn-apphooks-config>=0.2.6', 'djangocms-apphook-setup', - 'django-admin-sortable', ], extras_require={ 'search': ['aldryn-search'], From 29ff92f19adfdb1977837e08b4846d65acfe2701 Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Tue, 6 Jun 2017 09:11:19 +0530 Subject: [PATCH 09/19] Migration fixed --- .../{0032_auto_20170509_1831.py => 0030_auto_20170509_1831.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename djangocms_blog/migrations/{0032_auto_20170509_1831.py => 0030_auto_20170509_1831.py} (89%) diff --git a/djangocms_blog/migrations/0032_auto_20170509_1831.py b/djangocms_blog/migrations/0030_auto_20170509_1831.py similarity index 89% rename from djangocms_blog/migrations/0032_auto_20170509_1831.py rename to djangocms_blog/migrations/0030_auto_20170509_1831.py index 05bd4c6..c229bb7 100644 --- a/djangocms_blog/migrations/0032_auto_20170509_1831.py +++ b/djangocms_blog/migrations/0030_auto_20170509_1831.py @@ -8,7 +8,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('djangocms_blog', '0031_auto_20170411_1719'), + ('djangocms_blog', '0029_post_related.py'), ] operations = [ From 09435982e4b9368eb57bb90210712c229609fc90 Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Tue, 6 Jun 2017 09:18:02 +0530 Subject: [PATCH 10/19] code formatting --- djangocms_blog/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 3c12251..55c1ed0 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -171,7 +171,8 @@ class Post(KnockerModel, ModelMeta, TranslatableModel): translations = TranslatedFields( title=models.CharField(_('title'), max_length=255), - slug=models.SlugField(_('slug'), max_length=255, blank=True, db_index=True, allow_unicode=True), + slug=models.SlugField(_('slug'), max_length=255, blank=True, + db_index=True, allow_unicode=True), abstract=HTMLField(_('abstract'), blank=True, default=''), meta_description=models.TextField(verbose_name=_('post meta description'), blank=True, default=''), @@ -186,7 +187,8 @@ class Post(KnockerModel, ModelMeta, TranslatableModel): ) content = PlaceholderField('post_content', related_name='post_content') liveblog = PlaceholderField('live_blog', related_name='live_blog') - enable_liveblog = models.BooleanField(verbose_name=_('enable liveblog on post'), default=False) + enable_liveblog = models.BooleanField(verbose_name=_('enable liveblog on post'), + default=False) objects = GenericDateTaggedManager() tags = TaggableManager(blank=True, related_name='djangocms_blog_tags') From 4b53e94a979a64cc9312ccc5df1e8ca64fef0c9e Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Tue, 6 Jun 2017 09:20:37 +0530 Subject: [PATCH 11/19] migration issue fixed --- djangocms_blog/migrations/0030_auto_20170509_1831.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangocms_blog/migrations/0030_auto_20170509_1831.py b/djangocms_blog/migrations/0030_auto_20170509_1831.py index c229bb7..9243743 100644 --- a/djangocms_blog/migrations/0030_auto_20170509_1831.py +++ b/djangocms_blog/migrations/0030_auto_20170509_1831.py @@ -8,7 +8,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('djangocms_blog', '0029_post_related.py'), + ('djangocms_blog', '0029_post_related'), ] operations = [ From 815535c4bf73c0d8d071a34fe13be6feb647bc5a Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Sat, 10 Jun 2017 18:14:57 +0530 Subject: [PATCH 12/19] added django-sortedm2m --- .../migrations/0031_auto_20170610_1744.py | 22 +++++++++++++++++++ djangocms_blog/models.py | 9 ++++---- setup.py | 1 + 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 djangocms_blog/migrations/0031_auto_20170610_1744.py diff --git a/djangocms_blog/migrations/0031_auto_20170610_1744.py b/djangocms_blog/migrations/0031_auto_20170610_1744.py new file mode 100644 index 0000000..e8fedab --- /dev/null +++ b/djangocms_blog/migrations/0031_auto_20170610_1744.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-06-10 12:14 +from __future__ import unicode_literals + +from django.db import migrations +import sortedm2m.fields +from sortedm2m.operations import AlterSortedManyToManyField + + +class Migration(migrations.Migration): + + dependencies = [ + ('djangocms_blog', '0030_auto_20170509_1831'), + ] + + operations = [ + AlterSortedManyToManyField( + model_name='post', + name='related', + field=sortedm2m.fields.SortedManyToManyField(blank=True, help_text=None, to='djangocms_blog.Post', verbose_name='Related Posts'), + ), + ] diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 55c1ed0..5c55bd7 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -26,6 +26,7 @@ from meta.models import ModelMeta from parler.models import TranslatableModel, TranslatedFields from parler.utils.context import switch_language from taggit_autosuggest.managers import TaggableManager +from sortedm2m.fields import SortedManyToManyField from .cms_appconfig import BlogConfig from .managers import GenericDateTaggedManager @@ -193,10 +194,10 @@ class Post(KnockerModel, ModelMeta, TranslatableModel): objects = GenericDateTaggedManager() tags = TaggableManager(blank=True, related_name='djangocms_blog_tags') - related = models.ManyToManyField('self', - verbose_name=_('Related Posts'), - blank=True, - symmetrical=False) + related = SortedManyToManyField('self', + verbose_name=_('Related Posts'), + blank=True, + symmetrical=False) _metadata = { 'title': 'get_title', diff --git a/setup.py b/setup.py index 55bce8d..af516e8 100755 --- a/setup.py +++ b/setup.py @@ -40,6 +40,7 @@ setup( 'django-meta-mixin>=0.3', 'aldryn-apphooks-config>=0.2.6', 'djangocms-apphook-setup', + 'django-sortedm2m', ], extras_require={ 'search': ['aldryn-search'], From 9619064f44e6cbd625630bec92591bd0cbfe8533 Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Sat, 10 Jun 2017 18:34:36 +0530 Subject: [PATCH 13/19] Fixed helper --- cms_helper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cms_helper.py b/cms_helper.py index 8f28c53..6d78fd9 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -25,6 +25,7 @@ HELPER_SETTINGS = dict( 'taggit_autosuggest', 'aldryn_apphooks_config', 'aldryn_search', + 'sortedm2m', ], LANGUAGE_CODE='en', LANGUAGES=( From b56929cb9933e51230780460708bff6b88c8699d Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Sat, 10 Jun 2017 18:47:15 +0530 Subject: [PATCH 14/19] fixed isort test --- djangocms_blog/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 5c55bd7..90a647b 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -25,8 +25,8 @@ from filer.fields.image import FilerImageField from meta.models import ModelMeta from parler.models import TranslatableModel, TranslatedFields from parler.utils.context import switch_language -from taggit_autosuggest.managers import TaggableManager from sortedm2m.fields import SortedManyToManyField +from taggit_autosuggest.managers import TaggableManager from .cms_appconfig import BlogConfig from .managers import GenericDateTaggedManager From d24f3130d68e9d10d69d892737e5896f743019e6 Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Sun, 11 Jun 2017 12:35:32 +0530 Subject: [PATCH 15/19] moved related field below abstract field --- djangocms_blog/admin.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/djangocms_blog/admin.py b/djangocms_blog/admin.py index 159bb9d..ceba307 100755 --- a/djangocms_blog/admin.py +++ b/djangocms_blog/admin.py @@ -88,6 +88,9 @@ class PostAdmin(PlaceholderAdminMixin, FrontendEditableAdminMixin, (None, { 'fields': [['title', 'categories', 'publish', 'app_config'], ['related', ]] }), + (None,{ + 'fields': [['related', ]] + }), (_('Info'), { 'fields': [['slug', 'tags'], ['date_published', 'date_published_end', 'date_featured'], From 85eb7a319a3bac55a69f1cd141ed34e142f1819b Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Sun, 11 Jun 2017 12:37:32 +0530 Subject: [PATCH 16/19] Update installation doc --- docs/installation.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/installation.rst b/docs/installation.rst index b67556e..f8011a8 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -20,6 +20,7 @@ Add ``djangocms_blog`` and its dependencies to INSTALLED_APPS:: 'taggit', 'taggit_autosuggest', 'meta', + 'sortedm2m', 'djangocms_blog', ... ] From aac62b1aef4ab7d0c59fa7590e116a41a0b19c99 Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Sat, 22 Jul 2017 11:36:15 +0530 Subject: [PATCH 17/19] Django 1.8 compatible --- djangocms_blog/fields.py | 9 ++++++++ .../migrations/0032_auto_20170722_1058.py | 21 +++++++++++++++++++ djangocms_blog/models.py | 9 ++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 djangocms_blog/fields.py create mode 100644 djangocms_blog/migrations/0032_auto_20170722_1058.py diff --git a/djangocms_blog/fields.py b/djangocms_blog/fields.py new file mode 100644 index 0000000..d2f81f0 --- /dev/null +++ b/djangocms_blog/fields.py @@ -0,0 +1,9 @@ +from django.db.models import SlugField + +__all__ = ['AutoSlugField'] + + +class AutoSlugField(SlugField): + def __init__(self, *args, **kwargs): + self.allow_unicode = kwargs.pop('allow_unicode', False) + super(SlugField, self).__init__(*args, **kwargs) diff --git a/djangocms_blog/migrations/0032_auto_20170722_1058.py b/djangocms_blog/migrations/0032_auto_20170722_1058.py new file mode 100644 index 0000000..978a286 --- /dev/null +++ b/djangocms_blog/migrations/0032_auto_20170722_1058.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-07-22 05:28 +from __future__ import unicode_literals + +from django.db import migrations +import djangocms_blog.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('djangocms_blog', '0031_auto_20170610_1744'), + ] + + operations = [ + migrations.AlterField( + model_name='posttranslation', + name='slug', + field=djangocms_blog.fields.AutoSlugField(allow_unicode=True, blank=True, db_index=False, max_length=255, verbose_name='slug'), + ), + ] diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 90a647b..10a86c0 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -3,6 +3,7 @@ from __future__ import absolute_import, print_function, unicode_literals import hashlib +import django from aldryn_apphooks_config.fields import AppHookConfigField from aldryn_apphooks_config.managers.parler import AppHookConfigTranslatableManager from cms.models import CMSPlugin, PlaceholderField @@ -29,6 +30,7 @@ from sortedm2m.fields import SortedManyToManyField from taggit_autosuggest.managers import TaggableManager from .cms_appconfig import BlogConfig +from .fields import AutoSlugField from .managers import GenericDateTaggedManager from .settings import get_setting @@ -172,7 +174,7 @@ class Post(KnockerModel, ModelMeta, TranslatableModel): translations = TranslatedFields( title=models.CharField(_('title'), max_length=255), - slug=models.SlugField(_('slug'), max_length=255, blank=True, + slug=AutoSlugField(_('slug'), max_length=255, blank=True, db_index=True, allow_unicode=True), abstract=HTMLField(_('abstract'), blank=True, default=''), meta_description=models.TextField(verbose_name=_('post meta description'), @@ -259,7 +261,10 @@ class Post(KnockerModel, ModelMeta, TranslatableModel): if self.publish and self.date_published is None: self.date_published = timezone.now() if not self.slug and self.title: - self.slug = slugify(self.title, allow_unicode=True) + if django.VERSION >= (1, 9): + self.slug = slugify(self.title, allow_unicode=True) + else: + self.slug = slugify(self.title) super(Post, self).save(*args, **kwargs) def save_translation(self, translation, *args, **kwargs): From a1498d7f4285d97c7e0e28458ad720d405e43549 Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Sat, 22 Jul 2017 11:46:09 +0530 Subject: [PATCH 18/19] code formated --- djangocms_blog/admin.py | 4 ++-- djangocms_blog/models.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/djangocms_blog/admin.py b/djangocms_blog/admin.py index ceba307..0f7ab21 100755 --- a/djangocms_blog/admin.py +++ b/djangocms_blog/admin.py @@ -86,9 +86,9 @@ class PostAdmin(PlaceholderAdminMixin, FrontendEditableAdminMixin, enhance_exclude = ('main_image', 'tags') _fieldsets = [ (None, { - 'fields': [['title', 'categories', 'publish', 'app_config'], ['related', ]] + 'fields': [['title', 'categories', 'publish', 'app_config']] }), - (None,{ + (None, { 'fields': [['related', ]] }), (_('Info'), { diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 10a86c0..b11518d 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -175,7 +175,7 @@ class Post(KnockerModel, ModelMeta, TranslatableModel): translations = TranslatedFields( title=models.CharField(_('title'), max_length=255), slug=AutoSlugField(_('slug'), max_length=255, blank=True, - db_index=True, allow_unicode=True), + db_index=True, allow_unicode=True), abstract=HTMLField(_('abstract'), blank=True, default=''), meta_description=models.TextField(verbose_name=_('post meta description'), blank=True, default=''), From d71f742efbedfb00416dbff1ae0a72eb5522e868 Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Sat, 22 Jul 2017 12:27:10 +0530 Subject: [PATCH 19/19] - Fixed migrations - fixed live blog admin field issue --- djangocms_blog/admin.py | 2 +- .../migrations/0030_auto_20170509_1831.py | 7 ++++--- .../migrations/0032_auto_20170722_1058.py | 21 ------------------- 3 files changed, 5 insertions(+), 25 deletions(-) delete mode 100644 djangocms_blog/migrations/0032_auto_20170722_1058.py diff --git a/djangocms_blog/admin.py b/djangocms_blog/admin.py index 0f7ab21..1ccc636 100755 --- a/djangocms_blog/admin.py +++ b/djangocms_blog/admin.py @@ -247,7 +247,7 @@ class PostAdmin(PlaceholderAdminMixin, FrontendEditableAdminMixin, if request.user.is_superuser: fsets[1][1]['fields'][0].append('author') if apps.is_installed('djangocms_blog.liveblog'): - fsets[1][1]['fields'][2].append('enable_liveblog') + fsets[2][1]['fields'][2].append('enable_liveblog') filter_function = get_setting('ADMIN_POST_FIELDSET_FILTER') if callable(filter_function): fsets = filter_function(fsets, request, obj=obj) diff --git a/djangocms_blog/migrations/0030_auto_20170509_1831.py b/djangocms_blog/migrations/0030_auto_20170509_1831.py index 9243743..5b879a3 100644 --- a/djangocms_blog/migrations/0030_auto_20170509_1831.py +++ b/djangocms_blog/migrations/0030_auto_20170509_1831.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.10.5 on 2017-05-09 13:01 +# Generated by Django 1.10.5 on 2017-07-22 05:28 from __future__ import unicode_literals -from django.db import migrations, models +from django.db import migrations +import djangocms_blog.fields class Migration(migrations.Migration): @@ -15,6 +16,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='posttranslation', name='slug', - field=models.SlugField(allow_unicode=True, blank=True, max_length=255, verbose_name='slug'), + field=djangocms_blog.fields.AutoSlugField(allow_unicode=True, blank=True, db_index=False, max_length=255, verbose_name='slug'), ), ] diff --git a/djangocms_blog/migrations/0032_auto_20170722_1058.py b/djangocms_blog/migrations/0032_auto_20170722_1058.py deleted file mode 100644 index 978a286..0000000 --- a/djangocms_blog/migrations/0032_auto_20170722_1058.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.5 on 2017-07-22 05:28 -from __future__ import unicode_literals - -from django.db import migrations -import djangocms_blog.fields - - -class Migration(migrations.Migration): - - dependencies = [ - ('djangocms_blog', '0031_auto_20170610_1744'), - ] - - operations = [ - migrations.AlterField( - model_name='posttranslation', - name='slug', - field=djangocms_blog.fields.AutoSlugField(allow_unicode=True, blank=True, db_index=False, max_length=255, verbose_name='slug'), - ), - ]