Escaline

Sign in or create your account | Project List | Help

Escaline Git Source Tree

Root/escaline/feeds.py

1#!/usr/bin/python
2# coding=utf8
3#
4# feeds.py
5#
6# Copyright 2008 Antoine Millet <antoine@inaps.org>
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21# MA 02110-1301, USA.
22
23from django.core.urlresolvers import reverse
24from django.contrib.syndication.feeds import Feed
25
26from commands.models import Command
27from news.models import Post
28
29class LatestCommands(Feed):
30    title = 'Dernières commandes sur Escaline'
31    link = '/'
32    description = 'Toutes les dernières commandes d\'Escaline en live !'
33    
34    def items(self):
35        return Command.objects.filter(is_enabled=True, type__in='PCF').order_by('-date_of_creation')[:10]
36    
37    def item_link(self, item):
38        return reverse('man_url', args=(item.name,))
39        
40class LatestNews(Feed):
41    title = 'Dernières nouvelles sur Escaline'
42    link = '/'
43    description = 'Toutes les dernières nouvelles d\'Escaline en live !'
44    
45    def items(self):
46        return Post.objects.filter(is_published=True).order_by('-date')[:10]
47    
48    def item_link(self, item):
49        return item.get_permalink()
50
51FEEDS = {
52    'commands': LatestCommands,
53    'news': LatestNews,
54}
55

Archive Download this file