From 2fed2438f757a661e9a123aeb748b2fecd27597a Mon Sep 17 00:00:00 2001
From: Michael Tremer
Date: Sun, 22 Feb 2015 23:52:52 +0100
Subject: [PATCH] Add the release announcement to the download page
---
templates/modules/news-item.html | 16 ++++++-------
templates/modules/release-item.html | 6 +++++
templates/news-author.html | 37 -----------------------------
webapp/__init__.py | 1 -
webapp/backend/releases.py | 11 +++++++++
webapp/handlers_news.py | 18 +-------------
webapp/ui_modules.py | 2 +-
7 files changed, 26 insertions(+), 65 deletions(-)
delete mode 100644 templates/news-author.html
diff --git a/templates/modules/news-item.html b/templates/modules/news-item.html
index 7fbd41be..be4c3737 100644
--- a/templates/modules/news-item.html
+++ b/templates/modules/news-item.html
@@ -5,18 +5,16 @@
{% if announcement %}
{{ _("Announcement") }}:
{% end %}
- {{ item.title }}
+ {{ item.title }}
{% end %}
{% raw item.text %}
-
-
-
-
-
- {{ item.author }} -
- {{ locale.format_date(item.published, full_format=True) }}
-
+
+
+
+
+ {{ _("Published by %(author)s, %(time)s") % { "author" : item.author, "time" : locale.format_date(item.published, full_format=True) } }}
+
diff --git a/templates/modules/release-item.html b/templates/modules/release-item.html
index 6aa0d4d5..64792b14 100644
--- a/templates/modules/release-item.html
+++ b/templates/modules/release-item.html
@@ -75,6 +75,12 @@
{{ _("Magnet link") }},
{{ _("Torrent download") }}
+
+ {% if release.news %}
+
{{ _("There are no downloads available for this release.") }}
diff --git a/templates/news-author.html b/templates/news-author.html
deleted file mode 100644
index de38035a..00000000
--- a/templates/news-author.html
+++ /dev/null
@@ -1,37 +0,0 @@
-{% extends "planet-user.html" %}
-
-{% block title %}{{ author.cn }}{% end block %}
-
-{% block bodyA %}
-
-
-
-
- {% if lang == "de" %}
- XXX GERMAN TEXT MISSING
- {% else %}
-
- This is a list of all announcements made by {{ author.cn }}
- in reverse chronological order.
-
- {% end %}
-
-
-
- {% for news in latest_news %}
-
-
- {{ news.title }}
- |
-
- {{ locale.format_date(news.date, full_format=True) }}
- |
-
- {% end %}
-
-
-
-
-{% end block %}
diff --git a/webapp/__init__.py b/webapp/__init__.py
index 752b3b4d..87cebb2a 100644
--- a/webapp/__init__.py
+++ b/webapp/__init__.py
@@ -92,7 +92,6 @@ class Application(tornado.web.Application):
(r"/news", NewsIndexHandler),
(r"/news/year/([0-9]*)", NewsYearHandler),
(r"/news/(.*)", NewsItemHandler),
- (r"/author/(.*)", NewsAuthorHandler),
# Download sites
(r"/download", tornado.web.RedirectHandler, { "url" : "http://downloads.ipfire.org/latest" }),
diff --git a/webapp/backend/releases.py b/webapp/backend/releases.py
index ff482c02..d7f5433f 100644
--- a/webapp/backend/releases.py
+++ b/webapp/backend/releases.py
@@ -376,6 +376,17 @@ class Release(Object):
def netboot_initrd(self):
return "http://downloads.ipfire.org/%s/images/instroot" % self.path
+ @property
+ def news_id(self):
+ return self.__data.news_id
+
+ @property
+ def news(self):
+ if not hasattr(self, "_news"):
+ self._news = self.backend.news.get(self.news_id)
+
+ return self._news
+
class Releases(Object):
def get_by_id(self, id):
diff --git a/webapp/handlers_news.py b/webapp/handlers_news.py
index 51194fc4..18fd7f70 100644
--- a/webapp/handlers_news.py
+++ b/webapp/handlers_news.py
@@ -37,25 +37,9 @@ class NewsItemHandler(BaseHandler):
# Find the name of the author
author = self.get_account(news.author_id)
if author:
- news.author = author.cn
+ news.author = author.name
else:
_ = self.locale.translate
news.author = _("Unknown author")
return self.render("news-item.html", item=news)
-
-
-class NewsAuthorHandler(BaseHandler):
- """
- This page displays information about the news author.
- """
- def get(self, author):
- author = self.get_account(author)
- if not author:
- raise tornado.web.HTTPError(404)
-
- latest_news = self.news.get_latest(author=author.uid,
- locale=self.locale, limit=10)
-
- self.render("news-author.html",
- author=author, latest_news=latest_news)
diff --git a/webapp/ui_modules.py b/webapp/ui_modules.py
index 1a0eb769..c1de1d0c 100644
--- a/webapp/ui_modules.py
+++ b/webapp/ui_modules.py
@@ -201,7 +201,7 @@ class NewsItemModule(UIModule):
# Get name of author
author = self.accounts.find(author)
if author:
- return author.cn
+ return author.name
else:
_ = self.locale.translate
return _("Unknown author")
--
2.47.3