{% load i18n telemeta_tags saved_searches_tags %}
{% most_recent_searches as searches for_user request.user %}

   <div class="module">
    <h3>
      <img src="{{ STATIC_URL }}telemeta/images/search_wh2.png" alt="rss" style="vertical-align:middle" />
      {% trans title %}</h3>

    <div class="vscroll">
    <table class="listing" bgcolor="#FFFFFF" style="width: 100%">
      <tr>
        <th>{% trans "Date" %}</th>
        <th>{% trans "Query" %}</th>
      </tr>
    {% for s in searches %}
     <tr {% if not forloop.counter0|divisibleby:"2" %}class="odd"{% endif %}>
        <td>{{ s.created }}</td>
        <td>{% if s.search_key == 'quick' %}
                <a href="{% url "haystack_search" %}?q={{s.user_query}}">{{ s.user_query }}</a>
            {% elif s.search_key == 'advanced' %}
              {% with s.user_query|build_pattern_dict as queries %}
                <a href="{% url "haystack_advance_search" %}?{{queries|build_query_string}}">
                {% for k, v in queries.items %}
                 {% if v %}<li>{{ k }}: {{ v }}</li>{% endif %}
                {% endfor %}
                </a>
              {% endwith %}
            {% endif %}
        </td>
      </tr>
    {% endfor %}
    </table>
    </div>
   </div>
