]> git.ipfire.org Git - ipfire.org.git/blob - www/webapp/handlers_news.py
Remove obsolete pakfire CGI scripts.
[ipfire.org.git] / www / webapp / handlers_news.py
1 #!/usr/bin/python
2
3 import tornado.web
4
5 from handlers_base import *
6
7 class NewsIndexHandler(BaseHandler):
8 rss_url = "/news.rss"
9
10 """
11 This handler fetches the content that is show on the news portal.
12 """
13 def get(self):
14 news = self.news.get_latest(limit=5, locale=self.locale)
15
16 return self.render("news.html", news=news)
17
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)
24
25
26 class NewsItemHandler(BaseHandler):
27 rss_url = "/news.rss"
28
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:
40 news.author = author.cn
41 else:
42 _ = self.locale.translate
43 news.author = _("Unknown author")
44
45 return self.render("news-item.html", item=news)
46
47
48 class NewsAuthorHandler(BaseHandler):
49 """
50 This page displays information about the news author.
51 """
52 def get(self, author):
53 author = self.get_account(author)
54 if not author:
55 raise tornado.web.HTTPError(404)
56
57 latest_news = self.news.get_latest(author=author.uid,
58 locale=self.locale, limit=10)
59
60 self.render("news-author.html",
61 author=author, latest_news=latest_news)