# Path: aldryn_blog/conf.py
# class AldrynBlogAppConf(AppConf):
#     class Meta:
#     PLUGIN_LANGUAGE = settings.LANGUAGES[0][0]
#     SEARCH = True


import datetime
from collections import Counter
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse, NoReverseMatch
from django.db import models
from django.db.models import Q
from django.template.defaultfilters import slugify
from django.utils import timezone
from django.utils.translation import get_language, ugettext_lazy as _, override
from app_data import AppDataField
from cms.utils.i18n import get_current_language
from cms.models.fields import PlaceholderField
from cms.models.pluginmodel import CMSPlugin
from djangocms_text_ckeditor.fields import HTMLField
from filer.fields.image import FilerImageField
from hvad.models import TranslationManager, TranslatableModel, TranslatedFields
from taggit.managers import TaggableManager
from taggit.models import TaggedItem, Tag
from .conf import settings
from .utils import generate_slugs, get_blog_authors, get_slug_for_user, get_slug_in_language
        help_text=_('Show only the blog posts tagged with chosen tags.')
    )

    def __unicode__(self):
        """
        must return a unicode string
        """
        return str(self.latest_entries).decode('utf8')

    def copy_relations(self, oldinstance):
        self.tags = oldinstance.tags.all()

    def get_posts(self):
        posts = Post.published.filter_by_language(self.language)
        tags = self.tags.values_list('pk', flat=True)

        if tags.exists():
            posts = posts.filter(tags__in=tags)
        return posts[:self.latest_entries]


class AuthorsPlugin(CMSPlugin):

    def get_authors(self):
        return generate_slugs(get_blog_authors())


def force_language(sender, instance, **kwargs):
    if issubclass(sender, CMSPlugin) and instance.placeholder \
            and instance.placeholder.slot == 'aldryn_blog_post_content':

# Path: aldryn_blog/conf.py
# class AldrynBlogAppConf(AppConf):
#     class Meta:
#     PLUGIN_LANGUAGE = settings.LANGUAGES[0][0]
#     SEARCH = True


# Path: aldryn_blog/models.py
import datetime
from collections import Counter
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse, NoReverseMatch
from django.db import models
from django.db.models import Q
from django.template.defaultfilters import slugify
from django.utils import timezone
from django.utils.translation import get_language, ugettext_lazy as _, override
from app_data import AppDataField
from cms.utils.i18n import get_current_language
from cms.models.fields import PlaceholderField
from cms.models.pluginmodel import CMSPlugin
from djangocms_text_ckeditor.fields import HTMLField
from filer.fields.image import FilerImageField
from hvad.models import TranslationManager, TranslatableModel, TranslatedFields
from taggit.managers import TaggableManager
from taggit.models import TaggedItem, Tag
from .conf import settings
from .utils import generate_slugs, get_blog_authors, get_slug_for_user, get_slug_in_language

        help_text=_('Show only the blog posts tagged with chosen tags.')
    )

    def __unicode__(self):
        """
        must return a unicode string
        """
        return str(self.latest_entries).decode('utf8')

    def copy_relations(self, oldinstance):
        self.tags = oldinstance.tags.all()

    def get_posts(self):
        posts = Post.published.filter_by_language(self.language)
        tags = self.tags.values_list('pk', flat=True)

        if tags.exists():
            posts = posts.filter(tags__in=tags)
        return posts[:self.latest_entries]


class AuthorsPlugin(CMSPlugin):

    def get_authors(self):
        return generate_slugs(get_blog_authors())


def force_language(sender, instance, **kwargs):
    if issubclass(sender, CMSPlugin) and instance.placeholder \
            and instance.placeholder.slot == 'aldryn_blog_post_content':

        instance.language = settings.ALDRYN_BLOG_PLUGIN_LANGUAGE