Post ordering functionality added
This commit is contained in:
parent
c2b97edb24
commit
eebe16c8f5
4 changed files with 31 additions and 3 deletions
|
@ -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',
|
||||
|
|
24
djangocms_blog/migrations/0030_auto_20170411_1456.py
Normal file
24
djangocms_blog/migrations/0030_auto_20170411_1456.py
Normal file
|
@ -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),
|
||||
),
|
||||
]
|
|
@ -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):
|
||||
|
|
1
setup.py
1
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'],
|
||||
|
|
Loading…
Reference in a new issue