# Path: aldryn_blog/models.py
# class Category(TranslatableModel):
# 
#     translations = TranslatedFields(
#         name=models.CharField(_('Name'), max_length=255),
#         slug=models.SlugField(
#             verbose_name=_('Slug'),
#             max_length=255,
#             blank=True,
#             help_text=_('Auto-generated. Clean it to have it re-created. '
#                         'WARNING! Used in the URL. If changed, the URL will change. ')
#         ),
#         meta={'unique_together': [['slug', 'language_code']]}
#     )
# 
#     ordering = models.IntegerField(_('Ordering'), default=0)
# 
#     objects = CategoryManager()
# 
#     class Meta:
#         verbose_name = _('Category')
#         verbose_name_plural = _('Categories')
#         ordering = ['ordering']
# 
#     def __unicode__(self):
#         return self.lazy_translation_getter('name', str(self.pk))
# 
#     def get_absolute_url(self, language=None):
#         language = language or get_current_language()
#         slug = get_slug_in_language(self, language)
#         with override(language):
#             if slug:
#                 return reverse('aldryn_blog:category-posts', kwargs={'category': slug})
# 
#             # category not translated in given language
#             try:
#                 return reverse('aldryn_blog:latest-posts')
#             except (ImproperlyConfigured, NoReverseMatch):
#                 return '/%s' % language
# 
# class Post(models.Model):
# 
#     title = models.CharField(_('Title'), max_length=255)
#     slug = models.SlugField(
#         verbose_name=_('Slug'),
#         max_length=255,
#         unique=True,
#         blank=True,
#         help_text=_('Used in the URL. If changed, the URL will change. Clean it to have it re-created.')
#     )
#     language = models.CharField(
#         verbose_name=_('language'),
#         max_length=5,
#         null=True,
#         blank=True,
#         choices=settings.LANGUAGES,
#         help_text=_('leave empty to display in all languages')
#     )
#     key_visual = FilerImageField(verbose_name=_('Key Visual'), blank=True, null=True)
#     lead_in = HTMLField(
#         verbose_name=_('Lead-in'),
#         help_text=_('Will be displayed in lists, and at the start of the detail page (in bold)')
#     )
#     content = PlaceholderField('aldryn_blog_post_content', related_name='aldryn_blog_posts')
#     author = models.ForeignKey(to=AUTH_USER_MODEL, verbose_name=_('Author'))
#     coauthors = models.ManyToManyField(
#         to=AUTH_USER_MODEL,
#         verbose_name=_('Co-Authors'),
#         null=True,
#         blank=True,
#         related_name='aldryn_blog_coauthors'
#     )
#     publication_start = models.DateTimeField(
#         verbose_name=_('Published Since'),
#         default=timezone.now,
#         help_text=_('Used in the URL. If changed, the URL will change.')
#     )
#     publication_end = models.DateTimeField(
#         verbose_name=_('Published Until'),
#         null=True,
#         blank=True
#     )
#     category = models.ForeignKey(
#         to=Category,
#         verbose_name=_('Category'),
#         null=True,
#         blank=True
#     )
# 
#     objects = RelatedManager()
#     published = PublishedManager()
#     tags = TaggableManager(blank=True)
#     app_data = AppDataField()
# 
#     def __unicode__(self):
#         return self.title
# 
#     def get_absolute_url(self):
#         kwargs = {
#             'year': self.publication_start.year,
#             'month': self.publication_start.month,
#             'day': self.publication_start.day,
#             'slug': self.slug
#         }
# 
#         if self.language and not getattr(settings, 'ALDRYN_BLOG_SHOW_ALL_LANGUAGES', False):
#             with override(self.language):
#                 return reverse('aldryn_blog:post-detail', kwargs=kwargs)
#         return reverse('aldryn_blog:post-detail', kwargs=kwargs)
# 
#     class Meta:
#         ordering = ['-publication_start']
# 
#     def save(self, **kwargs):
#         if not self.slug:
#             self.slug = slugify(self.title)
#         return super(Post, self).save(**kwargs)
# 
#     def get_author_slug(self):
#         # FIXME: This is a potential performance hogger
#         return get_slug_for_user(self.author)


import datetime
from django.contrib.sites.models import Site
from django.contrib.syndication.views import Feed
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.utils.translation import get_language, get_language_from_request, ugettext as _
from aldryn_blog.models import Category, Post
        language = get_language()
        posts = Post.published.filter(Q(language=language) | Q(language__isnull=True))
        return posts.order_by('-publication_start')[:10]

    def item_title(self, item):
        return item.title

    def item_description(self, item):
        return item.lead_in

    def item_pubdate(self, item):
        return datetime.datetime.combine(item.publication_start, datetime.time())


class TagFeed(LatestEntriesFeed):

    def get_object(self, request, tag):
        return tag

    def items(self, obj):
        return Post.published.filter(tags__slug=obj)[:10]


class CategoryFeed(LatestEntriesFeed):

    def get_object(self, request, category):
        language = get_language_from_request(request, check_path=True)
        return Category.objects.language(language).get(slug=category)

    def items(self, obj):

# Path: aldryn_blog/models.py
# class Category(TranslatableModel):
# 
#     translations = TranslatedFields(
#         name=models.CharField(_('Name'), max_length=255),
#         slug=models.SlugField(
#             verbose_name=_('Slug'),
#             max_length=255,
#             blank=True,
#             help_text=_('Auto-generated. Clean it to have it re-created. '
#                         'WARNING! Used in the URL. If changed, the URL will change. ')
#         ),
#         meta={'unique_together': [['slug', 'language_code']]}
#     )
# 
#     ordering = models.IntegerField(_('Ordering'), default=0)
# 
#     objects = CategoryManager()
# 
#     class Meta:
#         verbose_name = _('Category')
#         verbose_name_plural = _('Categories')
#         ordering = ['ordering']
# 
#     def __unicode__(self):
#         return self.lazy_translation_getter('name', str(self.pk))
# 
#     def get_absolute_url(self, language=None):
#         language = language or get_current_language()
#         slug = get_slug_in_language(self, language)
#         with override(language):
#             if slug:
#                 return reverse('aldryn_blog:category-posts', kwargs={'category': slug})
# 
#             # category not translated in given language
#             try:
#                 return reverse('aldryn_blog:latest-posts')
#             except (ImproperlyConfigured, NoReverseMatch):
#                 return '/%s' % language
# 
# class Post(models.Model):
# 
#     title = models.CharField(_('Title'), max_length=255)
#     slug = models.SlugField(
#         verbose_name=_('Slug'),
#         max_length=255,
#         unique=True,
#         blank=True,
#         help_text=_('Used in the URL. If changed, the URL will change. Clean it to have it re-created.')
#     )
#     language = models.CharField(
#         verbose_name=_('language'),
#         max_length=5,
#         null=True,
#         blank=True,
#         choices=settings.LANGUAGES,
#         help_text=_('leave empty to display in all languages')
#     )
#     key_visual = FilerImageField(verbose_name=_('Key Visual'), blank=True, null=True)
#     lead_in = HTMLField(
#         verbose_name=_('Lead-in'),
#         help_text=_('Will be displayed in lists, and at the start of the detail page (in bold)')
#     )
#     content = PlaceholderField('aldryn_blog_post_content', related_name='aldryn_blog_posts')
#     author = models.ForeignKey(to=AUTH_USER_MODEL, verbose_name=_('Author'))
#     coauthors = models.ManyToManyField(
#         to=AUTH_USER_MODEL,
#         verbose_name=_('Co-Authors'),
#         null=True,
#         blank=True,
#         related_name='aldryn_blog_coauthors'
#     )
#     publication_start = models.DateTimeField(
#         verbose_name=_('Published Since'),
#         default=timezone.now,
#         help_text=_('Used in the URL. If changed, the URL will change.')
#     )
#     publication_end = models.DateTimeField(
#         verbose_name=_('Published Until'),
#         null=True,
#         blank=True
#     )
#     category = models.ForeignKey(
#         to=Category,
#         verbose_name=_('Category'),
#         null=True,
#         blank=True
#     )
# 
#     objects = RelatedManager()
#     published = PublishedManager()
#     tags = TaggableManager(blank=True)
#     app_data = AppDataField()
# 
#     def __unicode__(self):
#         return self.title
# 
#     def get_absolute_url(self):
#         kwargs = {
#             'year': self.publication_start.year,
#             'month': self.publication_start.month,
#             'day': self.publication_start.day,
#             'slug': self.slug
#         }
# 
#         if self.language and not getattr(settings, 'ALDRYN_BLOG_SHOW_ALL_LANGUAGES', False):
#             with override(self.language):
#                 return reverse('aldryn_blog:post-detail', kwargs=kwargs)
#         return reverse('aldryn_blog:post-detail', kwargs=kwargs)
# 
#     class Meta:
#         ordering = ['-publication_start']
# 
#     def save(self, **kwargs):
#         if not self.slug:
#             self.slug = slugify(self.title)
#         return super(Post, self).save(**kwargs)
# 
#     def get_author_slug(self):
#         # FIXME: This is a potential performance hogger
#         return get_slug_for_user(self.author)


# Path: aldryn_blog/feeds.py
import datetime
from django.contrib.sites.models import Site
from django.contrib.syndication.views import Feed
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.utils.translation import get_language, get_language_from_request, ugettext as _
from aldryn_blog.models import Category, Post

        language = get_language()
        posts = Post.published.filter(Q(language=language) | Q(language__isnull=True))
        return posts.order_by('-publication_start')[:10]

    def item_title(self, item):
        return item.title

    def item_description(self, item):
        return item.lead_in

    def item_pubdate(self, item):
        return datetime.datetime.combine(item.publication_start, datetime.time())


class TagFeed(LatestEntriesFeed):

    def get_object(self, request, tag):
        return tag

    def items(self, obj):
        return Post.published.filter(tags__slug=obj)[:10]


class CategoryFeed(LatestEntriesFeed):

    def get_object(self, request, category):
        language = get_language_from_request(request, check_path=True)
        return Category.objects.language(language).get(slug=category)

    def items(self, obj):

        return Post.published.filter(category=obj)[:10]