You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2018/07/06 15:58:34 UTC

[2/3] allura git commit: [#8209] Personal Dashboard - Modifications to paged_search and tickets.html

[#8209] Personal Dashboard - Modifications to paged_search and tickets.html


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/1fe9f02e
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1fe9f02e
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1fe9f02e

Branch: refs/heads/master
Commit: 1fe9f02e22bf8cf9c90e4fce6a3d52ec75428998
Parents: 1942948
Author: deshanigtk <de...@cse.mrt.ac.lk>
Authored: Wed Jul 4 18:16:12 2018 +0530
Committer: deshanigtk <de...@cse.mrt.ac.lk>
Committed: Wed Jul 4 18:16:12 2018 +0530

----------------------------------------------------------------------
 .../ext/personal_dashboard/dashboard_main.py    |  4 +-
 .../templates/sections/tickets.html             | 58 +++++++++++---------
 ForgeTracker/forgetracker/model/ticket.py       | 26 +++++----
 3 files changed, 49 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1fe9f02e/Allura/allura/ext/personal_dashboard/dashboard_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/personal_dashboard/dashboard_main.py b/Allura/allura/ext/personal_dashboard/dashboard_main.py
index 54a88be..dd751cf 100644
--- a/Allura/allura/ext/personal_dashboard/dashboard_main.py
+++ b/Allura/allura/ext/personal_dashboard/dashboard_main.py
@@ -67,7 +67,8 @@ class TicketsSection(DashboardSectionBase):
         from forgetracker.model import Ticket
 
         q = ' or '.join(['assigned_to:' + str(self.user['username']), 'reported_by:' + str(self.user['username'])])
-        result = Ticket.paged_search(None, self.user, q, limit=limit, page=page)
+        sort = 'mod_date_dt desc'
+        result = Ticket.paged_search(None, self.user, q, limit=limit, page=page, sort=sort)
 
         tickets = [
             dict(
@@ -75,6 +76,7 @@ class TicketsSection(DashboardSectionBase):
                 url=ticket.url(),
                 summary=ticket['summary'],
                 created_date=ticket['created_date'],
+                mod_date=ticket['mod_date'],
                 reported_by=ticket['reported_by'],
                 assigned_to_id=ticket['assigned_to_id'],
                 assigned_to=ticket['assigned_to'],

http://git-wip-us.apache.org/repos/asf/allura/blob/1fe9f02e/Allura/allura/ext/personal_dashboard/templates/sections/tickets.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/personal_dashboard/templates/sections/tickets.html b/Allura/allura/ext/personal_dashboard/templates/sections/tickets.html
index 9db22d9..f45cbc7 100644
--- a/Allura/allura/ext/personal_dashboard/templates/sections/tickets.html
+++ b/Allura/allura/ext/personal_dashboard/templates/sections/tickets.html
@@ -30,35 +30,39 @@
 
 {% block content %}
     {% if solr_error %}<p>{{ solr_error }}</p>{% endif %}
+    {% if count %}
     {{ page_size.display(page=page, count=count, limit=limit) }}
-    <table>
-        <tbody>
-        <thead>
-        <tr>
-            <th data-sort="ticket_num_i">#</th>
-            <th data-sort="snippet_s">Summary</th>
-            <th data-sort="created_date_s">Created Date</th>
-            <th data-sort="reported_by_s">Creator</th>
-            <th data-sort="assigned_to_s">Owner</th>
-            <th data-sort="_milestone_s">Milestone</th>
-            <th data-sort="status_s">Status</th>
-        </tr>
-        </thead>
-        <tbody class="ticket-list">
-        <tr>
+        <table>
+            <tbody>
+            <thead>
+            <tr>
+                <th data-sort="ticket_num_i">#</th>
+                <th data-sort="snippet_s">Summary</th>
+                <th data-sort="created_date_s">Created Date</th>
+                <th data-sort="mod_date_s">Updated Date</th>
+                <th data-sort="reported_by_s">Creator</th>
+                <th data-sort="assigned_to_s">Owner</th>
+                <th data-sort="_milestone_s">Milestone</th>
+                <th data-sort="status_s">Status</th>
+            </tr>
+            </thead>
+            <tbody class="ticket-list">
             {% for t in tickets %}
-                <td><a href="{{ t['url'] }}">{{ t['ticket_num'] }}</a></td>
-                <td><a href="{{ t['url'] }}">{{ t['summary'] }}</a></td>
-                <td>{{ lib.abbr_date(t['created_date']) }}</td>
-                <td>{{ t['reported_by'].display_name }}</td>
-                <td>{% if t['assigned_to_id'] %}{{t['assigned_to'].display_name}}{% endif %}</td>
-                <td>{{ t['milestone'] }}</td>
-                <td class="{{ t['status'] }}">{{ t['status'] }}</td>
+                <tr>
+                    <td><a href="{{ t['url'] }}">{{ t['ticket_num'] }}</a></td>
+                    <td><a href="{{ t['url'] }}">{{ t['summary'] }}</a></td>
+                    <td>{{ lib.abbr_date(t['created_date']) }}</td>
+                    <td>{{ lib.abbr_date(t['mod_date']) }}</td>
+                    <td>{{ t['reported_by'].display_name }}</td>
+                    <td>{% if t['assigned_to_id'] %}{{ t['assigned_to'].display_name }}{% endif %}</td>
+                    <td>{{ t['milestone'] }}</td>
+                    <td class="{{ t['status'] }}">{{ t['status'] }}</td>
                 </tr>
-            {% else %}
-                <li class="empty">No tickets to display.</li>
             {% endfor %}
-        </tbody>
-    </table>
-    {{ page_list.display(limit=limit, page=page, count=count-1) }}
+            </tbody>
+        </table>
+    {% else %}
+        <li class="empty">No tickets to display.</li>
+    {% endif %}
+    {{ page_list.display(limit=limit, page=page, count=count) }}
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/allura/blob/1fe9f02e/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 07ca0b9..d242e9a 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -1229,9 +1229,13 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
                 params.update(tsearch.FACET_PARAMS)
                 if not show_deleted:
                     params['fq'] = ['deleted_b:False']
+                if app_config is None:
+                    fl = 'id'
+                else:
+                    fl = 'ticket_num_i'
                 matches = search_artifact(
                     cls, q, short_timeout=True,
-                    rows=limit, sort=refined_sort, start=start, fl='ticket_num_i',
+                    rows=limit, sort=refined_sort, start=start, fl=fl,
                     filter=filter, **params)
             else:
                 matches = None
@@ -1241,29 +1245,29 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
             matches = None
         if matches:
             count = matches.hits
-            # ticket_numbers is in sorted order
-            ticket_numbers = [match['ticket_num_i'] for match in matches.docs]
-            # but query, unfortunately, returns results in arbitrary order
             if app_config is not None:
+                # ticket_matches is in sorted order
+                ticket_matches = [match['ticket_num_i'] for match in matches.docs]
+
+                # but query, unfortunately, returns results in arbitrary order
                 query = cls.query.find(
-                    dict(app_config_id=app_config._id, ticket_num={'$in': ticket_numbers}))
+                    dict(app_config_id=app_config._id, ticket_num={'$in': ticket_matches}))
             else:
+                ticket_matches = [ObjectId(match['id']).split('#')[1] for match in matches.docs]
                 query = cls.query.find(
-                    dict(ticket_num={'$in': ticket_numbers}))
+                    dict(_id={'$in': ticket_matches}))
             # so stick all the results in a dictionary...
             ticket_for_num = {}
             for t in query:
                 ticket_for_num[t.ticket_num] = t
             # and pull them out in the order given by ticket_numbers
             tickets = []
-            for tn in ticket_numbers:
+            for tn in ticket_matches:
                 if tn in ticket_for_num:
                     show_deleted = show_deleted and security.has_access(
                         ticket_for_num[tn], 'delete', user, app_config.project.root_project)
-                    if (app_config is not None) and(security.has_access(ticket_for_num[tn], 'read', user, app_config.project.root_project) and
-                            (show_deleted or ticket_for_num[tn].deleted == False)):
-                        tickets.append(ticket_for_num[tn])
-                    elif (app_config is None) and(security.has_access(ticket_for_num[tn], 'read', user) and
+                    if (security.has_access(ticket_for_num[tn], 'read', user,
+                                            app_config.project.root_project if app_config else None) and
                             (show_deleted or ticket_for_num[tn].deleted == False)):
                         tickets.append(ticket_for_num[tn])
                     else: