]>
Commit | Line | Data |
---|---|---|
940227cb MT |
1 | #!/usr/bin/python |
2 | ||
3 | import tornado.web | |
4 | ||
5 | from handlers_base import * | |
6 | ||
940227cb | 7 | class NewsIndexHandler(BaseHandler): |
de683d7c MT |
8 | rss_url = "/news.rss" |
9 | ||
940227cb MT |
10 | """ |
11 | This handler fetches the content that is show on the news portal. | |
12 | """ | |
13 | def get(self): | |
7771acea | 14 | news = self.news.get_latest(limit=5, locale=self.locale) |
940227cb | 15 | |
7771acea | 16 | return self.render("news.html", news=news) |
940227cb | 17 | |
7771acea MT |
18 | |
19 | class NewsYearHandler(NewsIndexHandler): | |
20 | def get(self, year): | |
21 | news = self.news.get_by_year(year, locale=self.locale) | |
22 | ||
23 | return self.render("news-year.html", news=news, selected_year=year) | |
940227cb MT |
24 | |
25 | ||
26 | class NewsItemHandler(BaseHandler): | |
de683d7c MT |
27 | rss_url = "/news.rss" |
28 | ||
940227cb MT |
29 | """ |
30 | This handler displays a whole page full of a single news item. | |
31 | """ | |
32 | def get(self, slug): | |
33 | news = self.news.get_by_slug(slug) | |
34 | if not news: | |
35 | raise tornado.web.HTTPError(404) | |
36 | ||
37 | # Find the name of the author | |
38 | author = self.get_account(news.author_id) | |
39 | if author: | |
2fed2438 | 40 | news.author = author.name |
940227cb MT |
41 | else: |
42 | _ = self.locale.translate | |
43 | news.author = _("Unknown author") | |
44 | ||
45 | return self.render("news-item.html", item=news) |