diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py index 5884e8c98c1..ff9082b0d5d 100644 --- a/ckan/controllers/package.py +++ b/ckan/controllers/package.py @@ -239,12 +239,13 @@ def pager_url(q=None, page=None): try: c.fields = [] search_extras = {} + fq = '' for (param, value) in request.params.items(): if not param in ['q', 'page'] \ and len(value) and not param.startswith('_'): if not param.startswith('ext_'): c.fields.append((param, value)) - q += ' %s: "%s"' % (param, value) + fq += ' %s:"%s"' % (param, value) else: search_extras[param] = value @@ -253,6 +254,7 @@ def pager_url(q=None, page=None): data_dict = { 'q':q, + 'fq':fq, 'facet.field':g.facets, 'rows':limit, 'start':(page-1)*limit, diff --git a/ckan/lib/activity.py b/ckan/lib/activity.py index 9bbde7146fe..9fbc1a67e7f 100644 --- a/ckan/lib/activity.py +++ b/ckan/lib/activity.py @@ -92,6 +92,12 @@ def before_commit(self, session): objects = object_cache[activity_type] for obj in objects: logger.debug("Looking at %s object %s" % (activity_type, obj)) + + if not hasattr(obj,"id"): + logger.debug("Object has no id, skipping...") + continue + + if activity_type == "new" and obj.id in activities: logger.debug("This object was already logged as a new " "package") diff --git a/ckan/lib/i18n.py b/ckan/lib/i18n.py index c9691e3f213..743ef880aad 100644 --- a/ckan/lib/i18n.py +++ b/ckan/lib/i18n.py @@ -89,7 +89,8 @@ def get_available_locales(): def handle_request(request, tmpl_context): ''' Set the language for the request ''' - lang = request.environ.get('CKAN_LANG', config['ckan.locale_default']) + lang = request.environ.get('CKAN_LANG', + config.get('ckan.locale_default', 'en')) if lang != 'en': i18n.set_lang(lang) tmpl_context.language = lang diff --git a/ckan/lib/search/query.py b/ckan/lib/search/query.py index 3ad1608f4ea..e4d6dbb6152 100644 --- a/ckan/lib/search/query.py +++ b/ckan/lib/search/query.py @@ -282,13 +282,12 @@ def run(self, query): # return results as json encoded string query['wt'] = query.get('wt', 'json') - # query field weighting: disabled for now as solr 3.* is required for - # the 'edismax' query parser, our current Ubuntu version only has - # packages for 1.4 - # - # query['defType'] = 'edismax' - # query['tie'] = '0.5' - # query['qf'] = query.get('qf', QUERY_FIELDS) + # If the query has a colon in it then consider it a fielded search and do use dismax. + if ':' not in query['q']: + query['defType'] = 'dismax' + query['tie'] = '0.1' + query['mm'] = '1' + query['qf'] = query.get('qf', QUERY_FIELDS) conn = make_connection() log.debug('Package query: %r' % query) diff --git a/ckan/logic/schema.py b/ckan/logic/schema.py index 31988d076b4..b1763501d41 100644 --- a/ckan/logic/schema.py +++ b/ckan/logic/schema.py @@ -188,6 +188,16 @@ def default_group_schema(): 'packages': { "id": [not_empty, unicode, package_id_or_name_exists], "__extras": [ignore] + }, + 'users': { + "name": [not_empty, unicode], + "capacity": [ignore_missing], + "__extras": [ignore] + }, + 'groups': { + "name": [not_empty, unicode], + "capacity": [ignore_missing], + "__extras": [ignore] } } return schema diff --git a/ckan/templates/js_strings.html b/ckan/templates/js_strings.html index 55c056bdc96..513a5c2ad25 100644 --- a/ckan/templates/js_strings.html +++ b/ckan/templates/js_strings.html @@ -22,7 +22,7 @@ CKAN.Strings.failedToSave = "${_('Failed to save, possibly due to invalid data ')}"; CKAN.Strings.addDataset = "${_('Add Dataset')}"; CKAN.Strings.addGroup = "${_('Add Group')}"; - CKAN.Strings.youHaveUnsavedChanges = "${_("You have unsaved changed. Make sure to click 'Save Changes' below before leaving this page.")}"; + CKAN.Strings.youHaveUnsavedChanges = "${_("You have unsaved changes. Make sure to click 'Save Changes' below before leaving this page.")}"; CKAN.Strings.loading = "${_('Loading...')}"; CKAN.Strings.noNameBrackets = "${_('(no name)')}"; CKAN.Strings.deleteThisResourceQuestion = "${_('Delete the resource \'%name%\'?')}" diff --git a/ckan/templates/user/read.html b/ckan/templates/user/read.html index 318b9f12321..43716c66a3f 100644 --- a/ckan/templates/user/read.html +++ b/ckan/templates/user/read.html @@ -21,6 +21,13 @@
Name
${c.user_dict['fullname'] or 'No name provided'}
+
Member since
+
${h.render_datetime(c.user_dict['created'])}
+ +
About
+
${c.about_formatted}
+
+
Email
@@ -30,13 +37,6 @@ No email
-
Member since
-
${h.render_datetime(c.user_dict['created'])}
- -
About
-
${c.about_formatted}
-
-
API Key
diff --git a/ckan/tests/functional/test_search.py b/ckan/tests/functional/test_search.py index bafbd0904ac..fe1802c76bf 100644 --- a/ckan/tests/functional/test_search.py +++ b/ckan/tests/functional/test_search.py @@ -67,7 +67,7 @@ def test_2_title(self): # multiple words res = self.app.get('/dataset?q=Government%20Expenditure') - result = self._check_results(res, 1, 'uk-government-expenditure') + result = self._check_results(res, 5, 'uk-government-expenditure') class TestSearch2(FunctionalTestCase, PylonsTestCase):#, TestPackageForm): diff --git a/ckan/tests/lib/test_solr_package_search.py b/ckan/tests/lib/test_solr_package_search.py index e530a15173e..6ec2b2fa2c4 100644 --- a/ckan/tests/lib/test_solr_package_search.py +++ b/ckan/tests/lib/test_solr_package_search.py @@ -92,13 +92,17 @@ def test_2_title(self): assert self._pkg_names(result) == 'se-opengov', self._pkg_names(result) # multiple words result = search.query_for(model.Package).run({'q': u'Government Expenditure'}) - assert self._pkg_names(result) == 'uk-government-expenditure', self._pkg_names(result) + # uk-government-expenditure is the best match but all other results should be retured + assert self._pkg_names(result).startswith('uk-government-expenditure'), self._pkg_names(result) + # se-opengov has only government in tags, all others hav it in title. + assert self._pkg_names(result).endswith('se-opengov'), self._pkg_names(result) # multiple words wrong order result = search.query_for(model.Package).run({'q': u'Expenditure Government'}) - assert self._pkg_names(result) == 'uk-government-expenditure', self._pkg_names(result) - # multiple words, one doesn't match + assert self._pkg_names(result).startswith('uk-government-expenditure'), self._pkg_names(result) + assert self._pkg_names(result).endswith('se-opengov'), self._pkg_names(result) + # multiple words all should match government result = search.query_for(model.Package).run({'q': u'Expenditure Government China'}) - assert len(result['results']) == 0, self._pkg_names(result) + assert len(result['results']) == 5, self._pkg_names(result) def test_3_licence(self): # this should result, but it is here to check that at least it does not error @@ -315,6 +319,7 @@ def test_overall(self): check_search_results('annakarenina', 1, ['annakarenina']) check_search_results('warandpeace', 1, ['warandpeace']) check_search_results('', 2) + check_search_results('A Novel By Tolstoy', 1, ['annakarenina']) check_search_results('title:Novel', 1, ['annakarenina']) check_search_results('title:peace', 0)