Add wishes to the donation page.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 10 May 2014 18:46:49 +0000 (20:46 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 10 May 2014 18:46:49 +0000 (20:46 +0200)
templates/donate.html [moved from templates/static/donation.html with 89% similarity]
templates/index.html
templates/modules/donation-box.html
templates/modules/wishlist-items.html [new file with mode: 0644]
webapp/__init__.py
webapp/handlers.py
webapp/ui_modules.py

similarity index 89%
rename from templates/static/donation.html
rename to templates/donate.html
index e3bf56a..8302fac 100644 (file)
@@ -1,4 +1,4 @@
-{% extends "../base-1.html" %}
+{% extends "base-1.html" %}
                
 {% block title %}{{ _("Donate") }}{% end block %}
 
 
        <div class="row">
                <div class="col-lg-10 col-md-10 col-lg-offset-1">
-                       {% module DonationBox() %}
-
-                       <p class="ac">
-                               <strong>{{ _("Did you know...?") }}</strong>
-
-                               {% if lang == "de" %}
-                                       Du kannst die Implementierung deiner bevorzugten Funktion mit Hilfe einer Spende auf der
-                                       <a href="http://wishlist.ipfire.org/">IPFire Wunschliste</a> unterst├╝tzen!
-                               {% else %}
-                                       You can support the implementation of your favorite feature on the
-                                       <a href="http://wishlist.ipfire.org/">IPFire wishlist</a>!
-                               {% end %}
-                       </p>
+                       {% module DonationBox(show_wishlist_items=True) %}
                </div>
        </div>
 
index b4b3745..63f3902 100644 (file)
                                                        <small>{{ _("The IPFire Crowdfunding Platform") }}</small>
                                                </h3>
 
-                                               <table class="table-wishlist-widget">
-                                                       {% for item in wishlist_items %}
-                                                               <tr>
-                                                                       <td>
-                                                                               {% if item.is_new() %}
-                                                                                       <span class="label label-success pull-right">{{ _("NEW") }}</span>
-                                                                               {% elif item.remaining_days and item.remaining_days <= 10 %}
-                                                                                       <span class="pull-right">
-                                                                                               {{ _("one day left", "%(num)s days left", item.remaining_days) % { "num" : item.remaining_days } }}
-                                                                                       </span>
-                                                                               {% else %}
-                                                                                       <span class="pull-right">
-                                                                                               {{ _("%d%% funded") % item.percentage }}
-                                                                                       </span>
-                                                                               {% end %}
-
-                                                                               <a href="http://wishlist.ipfire.org/wish/{{ item.slug }}" target="_blank">{{ item.title }}</a>
-
-                                                                               <br class="separator-small">
-
-                                                                               <div class="progress progress-small">
-                                                                                       <div class="progress-bar progress-{{ item.progressbar_colour }}" style="width: {{ "%.2f%%" % item.percentage_bar }};"></div>
-                                                                               </div>
-                                                                       </td>
-                                                               </tr>
-                                                       {% end %}
-                                               </table>
+                                               {% module WishlistItems(wishlist_items) %}
                                        {% end %}
                                </div>
 
index 0385916..44ee78c 100644 (file)
                        </p>
                </div>
        </div>
+
+       {% if wishlist_items %}
+               <hr>
+
+               <div class="row">
+                       <div class="col-md-12">
+                               <p class="ac">
+                                       <strong>{{ _("Did you know...?") }}</strong>
+
+                                       {% if lang == "de" %}
+                                               Du kannst die Implementierung deiner bevorzugten Funktion mit Hilfe einer Spende auf der
+                                               <a href="http://wishlist.ipfire.org/">IPFire Wunschliste</a> unterst├╝tzen!
+                                       {% else %}
+                                               You can support the implementation of your favorite feature on the
+                                               <a href="http://wishlist.ipfire.org/">IPFire wishlist</a>!
+                                       {% end %}
+                               </p>
+                               <br class="separator">
+
+                               {% module WishlistItems(wishlist_items) %}
+                       </div>
+               </div>
+       {% end %}
 </div>
diff --git a/templates/modules/wishlist-items.html b/templates/modules/wishlist-items.html
new file mode 100644 (file)
index 0000000..0338383
--- /dev/null
@@ -0,0 +1,27 @@
+<table class="table-wishlist-widget">
+       {% for item in wishlist_items %}
+               <tr>
+                       <td>
+                               {% if item.is_new() %}
+                                       <span class="label label-success pull-right">{{ _("NEW") }}</span>
+                               {% elif item.remaining_days and item.remaining_days <= 10 %}
+                                       <span class="pull-right">
+                                               {{ _("one day left", "%(num)s days left", item.remaining_days) % { "num" : item.remaining_days } }}
+                                       </span>
+                               {% else %}
+                                       <span class="pull-right">
+                                               {{ _("%d%% funded") % item.percentage }}
+                                       </span>
+                               {% end %}
+
+                               <a href="http://wishlist.ipfire.org/wish/{{ item.slug }}" target="_blank">{{ item.title }}</a>
+
+                               <br class="separator-small">
+
+                               <div class="progress progress-small">
+                                       <div class="progress-bar progress-{{ item.progressbar_colour }}" style="width: {{ "%.2f%%" % item.percentage_bar }};"></div>
+                               </div>
+                       </td>
+               </tr>
+       {% end %}
+</table>
index 0c6bd6e..dc91f33 100644 (file)
@@ -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),
index ea46985..3e497a8 100644 (file)
@@ -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)
index da69711..7433134 100644 (file)
@@ -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)