# -*- coding: utf-8 -*- # Future imports from __future__ import unicode_literals <<<<<<< Updated upstream from django.utils.translation import ugettext_lazy as _, ungettext_lazy from django.utils import six try: from django.utils.encoding import python_2_unicode_compatible except ImportError: def python_2_unicode_compatible(f): return f ======= # Django imports >>>>>>> Stashed changes from django.db import models from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy # Third Party from cms.models.fields import PageField from cms.models.fields import PlaceholderField from cms.models.pluginmodel import CMSPlugin from djangocms_text_ckeditor.fields import HTMLField from newsbox.models import NewsboxModelBase import six def newsboxcms_mcls_processor(mcls, class_name, class_bases, class_attrs, base, newsbox_opts): class_attrs['newsbox_summary'] = HTMLField( verbose_name=_('summary')) newsbox_opts['trans_fieldnames'].append('newsbox_summary') class_attrs['newsbox_body'] = PlaceholderField( 'newsbox-body', verbose_name=_('body')) if 'newsbox_body' in newsbox_opts['trans_fieldnames']: newsbox_opts['trans_fieldnames'].remove('newsbox_body') class NewsboxPluginBase(CMSPlugin): title = models.CharField( verbose_name=_('Title'), max_length=255, blank=True, null=True, help_text=_('Title to display before the list')) numitems = models.PositiveSmallIntegerField( verbose_name=_('Number of news'), default=2, help_text=_('Number of news to display. ' '"0" allow you to display ALL news')) with_pager = models.BooleanField( verbose_name=_('Display a pager'), default=False) page_link = PageField( verbose_name=_('All news page'), null=True, blank=True, help_text=_('Page displaying all news')) def __str__(self): if self.numitems > 0: return six.text_type(ungettext_lazy( 'Display of a news', 'Display of %(nb)d news', self.numitems ) % {'nb': self.numitems}) return six.text_type(_('Display of all news')) class Meta: abstract = True class NewsboxCMSBase(six.with_metaclass(NewsboxModelBase, models.Model)): class Meta: abstract = True newsbox_metaclass_base_processor = 'newsboxcms_mcls_processor'