changeset 2864:7de85ecc3669

rework +tickets, add Update and Assignee columns, remove itemid and sort by age button
author RogerHaase <haaserd@gmail.com>
date Tue, 09 Dec 2014 07:45:40 -0700
parents 3bbeaf34c52d
children 701db2cbfa67
files MoinMoin/apps/frontend/views.py MoinMoin/static/js/tickets.js MoinMoin/templates/tickets.html MoinMoin/themes/__init__.py
diffstat 4 files changed, 25 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Wed Dec 03 12:56:05 2014 -0700
+++ b/MoinMoin/apps/frontend/views.py	Tue Dec 09 07:45:40 2014 -0700
@@ -2296,13 +2296,6 @@
     user = And(user)
 
     with flaskg.storage.indexer.ix[LATEST_REVS].searcher() as searcher:
-        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))
-
         if assigned_username:
             selected_user = searcher.search(user, limit=None)
             if selected_user:
@@ -2312,7 +2305,7 @@
                 terms = []
 
         q = And(terms)
-        results = searcher.search(q, limit=None, sortedby=sortedby)
+        results = searcher.search(q, limit=None)
         tags = get_itemtype_specific_tags(ITEMTYPE_TICKET)
         return render_template('tickets.html',
                                results=results,
@@ -2320,7 +2313,6 @@
                                status=status,
                                tags=tags,
                                selected_tags=selected_tags,
-                               time_sorting=time_sorting,
                                current_timestamp=current_timestamp,
         )
 
--- a/MoinMoin/static/js/tickets.js	Wed Dec 03 12:56:05 2014 -0700
+++ b/MoinMoin/static/js/tickets.js	Tue Dec 09 07:45:40 2014 -0700
@@ -1,17 +1,5 @@
 $(document).ready(function () {
     "use strict";
-    $("table").tablesorter({
-        widgets: ["resizable"],
-        widgetOptions : {
-            // css class name applied to the sticky header
-            resizable : false
-        },
-        headers: {
-            // remove sorting option for tags column
-            7: { sorter: false }
-        }
-    });
-
     $('.moin-loginsettings').addClass('navbar-right');
 
     // executed when user clicks tickets tab tags button and conditionally on page load
--- a/MoinMoin/templates/tickets.html	Wed Dec 03 12:56:05 2014 -0700
+++ b/MoinMoin/templates/tickets.html	Tue Dec 09 07:45:40 2014 -0700
@@ -8,7 +8,7 @@
     {% set status_values = ['all', 'open', 'closed']  %}
     <span>{{ _("Filter:") }}</span>
     {% for status_value in status_values %}
-        <form action="{{ url_for('frontend.tickets', selected_tags=list(), time_sorting=time_sorting if time_sorting) }}" method="post" class='moin-ticketsearch-form'>
+        <form action="{{ url_for('frontend.tickets', selected_tags=list()) }}" method="post" class='moin-ticketsearch-form'>
             <input type="hidden" name="q" value="" >
             <input type="hidden" name="status" value="{{ status_value }}">
             <input type="submit" value="{{ status_value.capitalize() }}" title="{{ _('Show %(status)s tickets', status=status_value) }}" class="{{ 'ticket-query-button active' if status == status_value  else 'ticket-query-button' }}">
@@ -17,39 +17,7 @@
 
     <input type="button" class="ticket-tags-button ticket-tags-toggle" title="{{ _("Show all tags") }}" value="{{ _("Tags") }}">
 
-    <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">
-                <form action="{{ url_for('frontend.tickets', selected_tags=list(selected_tags), time_sorting='new') }}" method="post">
-                    <input type="hidden" name="status" value="{{ status }}">
-                    <input type="hidden" name="q" value="{{ query if query }}" >
-                    <button type="submit">
-                        {{ _("Recently updated") }}
-                    </button>
-                </form>
-            </li>
-            <li role="presentation">
-                <form action="{{ url_for('frontend.tickets', selected_tags=list(selected_tags), time_sorting='old') }}" method="post">
-                    <input type="hidden" name="status" value="{{ status }}">
-                    <input type="hidden" name="q" value="{{ query if query }}" >
-                    <button type="submit">
-                        {{ _("Least Recently updated") }}
-                    </button>
-                </form>
-            </li>
-        </ul>
-    </div>
-
-    <form class="moin-ticket-search" action="{{ url_for('frontend.tickets',selected_tags=list(selected_tags), time_sorting=time_sorting if time_sorting) }}" method="post">
+    <form class="moin-ticket-search" action="{{ url_for('frontend.tickets',selected_tags=list(selected_tags)) }}" method="post">
         <input type="hidden" name="status" value="{{ status }}">
         <input type="text" name="q" value="{{ query if query }}" id="moin-ticketsearch-query" placeholder="{{ _('Find tickets') }}">
     </form>
@@ -66,22 +34,23 @@
             {# If user clicks on the tag then it gets selected if it is not already selected #}
             {# If that tag is already selected then it gets deselected #}
             {% set selected_tags_value = list(selected_tags.difference([tag]) if tag in selected_tags else selected_tags.union([tag])) %}
-            <form class="moin-existing-tags" action="{{ url_for('frontend.tickets', selected_tags=selected_tags_value, time_sorting=time_sorting if time_sorting) }}" method="post">
+            <form class="moin-existing-tags" action="{{ url_for('frontend.tickets', selected_tags=selected_tags_value) }}" method="post">
                 <input type="hidden" name="q" value="{{ query if query }}" >
                 <input type="hidden" name="status" value="{{ status }}">
-                <input type="submit" value="{{ tag }}" class="{{ 'ticket-tags-button btn btn-primary active' if tag in selected_tags else 'ticket-tags-button btn btn-default' }}">
+                <input type="submit" value="{{ tag }}" class="{{ 'ticket-tags-button active btn btn-primary' if tag in selected_tags else 'ticket-tags-button' }}">
             </form>
         {% endfor %}
     </div>
 
     {% if results %}
         <p>{{ _("%(result_len)d Tickets found.", result_len=results|length) }}</p>
-        <table class="table table-hover" id="ticket-list">
+        <table class="table table-hover moin-sortable" id="ticket-list">
             <thead>
                 <tr>
-                    <th id="ticket-itemid">{{ _("ID") }}</th>
                     <th id="ticket-summary">{{ _("Summary") }}</th>
                     <th id="ticket-status">{{ _("Status") }}</th>
+                    <th id="ticket-mtime">{{ _("Updated") }}</th>
+                    <th id="ticket-assigned-to">{{ _("Assignee") }}</th>
                     <th id="ticket-effort" title="{{ _('Effort') }}">E</th>
                     <th id="ticket-difficulty" title="{{ _('Difficulty') }}">D</th>
                     <th id="ticket-severity" title="{{ _('Severity') }}">S</th>
@@ -94,10 +63,6 @@
                     <tr>
                         <td>
                             <a href="{{ url_for_item(result['itemid'], field='itemid', namespace=result['namespace']) }}" title="{{ _('ITEMID: %(itemid)s', itemid=result['itemid']) }}">
-                                {{ result['itemid'] | shorten_id }}
-                            </a>
-                        <td>
-                            <a href="{{ url_for_item(result['itemid'], field='itemid', namespace=result['namespace']) }}" title="{{ _('ITEMID: %(itemid)s', itemid=result['itemid']) }}">
                                 {{ result['summary'] }}
                             </a>
                         </td>
@@ -105,6 +70,12 @@
                             {{ _("Closed") if result['closed'] else _("Open") }}
                         </td>
                         <td>
+                            {{ result.get('mtime', '').strftime('%Y-%m-%d') }}
+                        </td>
+                        <td>
+                            {{ get_assigned_to_info(result) }}
+                        </td>
+                        <td>
                             {{ result.get('effort', '') }}
                         </td>
                         <td>
--- a/MoinMoin/themes/__init__.py	Wed Dec 03 12:56:05 2014 -0700
+++ b/MoinMoin/themes/__init__.py	Tue Dec 09 07:45:40 2014 -0700
@@ -22,7 +22,7 @@
 
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin import wikiutil, user
-from MoinMoin.constants.keys import USERID, ADDRESS, HOSTNAME, REVID, ITEMID, NAME_EXACT
+from MoinMoin.constants.keys import USERID, ADDRESS, HOSTNAME, REVID, ITEMID, NAME_EXACT, ASSIGNED_TO
 from MoinMoin.constants.contenttypes import CONTENTTYPES_MAP
 from MoinMoin.constants.namespaces import NAMESPACE_DEFAULT, NAMESPACE_USERPROFILES, NAMESPACE_ALL
 from MoinMoin.search import SearchForm
@@ -539,6 +539,15 @@
     return result
 
 
+def get_assigned_to_info(meta):
+    display_name = ''
+    userid = meta.get(ASSIGNED_TO)
+    if userid:
+        u = user.User(userid)
+        display_name = u.display_name or u.name0
+    return display_name
+
+
 def shorten_fqname(fqname, length=25):
     """
     Shorten fqname
@@ -673,6 +682,7 @@
         'url_for_item': url_for_item,
         'get_fqname': get_fqname,
         'get_editor_info': lambda meta: get_editor_info(meta),
+        'get_assigned_to_info': lambda meta: get_assigned_to_info(meta),
         'utctimestamp': lambda dt: utctimestamp(dt),
         'gen': make_generator(),
         'search_form': SearchForm.from_defaults(),