Skip to content

Commit

Permalink
Merge branch 'master' into 613-bulk-update-sorting
Browse files Browse the repository at this point in the history
Conflicts:
	ckan/templates/organization/bulk_process.html

    - facet fixes
  • Loading branch information
tobes committed Mar 13, 2013
2 parents 53c2096 + 7afd580 commit 7c7a2f5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
19 changes: 17 additions & 2 deletions ckan/lib/search/index.py
Expand Up @@ -3,6 +3,7 @@
import logging
import collections
import json
from dateutil.parser import parse

import re

Expand Down Expand Up @@ -156,7 +157,7 @@ def index_package(self, pkg_dict, defer_commit=False):

# if there is an owner_org we want to add this to groups for index
# purposes
if pkg_dict['owner_org']:
if pkg_dict.get('organization'):
pkg_dict['groups'].append(pkg_dict['organization']['name'])


Expand Down Expand Up @@ -192,7 +193,21 @@ def index_package(self, pkg_dict, defer_commit=False):
# Save dataset type
pkg_dict['dataset_type'] = pkg_dict['type']

pkg_dict = dict([(k.encode('ascii', 'ignore'), v) for (k, v) in pkg_dict.items()])
# clean the dict fixing keys and dates
# FIXME where are we getting these dirty keys from? can we not just
# fix them in the correct place or is this something that always will
# be needed? For my data not changing the keys seems to not cause a
# problem.
new_dict = {}
for key, value in pkg_dict.items():
key = key.encode('ascii', 'ignore')
if key.endswith('_date'):
try:
value = parse(value).isoformat() + 'Z'
except ValueError:
continue
new_dict[key] = value
pkg_dict = new_dict

for k in ('title', 'notes', 'title_string'):
if k in pkg_dict and pkg_dict[k]:
Expand Down
7 changes: 4 additions & 3 deletions ckan/templates/organization/bulk_process.html
Expand Up @@ -84,9 +84,10 @@ <h3 class="dataset-heading">
{% endif %}
</div>
<aside class="tertiary">
{% snippet 'snippets/simple_search.html', q=c.q, sort=c.sort_by_selected, placeholder=_('Search datasets...'), extra_sort=[(_('Last Modified'), 'data_modified asc')], input_class='search-normal', form_class='search-aside' %}
{{ h.snippet('snippets/facet_list.html', title='Tags', name='tags', within_tertiary=true, extras={'id':c.group_dict.name}) }}
{{ h.snippet('snippets/facet_list.html', title='Formats', name='res_format', within_tertiary=true, extras={'id':c.group_dict.name}) }}
{% snippet 'snippets/simple_search.html', q=c.q, sort=c.sort_by_selected, placeholder=_('Search datasets...'), extra_sort=[(_('Last Modified'), 'data_modified asc')], input_class='search-normal', form_class='search-aside' %}
{% for facet in c.facet_titles %}
{{ h.snippet('snippets/facet_list.html', title=c.facet_titles[facet], name=facet, extras={'id':c.group_dict.id}) }}
{% endfor %}
</aside>
</div>
{{ c.page.pager() }}
Expand Down
4 changes: 4 additions & 0 deletions ckan/tests/lib/test_solr_search_index.py
Expand Up @@ -65,6 +65,10 @@ def test_index(self):
'owner_org': None,
'metadata_created': datetime_now.isoformat(),
'metadata_modified': datetime_now.isoformat(),
'extras': [
{'key': 'test_date', 'value': '2013-03-01'},
{'key': 'test_wrong_date', 'value': 'Not a date'},
]
}
search.dispatch_by_operation('Package', pkg_dict, 'new')
response = self.solr.query('title:penguin', fq=self.fq)
Expand Down
1 change: 1 addition & 0 deletions pip-requirements.txt
Expand Up @@ -29,3 +29,4 @@ Jinja2==2.6
fanstatic==0.12
requests==1.1.0
WebTest==1.4.3
python-dateutil>=1.5.0,<2.0.0

0 comments on commit 7c7a2f5

Please sign in to comment.