1 # -*- coding: utf-8 -*-
2 # This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.contrib.syndication.views import Feed
6 from django.core.urlresolvers import reverse
7 from django.shortcuts import get_object_or_404
8 from django.utils.translation import ugettext as _, string_concat
10 from migdal.models import Category
11 from migdal import app_settings
14 class EntriesFeed(Feed):
15 def get_object(self, request, type_db=None, category_slug=None):
16 lang = request.LANGUAGE_CODE
18 category = get_object_or_404(Category, **{'slug_%s' % lang: category_slug})
22 entry_type = app_settings.TYPES_DICT[type_db]
25 return {'entry_type': entry_type, 'category': category}
28 t = "Prawo kultury, " + _("latest") + " "
30 t += unicode(obj['entry_type'].slug)
34 t += " " + _("in category") + " " + obj['category'].title
39 return reverse('migdal_category', args=[obj['category'].slug])
41 return reverse('migdal_entry_list_%s' % obj['entry_type'].db)
42 return reverse('migdal_main')
45 return api.entry_list(for_feed=True, **obj)
47 def item_title(self, item):
50 def item_description(self, item):
51 image = item.image.url if item.image else "/static/img/square-logo.png"
52 return string_concat("<img src='%s'/>" % image, item.lead)
54 def item_pubdate(self, item):
55 return item.published_at