From 9d7e697aa1bb8d24d9a9fbc6472cb1af8c4f73f5 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 22 Jul 2013 12:03:02 +0200 Subject: [PATCH] Add wishlist to front page. --- static/css/style.css | 13 ++++ templates/index.html | 83 ++++++++++++++++++------ translations/de_DE/LC_MESSAGES/webapp.po | 36 +++++++--- translations/webapp.pot | 32 +++++++-- webapp/backend/wishlist.py | 34 ++++++++++ webapp/handlers.py | 6 +- 6 files changed, 170 insertions(+), 34 deletions(-) diff --git a/static/css/style.css b/static/css/style.css index 1a5af1c..a15ea4a 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -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%; +} diff --git a/templates/index.html b/templates/index.html index ff40cd9..5f2113b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -170,6 +170,43 @@
+ {% if wishlist_items %} +

+ {{ _("IPFire Wishlist") }} + {{ _("The IPFire Crowdfunding Platform") }} +

+ + + {% for item in wishlist_items %} + + + + {% end %} +
+ {% if item.is_new() %} + {{ _("NEW") }} + {% elif item.remaining_days <= 10 %} + + {{ _("one day left", "%(num)s days left", item.remaining_days) % { "num" : item.remaining_days } }} + + {% else %} + + {{ _("%d%% funded") % item.percentage }} + + {% end %} + + {{ item.title }} + +
+ +
+
+
+
+ +
+ {% end %} +
+ + +
+ +
+

{{ _("IPFire Hardware Appliances & Consulting") }} {{ _("by Lightning Wire Labs") }}

-
- - {% if lang == "de" %} -

- Lightning Wire Labs bietet mit IPFire vorinstallierte Hardware-Appliances an. - Dazu bieten sie professionellen Service & Support durch qualifizierte Consultants. -

- {% else %} -

- Lightning Wire Labs offers hardware appliances that come pre-installed - with the latest version of IPFire. - They also provide professional services & support through their certified consultants. -

- {% end %} +
+
+ {% if lang == "de" %} +

+ Lightning Wire Labs bietet mit IPFire vorinstallierte Hardware-Appliances an. + Dazu bieten sie professionellen Service & Support durch qualifizierte Consultants. +

+ {% else %} +

+ Lightning Wire Labs offers hardware appliances that come pre-installed + with the latest version of IPFire. + They also provide professional services & support through their certified consultants. +

+ {% end %} +
-
+
+ + Appliance Eco + +
+

diff --git a/translations/de_DE/LC_MESSAGES/webapp.po b/translations/de_DE/LC_MESSAGES/webapp.po index cb32b88..8423c65 100644 --- a/translations/de_DE/LC_MESSAGES/webapp.po +++ b/translations/de_DE/LC_MESSAGES/webapp.po @@ -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 \n" "Language-Team: LANGUAGE \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" diff --git a/translations/webapp.pot b/translations/webapp.pot index ced509c..d712f05 100644 --- a/translations/webapp.pot +++ b/translations/webapp.pot @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/webapp/backend/wishlist.py b/webapp/backend/wishlist.py index a45f3a7..43b8f2f 100644 --- a/webapp/backend/wishlist.py +++ b/webapp/backend/wishlist.py @@ -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 diff --git a/webapp/handlers.py b/webapp/handlers.py index ba8fe1a..33804ac 100644 --- a/webapp/handlers.py +++ b/webapp/handlers.py @@ -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): -- 2.39.2