]> git.ipfire.org Git - people/shoehn/ipfire.org.git/commitdiff
Add wishlist to front page.
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 22 Jul 2013 10:03:02 +0000 (12:03 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 22 Jul 2013 10:03:02 +0000 (12:03 +0200)
static/css/style.css
templates/index.html
translations/de_DE/LC_MESSAGES/webapp.po
translations/webapp.pot
webapp/backend/wishlist.py
webapp/handlers.py

index 1a5af1c3b6ba332493ea6479edbcb4071155d6fb..a15ea4a4dfa3e80f3a4a00c4d29cfc3f24214395 100644 (file)
@@ -279,6 +279,11 @@ section > ul li {
        margin-bottom: 100px;
 }
 
+.progress-small {
+       margin-top: 6px;
+       height: 6px;
+}
+
 @media (min-width: 768px) and (max-width: 979px) {
        body {
                padding-top: 0;
@@ -393,3 +398,11 @@ section > ul li {
 .well-white {
        background-color: white;
 }
+
+.table-wishlist-widget {
+       width: 100%;
+}
+
+.table-wishlist-widget td.progress-bar {
+       width: 40%;
+}
index ff40cd94e1077227faba23b098aba6c3001a72be..5f2113b8b5a7b63525aead335ddd2a47ae35af9c 100644 (file)
 
                                <hr>
 
+                               {% if wishlist_items %}
+                                       <h4>
+                                               <a href="http://wishlist.ipfire.org">{{ _("IPFire Wishlist") }}</a>
+                                               <small>{{ _("The IPFire Crowdfunding Platform") }}</small>
+                                       </h4>
+
+                                       <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 <= 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="bar {{ item.progressbar_colour }}" style="width: {{ "%.2f%%" % item.percentage_bar }};"></div>
+                                                                       </div>
+                                                               </td>
+                                                       </tr>
+                                               {% end %}
+                                       </table>
+
+                                       <hr>
+                               {% end %}
+
                                <div class="row-fluid">
                                        <div class="span10">
                                                <a href="/donate"><strong>{{ _("Please support us with your donation!") }}</strong></a>
                                        </div>
                                </div>
                        </div>
+               </div>
+       </div>
 
+       <br class="separator">
+
+       <div class="row">
+               <div class="span8 offset2">
                        <div class="well well-white">
                                <h4>
                                        {{ _("IPFire Hardware Appliances & Consulting") }} <small>{{ _("by Lightning Wire Labs") }}</small>
                                </h4>
 
-                               <br>
-
-                               {% if lang == "de" %}
-                                       <p>
-                                               Lightning Wire Labs bietet mit IPFire vorinstallierte Hardware-Appliances an.
-                                               Dazu bieten sie professionellen Service &amp; Support durch qualifizierte Consultants.
-                                       </p>
-                               {% else %}
-                                       <p>
-                                               Lightning Wire Labs offers hardware appliances that come pre-installed
-                                               with the latest version of IPFire.
-                                               They also provide professional services &amp; support through their certified consultants.
-                                       </p>
-                               {% end %}
+                               <div class="row-fluid">
+                                       <div class="span6">
+                                               {% if lang == "de" %}
+                                                       <p>
+                                                               Lightning Wire Labs bietet mit IPFire vorinstallierte Hardware-Appliances an.
+                                                               Dazu bieten sie professionellen Service &amp; Support durch qualifizierte Consultants.
+                                                       </p>
+                                               {% else %}
+                                                       <p>
+                                                               Lightning Wire Labs offers hardware appliances that come pre-installed
+                                                               with the latest version of IPFire.
+                                                               They also provide professional services &amp; support through their certified consultants.
+                                                       </p>
+                                               {% end %}
+                                       </div>
 
-                               <hr>
+                                       <div class="span6 ac">
+                                               <a href="http://www.lightningwirelabs.com/products/ipfire/appliances" target="_blank">
+                                                       <img src="{{ static_url("images/LWL/appliance-eco.jpg") }}" alt="Appliance Eco">
+                                               </a>
+                                       </div>
+                               </div>
 
                                <div class="ac">
                                        <a href="http://www.lightningwirelabs.com/products/ipfire/appliances" target="_blank">
                                                <img src="{{ static_url("images/LWL/appliance-pro.jpg") }}" alt="Appliance Professional">
                                        </a>
-                                       <br>
-                                       <a href="http://www.lightningwirelabs.com/products/ipfire/appliances" target="_blank">
-                                               <img src="{{ static_url("images/LWL/appliance-eco.jpg") }}" alt="Appliance Eco">
-                                       </a>
                                </div>
 
                                <hr>
index cb32b883060576e5e97900cadb9305325b1bf666..8423c65db7b17cde6e4e58f0db2a4e529533acdf 100644 (file)
@@ -7,15 +7,15 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-07-22 10:42+0200\n"
-"PO-Revision-Date: 2013-02-19 12:38+0100\n"
+"POT-Creation-Date: 2013-07-22 11:43+0200\n"
+"PO-Revision-Date: 2013-07-22 11:44+0100\n"
 "Last-Translator: Michael Tremer <michael.tremer@ipfire.org>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
-"Language: \n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=n != 1;\n"
+"X-Generator: Poedit 1.5.4\n"
 
 #: webapp/handlers_news.py:43 webapp/ui_modules.py:76
 msgid "Unknown author"
@@ -86,7 +86,7 @@ msgstr "Dezember"
 msgid "%s to %s"
 msgstr "%s nach %s"
 
-#: webapp/backend/wishlist.py:153
+#: webapp/backend/wishlist.py:187
 msgid "Checkout this crowdfunding wish from #ipfire:"
 msgstr ""
 
@@ -213,7 +213,7 @@ msgstr "Älter"
 msgid "Newer"
 msgstr "Neuer"
 
-#: templates/wishlist/base.html:6
+#: templates/wishlist/base.html:6 templates/index.html:175
 msgid "IPFire Wishlist"
 msgstr "IPFire Wunschliste"
 
@@ -1546,15 +1546,35 @@ msgstr "Mehr erfahren"
 msgid "What's new?"
 msgstr "Neuigkeiten"
 
-#: templates/index.html:175
+#: templates/index.html:176
+msgid "The IPFire Crowdfunding Platform"
+msgstr "Die IPFire Crowdfunding-Plattform"
+
+#: templates/index.html:184
+msgid "NEW"
+msgstr "NEU"
+
+#: templates/index.html:187
+#, python-format
+msgid "one day left"
+msgid_plural "%(num)s days left"
+msgstr[0] "noch ein Tag"
+msgstr[1] "noch %(num)s Tage"
+
+#: templates/index.html:191
+#, python-format
+msgid "%d%% funded"
+msgstr "%d%% gesammelt"
+
+#: templates/index.html:212
 msgid "Please support us with your donation!"
 msgstr "Unterstütze dieses Projekt mit deiner Spende!"
 
-#: templates/index.html:189
+#: templates/index.html:232
 msgid "IPFire Hardware Appliances & Consulting"
 msgstr "IPFire Hardware Appliances & Consulting"
 
-#: templates/index.html:189
+#: templates/index.html:232
 msgid "by Lightning Wire Labs"
 msgstr "von Lightning Wire Labs"
 
index ced509c99608ccc5a242d4d2fb41823fab0fd665..d712f0589ff1601f3eea199d29896b52b62c3bd6 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-07-22 10:42+0200\n"
+"POT-Creation-Date: 2013-07-22 11:43+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -87,7 +87,7 @@ msgstr ""
 msgid "%s to %s"
 msgstr ""
 
-#: webapp/backend/wishlist.py:153
+#: webapp/backend/wishlist.py:187
 msgid "Checkout this crowdfunding wish from #ipfire:"
 msgstr ""
 
@@ -212,7 +212,7 @@ msgstr ""
 msgid "Newer"
 msgstr ""
 
-#: templates/wishlist/base.html:6
+#: templates/wishlist/base.html:6 templates/index.html:175
 msgid "IPFire Wishlist"
 msgstr ""
 
@@ -1535,15 +1535,35 @@ msgstr ""
 msgid "What's new?"
 msgstr ""
 
-#: templates/index.html:175
+#: templates/index.html:176
+msgid "The IPFire Crowdfunding Platform"
+msgstr ""
+
+#: templates/index.html:184
+msgid "NEW"
+msgstr ""
+
+#: templates/index.html:187
+#, python-format
+msgid "one day left"
+msgid_plural "%(num)s days left"
+msgstr[0] ""
+msgstr[1] ""
+
+#: templates/index.html:191
+#, python-format
+msgid "%d%% funded"
+msgstr ""
+
+#: templates/index.html:212
 msgid "Please support us with your donation!"
 msgstr ""
 
-#: templates/index.html:189
+#: templates/index.html:232
 msgid "IPFire Hardware Appliances & Consulting"
 msgstr ""
 
-#: templates/index.html:189
+#: templates/index.html:232
 msgid "by Lightning Wire Labs"
 msgstr ""
 
index a45f3a7ce68ad06f35dce3137e596b5f28575de4..43b8f2f8ba2f5a7c133b9cba78a8388874336d2c 100644 (file)
@@ -50,6 +50,17 @@ class Wishlist(object):
 
                return self.get_all_by_query(query, *args)
 
+       def get_hot_wishes(self, limit=3):
+               query = "SELECT * FROM wishlist \
+                       WHERE status = %s AND DATE(NOW()) BETWEEN date_start AND date_end AND ( \
+                               ((UNIX_TIMESTAMP() - UNIX_TIMESTAMP(date_start)) <= 864000) \
+                               OR ((UNIX_TIMESTAMP(date_end) - UNIX_TIMESTAMP()) <= 1209600) \
+                               OR ((donated / goal) >= 0.9) \
+                               OR (goal >= 3000) \
+                       ) ORDER BY prio ASC, date_end ASC LIMIT %s"
+
+               return self.get_all_by_query(query, "running", limit)
+
 
 class Wish(object):
        def __init__(self, wishlist, id, data=None):
@@ -58,6 +69,9 @@ class Wish(object):
 
                self.__data = data
 
+       def __repr__(self):
+               return "<%s %s>" % (self.__class__.__name__, self.title)
+
        def __cmp__(self, other):
                return cmp(self.date_end, other.date_end)
 
@@ -77,6 +91,13 @@ class Wish(object):
        def title(self):
                return self.data.title
 
+       @property
+       def title_short(self):
+               if len(self.title) > 30:
+                       return "%s..." % self.title[:30]
+
+               return self.title
+
        @property
        def slug(self):
                return self.data.slug
@@ -108,6 +129,16 @@ class Wish(object):
 
                return self.percentage
 
+       @property
+       def progressbar_colour(self):
+               if self.is_new():
+                       return "bar-success"
+
+               if self.percentage >= 90:
+                       return "bar-danger"
+
+               return "bar-warning"
+
        @property
        def status(self):
                if self.data.status == "running" and not self.running:
@@ -146,6 +177,9 @@ class Wish(object):
                remaining = self.date_end - today
                return remaining.days
 
+       def is_new(self):
+               return self.running_days <= 10
+
        def get_tweet(self, locale):
                _ = locale.translate
 
index ba8fe1abc859ae7f620afb2b5541d1fc4fa1ac31..33804ac3ee708a9bb209c23e06e3baf3bcb7d330 100644 (file)
@@ -65,8 +65,12 @@ class IndexHandler(BaseHandler):
                # Get the latest release.
                latest_release = self.releases.get_latest()
 
+               # Interesting items from the wishlist.
+               wishlist_items = self.wishlist.get_hot_wishes()
+
                return self.render("index.html", latest_news=latest_news,
-                       planet_posts=planet_posts, latest_release=latest_release)
+                       planet_posts=planet_posts, latest_release=latest_release,
+                       wishlist_items=wishlist_items)
 
 
 class StaticHandler(BaseHandler):