changeset 2636:5ed45d642d47

Added suggestions for in ticket modify and submit template and also shown all tags in +tickets view
author Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
date Mon, 30 Jun 2014 13:30:33 +0530
parents d98612551045
children 77691e977d87
files MoinMoin/apps/frontend/views.py MoinMoin/items/ticket.py MoinMoin/templates/ticket/base.html MoinMoin/templates/ticket/modify.html MoinMoin/templates/ticket/submit.html MoinMoin/templates/tickets.html
diffstat 6 files changed, 46 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Fri Jun 27 13:43:58 2014 +0530
+++ b/MoinMoin/apps/frontend/views.py	Mon Jun 30 13:30:33 2014 +0530
@@ -20,7 +20,6 @@
 import time
 import mimetypes
 import json
-from itertools import chain
 from datetime import datetime
 from collections import namedtuple
 from functools import wraps, partial
@@ -2235,7 +2234,7 @@
         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))
+        tags = list(searcher.field_terms(TAGS))
         return render_template('tickets.html',
                                results=results,
                                query=query,
--- a/MoinMoin/items/ticket.py	Fri Jun 27 13:43:58 2014 +0530
+++ b/MoinMoin/items/ticket.py	Mon Jun 30 13:30:33 2014 +0530
@@ -27,6 +27,7 @@
 from MoinMoin.constants.contenttypes import CONTENTTYPE_USER
 from MoinMoin.items import Item, Contentful, register, BaseModifyForm
 from MoinMoin.items.content import NonExistentContent
+from MoinMoin.constants.keys import LATEST_REVS, TAGS
 
 
 ITEMTYPE_TICKET = u'ticket'
@@ -193,11 +194,14 @@
 
         # XXX When creating new item, suppress the "foo doesn't exist. Create it?" dummy content
         data_rendered = None if is_new else Markup(self.content._render_data())
+        with flaskg.storage.indexer.ix[LATEST_REVS].searcher() as searcher:
+            suggested_tags = list(searcher.field_terms(TAGS))
 
-        return render_template(self.submit_template if is_new else self.modify_template,
-                               is_new=is_new,
-                               closed=closed,
-                               item_name=self.name,
-                               data_rendered=data_rendered,
-                               form=form,
-                              )
+            return render_template(self.submit_template if is_new else self.modify_template,
+                                   is_new=is_new,
+                                   closed=closed,
+                                   item_name=self.name,
+                                   data_rendered=data_rendered,
+                                   form=form,
+                                   suggested_tags=suggested_tags,
+                                  )
--- a/MoinMoin/templates/ticket/base.html	Fri Jun 27 13:43:58 2014 +0530
+++ b/MoinMoin/templates/ticket/base.html	Mon Jun 30 13:30:33 2014 +0530
@@ -9,6 +9,13 @@
         'severity',
         'priority',
         'tags',
+        ] %}
+        {{ forms.render(form['meta'][e]) }}
+    {% endfor %}
+{% endmacro %}
+
+{% macro render_selectlists() %}
+    {% for e in [
         'assigned_to',
         'superseded_by',
         'depends_on',
--- a/MoinMoin/templates/ticket/modify.html	Fri Jun 27 13:43:58 2014 +0530
+++ b/MoinMoin/templates/ticket/modify.html	Mon Jun 30 13:30:33 2014 +0530
@@ -14,6 +14,11 @@
     <dl>
     {{ forms.render_errors(form) }}
     {{ render_meta() }}
+    {{ _("Suggested Tags: ") }}
+    {% for suggested_tag in suggested_tags %}
+        {{ suggested_tag }}
+    {% endfor %}
+    {{ render_selectlists() }}
     </dl>
 
     {{ forms.render(form['submit']) }}
--- a/MoinMoin/templates/ticket/submit.html	Fri Jun 27 13:43:58 2014 +0530
+++ b/MoinMoin/templates/ticket/submit.html	Mon Jun 30 13:30:33 2014 +0530
@@ -15,6 +15,11 @@
     <dl>
     {{ forms.render_errors(form) }}
     {{ render_meta() }}
+    {{ _("Suggested Tags: ") }}
+    {% for suggested_tag in suggested_tags %}
+        {{ suggested_tag }}
+    {% endfor %}
+    {{ render_selectlists() }}
     </dl>
 
     {{ forms.render_submit(form) }}
--- a/MoinMoin/templates/tickets.html	Fri Jun 27 13:43:58 2014 +0530
+++ b/MoinMoin/templates/tickets.html	Mon Jun 30 13:30:33 2014 +0530
@@ -13,7 +13,7 @@
 {% set status_values = ['all', 'open', 'closed']  %}
 {{_("Filter:")}}
 {% for status_value in status_values %}
-    <form action="{{ url_for('frontend.tickets') }}" method="post" class='moin-ticketsearch-form'>
+    <form action="{{ url_for('frontend.tickets', selected_tags=list(selected_tags), time_sorting=time_sorting if time_sorting) }}" method="post" class='moin-ticketsearch-form'>
         <input type="hidden" name="q" value="{{ query if query }}" >
         &nbsp;<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'}}">
@@ -32,19 +32,19 @@
     </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') }}">
+            <a role="menuitem" tabindex="-1" href="{{ url_for('frontend.tickets', selected_tags=list(selected_tags), time_sorting='new') }}">
                 {{_("Recently updated")}}
             </a>
         </li>
         <li role="presentation">
-            <a role="menuitem" tabindex="-1" href="{{ url_for('frontend.tickets', time_sorting='old') }}">
+            <a role="menuitem" tabindex="-1" href="{{ url_for('frontend.tickets', selected_tags=list(selected_tags), time_sorting='old') }}">
                 {{_("Least recently updated")}}
             </a>
         </li>
     </ul>
 </div>
 
-<form action="{{ url_for('frontend.tickets') }}" method="post">
+<form action="{{ url_for('frontend.tickets',selected_tags=list(selected_tags), time_sorting=time_sorting if time_sorting) }}" 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')}}">
 </form>
@@ -100,17 +100,6 @@
     {% endfor %}
     </tbody>
     </table>
-    <h3>{{_("Tags")}}</h3>
-    {% for tag in tags %}
-        {# 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 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' }}">
-        </form>
-    {% endfor %}
 
     <p id="ticket-table-tip">
         {{_("Tip: Sort multiple columns simultaneously by holding down the Shift key and clicking a second, third or even fourth column header!")}}
@@ -118,6 +107,19 @@
 {% else %}
     {{ _("No Ticket found.") }}
 {% endif %}
+
+<h3>{{_("Tags")}}</h3>
+{% for tag in tags %}
+    {# 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 action="{{ url_for('frontend.tickets', selected_tags=selected_tags_value, time_sorting=time_sorting if time_sorting) }}" 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' }}">
+    </form>
+{% endfor %}
+
 </p>
 {% endblock %}
 {% block body_scripts %}