Skip to content

Commit

Permalink
making sort by title the default so that we can FINALLY close #1484
Browse files Browse the repository at this point in the history
  • Loading branch information
mbellotti committed Oct 29, 2014
1 parent bce7fb7 commit 57c63a7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
19 changes: 18 additions & 1 deletion ckanext-hdx_search/ckanext/hdx_search/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import logging as logging
import ckan.lib.helpers as h
import ckan.model as model
import ckan.plugins as p

import ckanext.hdx_theme.tests.hdx_test_base as hdx_test_base

Expand All @@ -18,7 +19,11 @@ class TestHDXSearch(hdx_test_base.HdxBaseTest):

@classmethod
def _load_plugins(cls):
hdx_test_base.load_plugin('hdx_search hdx_theme')
try:
p.load('hdx_search')
except Exception as e:
log.warn('Module already loaded')
log.info(str(e))

def test_search(self):
user = model.User.by_name('tester')
Expand Down Expand Up @@ -70,3 +75,15 @@ def test_package_search(self):
'user': user, 'for_view': True, 'auth_user_obj': user}
s = search.package_search(context, data_dict)
assert len(s['results']) > 0

def test_new_sort_org(self):
org = h.url_for(
controller='organization', action='list')
response = self.app.get(org, params={'sort':'title+asc'})
assert '200' in response.status

def test_new_sort_grp(self):
grp = h.url_for(
controller='group', action='list')
response = self.app.get(grp, params={'sort':'title+asc'})
assert '200' in response.status
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{% block primary_content_inner %}
<h1 class="hide-heading">{{ _('Groups') }}</h1>
{% block groups_search_form %}
{% set sorting_option = c.sort_by_selected or 'name asc' %}
{% set sorting_option = c.sort_by_selected or 'title asc' %}
{% snippet 'snippets/search_form.html', type='group', query=c.q, sorting_selected=sorting_option, count=c.page.item_count, placeholder=_('Search groups...'), show_empty=request.params %}
{% endblock %}
{% block groups_list %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{% block primary_content_inner %}
<h1 class="hide-heading">{% block page_heading %}{{ _('Organisations') }}{% endblock %}</h1>
{% block organizations_search_form %}
{% set sorting_option = c.sort_by_selected or 'name asc' %}
{% set sorting_option = c.sort_by_selected or 'title asc' %}
{% snippet 'snippets/search_form.html', type='organization', query=c.q, sorting_selected=sorting_option, count=c.page.item_count, placeholder=_('Search organisations...'), show_empty=request.params %}
{% endblock %}
{% block organizations_list %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% import 'macros/form.html' as form %}

{% set placeholder = placeholder if placeholder else _('Search...') %}
{% set sorting = sorting if sorting else [(_('Default Sort'), 'name asc'), (_('Name Ascending'), 'title asc'), (_('Name Descending'), 'title desc')] %}
{% set sorting = sorting if sorting else [(_('Name Ascending'), 'title asc'), (_('Name Descending'), 'title desc')] %}
{% set search_class = search_class if search_class else 'search-giant' %}
{% set is_display_search_input = display_search_input if display_search_input==False else True %}
{% set is_dataset = ('dataset' == type) %}
Expand Down

0 comments on commit 57c63a7

Please sign in to comment.