changeset 2635:d98612551045

Added option of sort by recently and least recently updated tickets in +tickets view
author Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
date Fri, 27 Jun 2014 13:43:58 +0530
parents 4cc1d15c203c
children 5ed45d642d47
files MoinMoin/apps/frontend/views.py MoinMoin/templates/tickets.html MoinMoin/themes/basic/static/css/basic.css MoinMoin/themes/basic/static/custom-less/basic.less
diffstat 4 files changed, 39 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Thu Jun 26 13:34:13 2014 +0530
+++ b/MoinMoin/apps/frontend/views.py	Fri Jun 27 13:43:58 2014 +0530
@@ -41,6 +41,7 @@
 
 from whoosh.query import Term, Prefix, And, Or, DateRange, Every
 from whoosh.analysis import StandardAnalyzer
+from whoosh import sorting
 
 from MoinMoin import log
 logging = log.getLogger(__name__)
@@ -2227,7 +2228,13 @@
     q = And(terms)
 
     with flaskg.storage.indexer.ix[LATEST_REVS].searcher() as searcher:
-        results = searcher.search(q, limit=None)
+        sortedby = []
+        time_sorting = request.args.get(u'time_sorting')
+        if time_sorting == u'new':
+            sortedby.append(sorting.FieldFacet(u'mtime', reverse=True))
+        elif time_sorting == u'old':
+            sortedby.append(sorting.FieldFacet(u'mtime', reverse=False))
+        results = searcher.search(q, limit=None, sortedby=sortedby)
         tags = set(chain.from_iterable(r[TAGS] for r in results))
         return render_template('tickets.html',
                                results=results,
@@ -2235,6 +2242,7 @@
                                status=status,
                                tags=tags,
                                selected_tags=selected_tags,
+                               time_sorting=time_sorting,
         )
 
 
--- a/MoinMoin/templates/tickets.html	Thu Jun 26 13:34:13 2014 +0530
+++ b/MoinMoin/templates/tickets.html	Fri Jun 27 13:43:58 2014 +0530
@@ -20,6 +20,30 @@
     </form>
 {% endfor %}
 
+<div class="tickets-sort-button dropdown">
+    <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
+        {% if time_sorting == 'new' %}
+            {% set sortedby = 'Recently updated' %}
+        {% elif time_sorting == 'old' %}
+            {% set sortedby = 'Least recently updated' %}
+        {% endif %}
+        {{_("Sort: %(sortedby)s", sortedby=sortedby if sortedby)}}
+    <span class="caret"></span>
+    </button>
+    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
+        <li role="presentation">
+            <a role="menuitem" tabindex="-1" href="{{ url_for('frontend.tickets', time_sorting='new') }}">
+                {{_("Recently updated")}}
+            </a>
+        </li>
+        <li role="presentation">
+            <a role="menuitem" tabindex="-1" href="{{ url_for('frontend.tickets', time_sorting='old') }}">
+                {{_("Least recently updated")}}
+            </a>
+        </li>
+    </ul>
+</div>
+
 <form action="{{ url_for('frontend.tickets') }}" method="post">
     <input type="hidden" name="status" value="{{ status }}">
     <input type="text" name="q" value="{{ query if query }}" id="moin-ticketsearch-query" class="form-control" placeholder="{{_('Find tickets')}}">
--- a/MoinMoin/themes/basic/static/css/basic.css	Thu Jun 26 13:34:13 2014 +0530
+++ b/MoinMoin/themes/basic/static/css/basic.css	Fri Jun 27 13:43:58 2014 +0530
@@ -6413,3 +6413,6 @@
   float: right;
   color: #999999;
 }
+.tickets-sort-button.dropdown {
+  display: inline;
+}
--- a/MoinMoin/themes/basic/static/custom-less/basic.less	Thu Jun 26 13:34:13 2014 +0530
+++ b/MoinMoin/themes/basic/static/custom-less/basic.less	Fri Jun 27 13:43:58 2014 +0530
@@ -385,3 +385,6 @@
   float: right;
   color: #999999;
 }
+.tickets-sort-button.dropdown {
+  display: inline;
+}