]> git.parisson.com Git - telemeta.git/commitdiff
add sound filter to search results
authoryomguy <yomguy@parisson.com>
Wed, 30 Nov 2011 14:42:08 +0000 (15:42 +0100)
committeryomguy <yomguy@parisson.com>
Wed, 30 Nov 2011 14:42:08 +0000 (15:42 +0100)
telemeta/templates/telemeta_default/search_results.html
telemeta/templatetags/telemeta_utils.py

index 205632a83bd674331e52268c01a43132fc8f029f..ced7817178f6def1ae588ae6ad2c96ce9e0ef6ef 100644 (file)
@@ -8,6 +8,16 @@
  <img src="{% url telemeta-images "search_red.png" %}" alt="search-results" style="vertical-align:middle" /> {% trans "Search Results" %}
 {% endblock %}
 
+{% block title_buttons %}
+    {% ifequal type 'items' %}
+     <a href="{% url telemeta-search-items %}?{{criteria|with_no_sound|build_query_string}}" class="component_icon button icon_filter">{% trans "All" %}</a>
+     <a href="{% url telemeta-search-items %}?{{criteria|with_sound|build_query_string}}" class="component_icon button icon_filter">{% trans "Sounds" %}</a>
+    {% else %}
+     <a href="{% url telemeta-search-collections %}?{{criteria|with_no_sound|build_query_string}}" class="component_icon button icon_filter">{% trans "All" %}</a>
+     <a href="{% url telemeta-search-collections %}?{{criteria|with_sound|build_query_string}}" class="component_icon button icon_filter">{% trans "Sounds" %}</a>
+    {% endifequal %}
+{% endblock %}
+
 {% block content %}
 {% if criteria %}
 <ul>
@@ -43,6 +53,9 @@
      {% endifnotequal %}
     </li>
   {% endif %}
+    {% if criteria.sound %}
+    <li><b>{% trans "Sound" %}:</b> {{criteria.sound}}</li>
+  {% endif %}
 </ul>
 {% endif %}
 
index 9667237750704f2ba9d73ddb787fc4f019dc1cdd..05f8ecbe61bc5a37e303434d323d8dd87e149341 100644 (file)
@@ -86,6 +86,22 @@ def build_query_string(vars):
       return "&amp;".join(args)
     return ''
 
+@register.filter
+def with_no_sound(vars):
+    _vars = vars.copy()
+    if type(_vars) == dict:
+        if u'sound' in _vars:
+            del _vars[u'sound']
+    return _vars
+
+@register.filter
+def with_sound(vars):
+    _vars = vars.copy()
+    if type(_vars) == dict:
+        if not 'sound' in _vars:
+            _vars['sound'] = True
+    return _vars
+
 @register.filter
 def code_or_id(resource):
     if resource.code: