]> git.ipfire.org Git - ipfire.org.git/commitdiff
wishlist: Show ended fundings.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 2 Feb 2013 17:29:49 +0000 (18:29 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 2 Feb 2013 17:29:49 +0000 (18:29 +0100)
www/templates/wishlist/closed.html [new file with mode: 0644]
www/templates/wishlist/index.html
www/templates/wishlist/modules/wish.html
www/translations/de_DE/LC_MESSAGES/webapp.po
www/translations/webapp.pot
www/webapp/__init__.py
www/webapp/backend/wishlist.py
www/webapp/handlers_wishlist.py

diff --git a/www/templates/wishlist/closed.html b/www/templates/wishlist/closed.html
new file mode 100644 (file)
index 0000000..45f0857
--- /dev/null
@@ -0,0 +1,55 @@
+{% extends "../base-1.html" %}
+
+{% block title %}{{ _("Closed wishes") }}{% end block %}
+
+{% block body %}
+       <div class="page-header">
+               <ul class="nav nav-pills pull-right">
+                       <li>
+                               <a href="/">{{ _("Wishes open for donation") }}</a>
+                       </li>
+               </ul>
+
+               <h1>{{ _("Closed wishes") }}</h1>
+       </div>
+
+       {% if lang == "de" %}
+               <p>
+                       Auf dieser Seite finden sich bereits ausgelaufene Sammlungen.
+               </p>
+       {% else %}
+               <p>
+                       On this page, you will find all fundings that have already ended.
+               </p>
+       {% end %}
+
+       <hr>
+
+       {% if wishes %}
+               {{ modules.Wishlist(wishes) }}
+
+               <hr>
+
+               <ul class="pager">
+                       {% if has_next %}
+                               <li class="previous">
+                                       <a href="/closed?limit={{ limit }}&offset={{ offset + limit }}">&larr; {{ _("Older") }}</a>
+                               </li>
+                       {% else %}
+                               <li class="previous disabled">
+                                       <a href="#">&larr; {{ _("Older") }}</a>
+                               </li>
+                       {% end %}
+
+                       {% if has_previous %}
+                               <li class="next">
+                                       <a href="/closed?limit={{ limit }}&offset={{ offset - limit }}">{{ _("Newer") }} &rarr;</a>
+                               </li>
+                       {% else %}
+                               <li class="next disabled">
+                                       <a href="#">{{ _("Newer") }} &rarr;</a>
+                               </li>
+                       {% end %}
+               </ul>
+       {% end %}
+{% end %}
index 453b6b0fe260893acb2cb44ba00e10cbcd7f5f95..daf86cea556e768544e8e856837fbddcf675601b 100644 (file)
        {% if wishes %}
                {{ modules.Wishlist(wishes) }}
        {% else %}
-               <div class="alert alert-error">
+               <div class="alert alert-error ac">
                        {% if lang == "de" %}
-                               <strong>Es tut uns Leid!</strong>
+                               <strong>Es tut uns Leid!</strong><br>
                                Derzeit finden keine Finanzierungen statt.
                                Wenn du das Projekt unterstützten möchtest, so
                                tätige eine <a href="http://www.ipfire.org/donation">Spende</a>.
                        {% else %}
-                               <strong>We are sorry!</strong>
+                               <strong>We are sorry!</strong><br>
                                There are currently no running fundings.
                                If you want to contribute to the project, please
                                make a <a href="http://www.ipfire.org/donation">donation</a>.
 
        <hr>
 
-       {% if lang == "de" %}
-               <p class="ac">
-                       Du hast eine Idee, oder glaubst ein wichtiges Feature fehlt
-                       und wäre ideal von der Community finanziert?
-                       Sende eine E-Mail an
-                       <a href="mailto:wishlist@ipfire.org">
-                               <i class="icon-envelope"></i> wishlist@ipfire.org
-                       </a>
-               </p>
-       {% else %}
-               <p class="ac">
-                       Do you think we are missing a great feature that could be
-                       funded by the community? Write us an email about it to
-                       <a href="mailto:wishlist@ipfire.org">
-                               <i class="icon-envelope"></i> wishlist@ipfire.org
-                       </a>
-               </p>
-       {% end %}
+       <div class="row">
+               <div class="span4 ac">
+                       {% if lang == "de" %}
+                               Wenn du dich nicht entscheiden kannst für was
+                               deine Spende verwendet werden soll, klicke
+                               <a href="http://www.ipfire.org/donate">hier</a>.
+                       {% else %}
+                               In case you cannot decide for which feature
+                               your donation should be used, click
+                               <a href="http://www.ipfire.org/donate">here</a>.
+                       {% end %}
+               </div>
 
-       <hr>
+               <div class="span4 ac">
+                       {% 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:<br>
+                               <i class="icon-envelope"></i> <a href="mailto:wishlist@ipfire.org">wishlist@ipfire.org</a>
+                       {% else %}
+                               Do you think we are missing a great feature that could be
+                               funded by the community? Write us an email about it to:<br>
+                               <i class="icon-envelope"></i> <a href="mailto:wishlist@ipfire.org">wishlist@ipfire.org</a>
+                       {% end %}
+               </div>
 
-       {% if lang == "de" %}
-               <p class="ac">
-                       Wenn du dich nicht entscheiden kannst für was
-                       deine Spende verwendet werden soll, klicke
-                       <a href="http://www.ipfire.org/donate">hier</a>.
-               </p>
-       {% else %}
-               <p class="ac">
-                       In case you cannot decide for which feature
-                       your donation should be used, click
-                       <a href="http://www.ipfire.org/donate">here</a>.
-               </p>
-       {% end %}
+               <div class="span4 ac">
+                       {% if lang == "de" %}
+                               Bereits abgelaufene Sammlungen finden sich
+                               <a href="/closed">hier</a>.
+                       {% else %}
+                               Already closed fundings are to be found over
+                               <a href="/closed">here</a>.
+                       {% end %}
+               </div>
+       </div>
 {% end block %}
index 6c2d575b64ce268596342bdbb818460cddaef149..ba3326e64a49996a48deb7e0255c1c068fcc35f6 100644 (file)
                                                        {% if wish.remaining_days >= 0 %}
                                                                <p class="lead">{{ wish.remaining_days }}</p>
                                                                <p>{{ _("day to go", "days to go", wish.remaining_days) }}</p>
+                                                       {% elif wish.status == "in_progress" %}
+                                                               <p class="lead">{{ _("In progress") }}</p>
+                                                       {% elif wish.status == "finished" %}
+                                                               <p class="lead">{{ _("Finished") }}</p>
                                                        {% else %}
-                                                               <p class="lead">{{ _("Ended") }}</p>
+                                                               <p class="lead">{{ _("Funding ended") }}</p>
                                                        {% end %}
                                                </div>
                                        </div>
index d04f667ce2ec251b10e822e043decaedb66fcb74..6898dfb114e8870c56123db8393d0cd4b3818f1b 100644 (file)
@@ -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 <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\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"
 
index c9360e99371b7d0c53e590bff4e3f8cdf6c46d3e..362bef39c461be83500c1fecfc7d022b7b98aa46 100644 (file)
@@ -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 <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\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 ""
 
index f5c656d1b5f15845da62de69c4cd220957b2da9b..d51ef65f7529d3f00ea7171f23e64ddae6ee85a9 100644 (file)
@@ -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),
index d3b7a26dad47d228995c3d58416d6166241d0a93..a45f3a7ce68ad06f35dce3137e596b5f28575de4 100644 (file)
@@ -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:
index 247bb84f9d4065b0e70a986005b929b06ce27730..00ded7e7403b5356fa6a00212f0b242ff2f4996b 100644 (file)
@@ -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")