]> git.ipfire.org Git - people/shoehn/ipfire.org.git/commitdiff
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 e3bf56a195065ba2c36603222a3686137a5c209c..8302face92eb0b4454feb92dd4109fad6abe612d 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 b4b3745466d5b4741b86304d1a3da5056593d9ef..63f3902201bca42f231fa47a43ee122f70dbe71c 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 0385916b7e88279d9be479d8c3a240ff24ef7390..44ee78c69dd979f1b4eba0b69af0d81223166a3d 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 0c6bd6e6ba8c6284c7e99df91060a45abef19c04..dc91f33f08b4435fa2118bdca5bc3da0a2a1a0d8 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 ea46985b191fd5dcd54ccb18e0727e2fa0339cc6..3e497a8c7d893ae0fe1e45d9f87ef7d749d62d6e 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 da69711c11013b866eb3b6a3f07d44c1ce7c68ed..7433134af7953ccf31143f8367f5cbd9e42bd411 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)