From e64ce07e574aef4f759a4ae28277036551629b21 Mon Sep 17 00:00:00 2001
From: Michael Tremer
Date: Sat, 10 May 2014 20:46:49 +0200
Subject: [PATCH] Add wishes to the donation page.
---
.../{static/donation.html => donate.html} | 16 ++---------
templates/index.html | 28 +------------------
templates/modules/donation-box.html | 23 +++++++++++++++
templates/modules/wishlist-items.html | 27 ++++++++++++++++++
webapp/__init__.py | 7 +++--
webapp/handlers.py | 8 ++++++
webapp/ui_modules.py | 19 +++++++++++--
7 files changed, 83 insertions(+), 45 deletions(-)
rename templates/{static/donation.html => donate.html} (89%)
create mode 100644 templates/modules/wishlist-items.html
diff --git a/templates/static/donation.html b/templates/donate.html
similarity index 89%
rename from templates/static/donation.html
rename to templates/donate.html
index e3bf56a..8302fac 100644
--- a/templates/static/donation.html
+++ b/templates/donate.html
@@ -1,4 +1,4 @@
-{% extends "../base-1.html" %}
+{% extends "base-1.html" %}
{% block title %}{{ _("Donate") }}{% end block %}
@@ -62,19 +62,7 @@
- {% module DonationBox() %}
-
-
- {{ _("Did you know...?") }}
-
- {% if lang == "de" %}
- Du kannst die Implementierung deiner bevorzugten Funktion mit Hilfe einer Spende auf der
- IPFire Wunschliste unterstützen!
- {% else %}
- You can support the implementation of your favorite feature on the
- IPFire wishlist!
- {% end %}
-
+ {% module DonationBox(show_wishlist_items=True) %}
diff --git a/templates/index.html b/templates/index.html
index b4b3745..63f3902 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -191,33 +191,7 @@
{{ _("The IPFire Crowdfunding Platform") }}
-
+ {% module WishlistItems(wishlist_items) %}
{% end %}
diff --git a/templates/modules/donation-box.html b/templates/modules/donation-box.html
index 0385916..44ee78c 100644
--- a/templates/modules/donation-box.html
+++ b/templates/modules/donation-box.html
@@ -88,4 +88,27 @@
+
+ {% if wishlist_items %}
+
+
+
+
+
+ {{ _("Did you know...?") }}
+
+ {% if lang == "de" %}
+ Du kannst die Implementierung deiner bevorzugten Funktion mit Hilfe einer Spende auf der
+ IPFire Wunschliste unterstützen!
+ {% else %}
+ You can support the implementation of your favorite feature on the
+ IPFire wishlist!
+ {% end %}
+
+
+
+ {% module WishlistItems(wishlist_items) %}
+
+
+ {% end %}
diff --git a/templates/modules/wishlist-items.html b/templates/modules/wishlist-items.html
new file mode 100644
index 0000000..0338383
--- /dev/null
+++ b/templates/modules/wishlist-items.html
@@ -0,0 +1,27 @@
+
diff --git a/webapp/__init__.py b/webapp/__init__.py
index 0c6bd6e..dc91f33 100644
--- a/webapp/__init__.py
+++ b/webapp/__init__.py
@@ -60,6 +60,7 @@ class Application(tornado.web.Application):
"TrackerPeerList" : TrackerPeerListModule,
"Wish" : WishModule,
"Wishlist" : WishlistModule,
+ "WishlistItems" : WishlistItemsModule,
},
xsrf_cookies = True,
)
@@ -95,7 +96,9 @@ class Application(tornado.web.Application):
(r"/support", tornado.web.RedirectHandler, { "url" : "/getinvolved" }),
(r"/features/.*", tornado.web.RedirectHandler, { "url" : "/features" }),
- (r"/donate", tornado.web.RedirectHandler, { "url" : "/donation" }),
+ # Donate
+ (r"/donate", DonateHandler),
+ (r"/donation", tornado.web.RedirectHandler, { "url" : "/donate" }),
# RSS feed
(r"/news.rss", RSSNewsHandler),
@@ -202,7 +205,7 @@ class Application(tornado.web.Application):
] + static_handlers)
# wishlist.ipfire.org
- self.add_handlers(r"wishlist\.ipfire\.org", [
+ self.add_handlers(r"wishlist(\.dev)?\.ipfire\.org", [
(r"/", WishlistIndexHandler),
(r"/closed", WishlistClosedHandler),
(r"/wish/(.*)/donate", WishDonateHandler),
diff --git a/webapp/handlers.py b/webapp/handlers.py
index ea46985..3e497a8 100644
--- a/webapp/handlers.py
+++ b/webapp/handlers.py
@@ -120,3 +120,11 @@ class GeoIPHandler(BaseHandler):
mirrors = self.mirrors.get_for_location(peer)
self.render("geoip/index.html", addr=addr, peer=peer, mirrors=mirrors)
+
+
+class DonateHandler(BaseHandler):
+ def get(self):
+ # Interesting items from the wishlist.
+ wishlist_items = self.wishlist.get_hot_wishes()
+
+ self.render("donate.html", wishlist_items=wishlist_items)
diff --git a/webapp/ui_modules.py b/webapp/ui_modules.py
index da69711..7433134 100644
--- a/webapp/ui_modules.py
+++ b/webapp/ui_modules.py
@@ -51,6 +51,10 @@ class UIModule(tornado.web.UIModule):
def planet(self):
return self.handler.planet
+ @property
+ def wishlist(self):
+ return self.handler.wishlist
+
class AdvertisementModule(UIModule):
def render(self, where):
@@ -359,10 +363,21 @@ class WishModule(UIModule):
wish=wish, short=short, progress_bar=progress_bar)
+class WishlistItemsModule(UIModule):
+ def render(self, wishlist_items):
+ return self.render_string("modules/wishlist-items.html",
+ wishlist_items=wishlist_items)
+
+
class DonationBoxModule(UIModule):
- def render(self, reason_for_transfer=None):
+ def render(self, reason_for_transfer=None, show_wishlist_items=False):
if reason_for_transfer:
reason_for_transfer = "IPFire.org - %s" % reason_for_transfer
+ # Interesting items from the wishlist.
+ wishlist_items = []
+ if show_wishlist_items:
+ wishlist_items = self.wishlist.get_hot_wishes()
+
return self.render_string("modules/donation-box.html",
- reason_for_transfer=reason_for_transfer)
+ reason_for_transfer=reason_for_transfer, wishlist_items=wishlist_items)
--
2.39.2