From: Michael Tremer Date: Sat, 2 Feb 2013 17:29:49 +0000 (+0100) Subject: wishlist: Show ended fundings. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1bf8d4826c4d2cd15d0a4c7c761082ba93962f37;p=ipfire.org.git wishlist: Show ended fundings. --- diff --git a/www/templates/wishlist/closed.html b/www/templates/wishlist/closed.html new file mode 100644 index 00000000..45f0857c --- /dev/null +++ b/www/templates/wishlist/closed.html @@ -0,0 +1,55 @@ +{% extends "../base-1.html" %} + +{% block title %}{{ _("Closed wishes") }}{% end block %} + +{% block body %} + + + {% if lang == "de" %} +

+ Auf dieser Seite finden sich bereits ausgelaufene Sammlungen. +

+ {% else %} +

+ On this page, you will find all fundings that have already ended. +

+ {% end %} + +
+ + {% if wishes %} + {{ modules.Wishlist(wishes) }} + +
+ + + {% end %} +{% end %} diff --git a/www/templates/wishlist/index.html b/www/templates/wishlist/index.html index 453b6b0f..daf86cea 100644 --- a/www/templates/wishlist/index.html +++ b/www/templates/wishlist/index.html @@ -38,14 +38,14 @@ {% if wishes %} {{ modules.Wishlist(wishes) }} {% else %} -
+
{% if lang == "de" %} - Es tut uns Leid! + Es tut uns Leid!
Derzeit finden keine Finanzierungen statt. Wenn du das Projekt unterstützten möchtest, so tätige eine Spende. {% else %} - We are sorry! + We are sorry!
There are currently no running fundings. If you want to contribute to the project, please make a donation. @@ -55,38 +55,40 @@
- {% if lang == "de" %} -

- Du hast eine Idee, oder glaubst ein wichtiges Feature fehlt - und wäre ideal von der Community finanziert? - Sende eine E-Mail an - - wishlist@ipfire.org - -

- {% else %} -

- Do you think we are missing a great feature that could be - funded by the community? Write us an email about it to - - wishlist@ipfire.org - -

- {% end %} +
+
+ {% if lang == "de" %} + Wenn du dich nicht entscheiden kannst für was + deine Spende verwendet werden soll, klicke + hier. + {% else %} + In case you cannot decide for which feature + your donation should be used, click + here. + {% end %} +
-
+
+ {% if lang == "de" %} + Du hast eine Idee, oder glaubst ein wichtiges Feature fehlt + und wäre ideal von der Community finanziert? + Sende eine E-Mail an:
+ wishlist@ipfire.org + {% else %} + Do you think we are missing a great feature that could be + funded by the community? Write us an email about it to:
+ wishlist@ipfire.org + {% end %} +
- {% if lang == "de" %} -

- Wenn du dich nicht entscheiden kannst für was - deine Spende verwendet werden soll, klicke - hier. -

- {% else %} -

- In case you cannot decide for which feature - your donation should be used, click - here. -

- {% end %} +
+ {% if lang == "de" %} + Bereits abgelaufene Sammlungen finden sich + hier. + {% else %} + Already closed fundings are to be found over + here. + {% end %} +
+
{% end block %} diff --git a/www/templates/wishlist/modules/wish.html b/www/templates/wishlist/modules/wish.html index 6c2d575b..ba3326e6 100644 --- a/www/templates/wishlist/modules/wish.html +++ b/www/templates/wishlist/modules/wish.html @@ -45,8 +45,12 @@ {% if wish.remaining_days >= 0 %}

{{ wish.remaining_days }}

{{ _("day to go", "days to go", wish.remaining_days) }}

+ {% elif wish.status == "in_progress" %} +

{{ _("In progress") }}

+ {% elif wish.status == "finished" %} +

{{ _("Finished") }}

{% else %} -

{{ _("Ended") }}

+

{{ _("Funding ended") }}

{% end %}
diff --git a/www/translations/de_DE/LC_MESSAGES/webapp.po b/www/translations/de_DE/LC_MESSAGES/webapp.po index d04f667c..6898dfb1 100644 --- a/www/translations/de_DE/LC_MESSAGES/webapp.po +++ b/www/translations/de_DE/LC_MESSAGES/webapp.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-02-01 18:09+0100\n" +"POT-Creation-Date: 2013-02-02 18:28+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -32,6 +32,22 @@ msgstr "Gestarted: %s" msgid "Funding ends: %s" msgstr "Sammlung endet: %s" +#: templates/wishlist/closed.html:3 templates/wishlist/closed.html:13 +msgid "Closed wishes" +msgstr "Beendete Wünsche" + +#: templates/wishlist/closed.html:9 +msgid "Wishes open for donation" +msgstr "Noch laufende Wünsche" + +#: templates/wishlist/closed.html:36 templates/wishlist/closed.html:40 +msgid "Older" +msgstr "Älter" + +#: templates/wishlist/closed.html:46 templates/wishlist/closed.html:50 +msgid "Newer" +msgstr "Neuer" + #: templates/wishlist/modules/wish.html:6 msgid "Only a few days left!" msgstr "Nur noch wenige Tage!" @@ -63,10 +79,18 @@ msgstr[0] "Tag übrig" msgstr[1] "Tage übrig" #: templates/wishlist/modules/wish.html:49 -msgid "Ended" +msgid "In progress" +msgstr "In Entwicklung" + +#: templates/wishlist/modules/wish.html:51 +msgid "Finished" msgstr "Beendet" -#: templates/wishlist/modules/wish.html:59 +#: templates/wishlist/modules/wish.html:53 +msgid "Funding ended" +msgstr "Sammlung beendet" + +#: templates/wishlist/modules/wish.html:63 msgid "Share this wish with your friends and help us promote it!" msgstr "" "Teile diesen Wunsch mit deinen Freunden und hilf diesen bekannter zu machen!" @@ -1444,7 +1468,7 @@ msgstr "Unbekannter Autor" msgid "%s to %s" msgstr "%s nach %s" -#: webapp/backend/wishlist.py:135 +#: webapp/backend/wishlist.py:153 msgid "Checkout this crowdfunding wish from #ipfire:" msgstr "" @@ -1693,6 +1717,9 @@ msgstr "%(weekday)s, %(day)s. %(month_name)s" msgid "%(commas)s and %(last)s" msgstr "%(commas)s und %(last)s" +#~ msgid "Ended" +#~ msgstr "Beendet" + #~ msgid "euro bank transfer" #~ msgstr "Europa-Banküberweisung" diff --git a/www/translations/webapp.pot b/www/translations/webapp.pot index c9360e99..362bef39 100644 --- a/www/translations/webapp.pot +++ b/www/translations/webapp.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-02-01 18:09+0100\n" +"POT-Creation-Date: 2013-02-02 18:28+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -32,6 +32,22 @@ msgstr "" msgid "Funding ends: %s" msgstr "" +#: templates/wishlist/closed.html:3 templates/wishlist/closed.html:13 +msgid "Closed wishes" +msgstr "" + +#: templates/wishlist/closed.html:9 +msgid "Wishes open for donation" +msgstr "" + +#: templates/wishlist/closed.html:36 templates/wishlist/closed.html:40 +msgid "Older" +msgstr "" + +#: templates/wishlist/closed.html:46 templates/wishlist/closed.html:50 +msgid "Newer" +msgstr "" + #: templates/wishlist/modules/wish.html:6 msgid "Only a few days left!" msgstr "" @@ -63,10 +79,18 @@ msgstr[0] "" msgstr[1] "" #: templates/wishlist/modules/wish.html:49 -msgid "Ended" +msgid "In progress" +msgstr "" + +#: templates/wishlist/modules/wish.html:51 +msgid "Finished" +msgstr "" + +#: templates/wishlist/modules/wish.html:53 +msgid "Funding ended" msgstr "" -#: templates/wishlist/modules/wish.html:59 +#: templates/wishlist/modules/wish.html:63 msgid "Share this wish with your friends and help us promote it!" msgstr "" @@ -1435,7 +1459,7 @@ msgstr "" msgid "%s to %s" msgstr "" -#: webapp/backend/wishlist.py:135 +#: webapp/backend/wishlist.py:153 msgid "Checkout this crowdfunding wish from #ipfire:" msgstr "" diff --git a/www/webapp/__init__.py b/www/webapp/__init__.py index f5c656d1..d51ef65f 100644 --- a/www/webapp/__init__.py +++ b/www/webapp/__init__.py @@ -184,6 +184,7 @@ class Application(tornado.web.Application): # wishlist.ipfire.org self.add_handlers(r"wishlist\.ipfire\.org", [ (r"/", WishlistIndexHandler), + (r"/closed", WishlistClosedHandler), (r"/wish/(.*)/donate", WishDonateHandler), (r"/wish/(.*)", WishHandler), (r"/terms", WishlistTermsHandler), diff --git a/www/webapp/backend/wishlist.py b/www/webapp/backend/wishlist.py index d3b7a26d..a45f3a7c 100644 --- a/www/webapp/backend/wishlist.py +++ b/www/webapp/backend/wishlist.py @@ -21,10 +21,10 @@ class Wishlist(object): if wish: return Wish(self, wish.id) - def get_all_by_query(self, query): + def get_all_by_query(self, query, *args): wishes = [] - for row in self.db.query(query): + for row in self.db.query(query, *args): wish = Wish(self, row.id, row) wishes.append(wish) @@ -32,12 +32,23 @@ class Wishlist(object): def get_all_running(self): return self.get_all_by_query("SELECT * FROM wishlist \ - WHERE DATE(NOW()) >= date_start AND DATE(NOW()) <= date_end AND published = 'Y'\ + WHERE DATE(NOW()) >= date_start AND DATE(NOW()) <= date_end AND status = 'running' \ ORDER BY prio ASC, date_end ASC") - def get_all_finished(self): - return self.get_all_by_query("SELECT * FROM wishlist \ - WHERE DATE(NOW()) > date_end AND published = 'Y' ORDER BY date_end ASC") + def get_all_finished(self, limit=5, offset=None): + query = "SELECT * FROM wishlist WHERE DATE(NOW()) > date_end AND status IS NOT NULL \ + ORDER BY date_end DESC" + args = [] + + if limit: + if offset: + query += " LIMIT %s,%s" + args += [limit, offset] + else: + query += " LIMIT %s" + args.append(limit) + + return self.get_all_by_query(query, *args) class Wish(object): @@ -97,6 +108,13 @@ class Wish(object): return self.percentage + @property + def status(self): + if self.data.status == "running" and not self.running: + return "closed" + + return self.data.status + @property def running(self): if self.remaining_days < 0: diff --git a/www/webapp/handlers_wishlist.py b/www/webapp/handlers_wishlist.py index 247bb84f..00ded7e7 100644 --- a/www/webapp/handlers_wishlist.py +++ b/www/webapp/handlers_wishlist.py @@ -11,6 +11,38 @@ class WishlistIndexHandler(BaseHandler): self.render("wishlist/index.html", wishes=wishes) +class WishlistClosedHandler(BaseHandler): + def get(self): + limit = self.get_argument("limit", None) + offset = self.get_argument("offset", None) + + try: + limit = int(limit) + except: + limit = 5 + + try: + offset = int(offset) + except: + offset = 0 + + wishes = self.wishlist.get_all_finished(limit=limit + 1, offset=offset) + + if len(wishes) > limit: + wishes = wishes[:limit] + has_next = True + else: + has_next = False + + if offset: + has_previous = True + else: + has_previous = False + + self.render("wishlist/closed.html", wishes=wishes, limit=limit, offset=offset, + has_next=has_next, has_previous=has_previous) + + class WishlistTermsHandler(BaseHandler): def get(self): return self.render("wishlist/terms.html")