[ckan-changes] [okfn/ckan] 64feb7: [no-branch; bug fix] Fixed construction of search ...

GitHub noreply at github.com
Wed Apr 18 11:25:55 UTC 2012


  Branch: refs/heads/release-v1.6.1
  Home:   https://github.com/okfn/ckan
  Commit: 64feb7eebaaa10131f04c3f074b48ba97f2556f2
      https://github.com/okfn/ckan/commit/64feb7eebaaa10131f04c3f074b48ba97f2556f2
  Author: Ian Murray <ian.murray at okfn.org>
  Date:   2012-04-12 (Thu, 12 Apr 2012)

  Changed paths:
    M ckan/controllers/feed.py

  Log Message:
  -----------
  [no-branch; bug fix] Fixed construction of search query in feeds


diff --git a/ckan/controllers/feed.py b/ckan/controllers/feed.py
index aa4fa5d..92bd4fe 100644
--- a/ckan/controllers/feed.py
+++ b/ckan/controllers/feed.py
@@ -170,7 +170,7 @@ def group(self,id):
             abort(404,'Group not found')
 
         data_dict, params = self._parse_url_params()
-        data_dict['q'] = 'groups: %s' % id
+        data_dict['fq'] = 'groups:"%s"' % id
 
         item_count, results = _package_search(data_dict)
 
@@ -201,7 +201,7 @@ def group(self,id):
     def tag(self,id):
 
         data_dict, params = self._parse_url_params()
-        data_dict['q'] = 'tags: %s' % id
+        data_dict['fq'] = 'tags:"%s"' % id
 
         item_count, results = _package_search(data_dict)
 
@@ -259,12 +259,13 @@ def general(self):
     # TODO check search params
     def custom(self):
         q = request.params.get('q', u'')
+        fq = ''
         search_params = {}
         for (param, value) in request.params.items():
-            if not param in ['q', 'page', 'sort'] \
+            if param not in ['q', 'page', 'sort'] \
                     and len(value) and not param.startswith('_'):
                 search_params[param] = value
-                q += ' %s: "%s"' % (param, value)
+                fq += ' %s:"%s"' % (param, value)
 
         search_url_params = urlencode(search_params)
 
@@ -276,6 +277,7 @@ def custom(self):
         limit = ITEMS_LIMIT
         data_dict = {
             'q': q,
+            'fq': fq,
             'start': (page-1) * limit,
             'rows': limit,
             'sort': request.params.get('sort', None),


================================================================
  Commit: 6862830d4407dbf4254a3ea8f9c3f25f6bcb1181
      https://github.com/okfn/ckan/commit/6862830d4407dbf4254a3ea8f9c3f25f6bcb1181
  Author: Ian Murray <ian.murray at okfn.org>
  Date:   2012-04-18 (Wed, 18 Apr 2012)

  Changed paths:
    M test-core.ini

  Log Message:
  -----------
  Fixed failing pagination tests.

Tests were written expecting 20 datasets per page


diff --git a/test-core.ini b/test-core.ini
index bb15f93..c0f6486 100644
--- a/test-core.ini
+++ b/test-core.ini
@@ -64,7 +64,7 @@ ckanext.stats.cache_enabled = 0
 
 openid_enabled = True
 
-ckan.datasets_per_page = 10
+ckan.datasets_per_page = 20
 
 # Logging configuration
 [loggers]


================================================================
  Commit: b9d950fcc360970be748e92d4e98f3dc8e96ed7f
      https://github.com/okfn/ckan/commit/b9d950fcc360970be748e92d4e98f3dc8e96ed7f
  Author: Ian Murray <ian.murray at okfn.org>
  Date:   2012-04-18 (Wed, 18 Apr 2012)

  Changed paths:
    M ckan/lib/base.py
    M ckan/lib/navl/dictization_functions.py
    M ckan/public/scripts/application.js

  Log Message:
  -----------
  Merge remote-tracking branch 'origin/release-v1.6.1' into release-v1.6.1


diff --git a/ckan/lib/base.py b/ckan/lib/base.py
index b10c980..0dfe78e 100644
--- a/ckan/lib/base.py
+++ b/ckan/lib/base.py
@@ -193,12 +193,20 @@ def __call__(self, environ, start_response):
                 if cookie.startswith('ckan') and cookie not in ['ckan']:
                     response.delete_cookie(cookie)
                 # Remove the ckan session cookie if not used e.g. logged out
-                elif cookie == 'ckan' and not c.user and not h.are_there_flash_messages():
-                    if session.id:
-                        if not session.get('lang'):
-                            session.delete()
-                    else:
-                        response.delete_cookie(cookie)
+                elif cookie == 'ckan' and not c.user:
+                    # Check session for valid data (including flash messages)
+                    # (DGU also uses session for a shopping basket-type behaviour)
+                    is_valid_cookie_data = False
+                    for key, value in session.items():
+                        if not key.startswith('_') and value:
+                            is_valid_cookie_data = True
+                            break
+                    if not is_valid_cookie_data:
+                        if session.id:
+                            if not session.get('lang'):
+                                session.delete()
+                        else:
+                            response.delete_cookie(cookie)
                 # Remove auth_tkt repoze.who cookie if user not logged in.
                 elif cookie == 'auth_tkt' and not session.id:
                     response.delete_cookie(cookie)
diff --git a/ckan/lib/navl/dictization_functions.py b/ckan/lib/navl/dictization_functions.py
index 822b29b..a1ad525 100644
--- a/ckan/lib/navl/dictization_functions.py
+++ b/ckan/lib/navl/dictization_functions.py
@@ -27,15 +27,21 @@ def __nonzero__(self):
 class State(object):
     pass
 
-class Invalid(Exception):
+class DictizationError(Exception):
+    def __str__(self):
+        if hasattr(self, 'error') and self.error:
+            return repr(self.error)
+        return ''
+
+class Invalid(DictizationError):
     def __init__(self, error, key=None):
         self.error = error
 
-class DataError(Exception):
+class DataError(DictizationError):
     def __init__(self, error):
         self.error = error
 
-class StopOnError(Exception):
+class StopOnError(DictizationError):
     '''error to stop validations for a particualar key'''
     pass
 
diff --git a/ckan/public/scripts/application.js b/ckan/public/scripts/application.js
index ba31c59..49a3ae2 100644
--- a/ckan/public/scripts/application.js
+++ b/ckan/public/scripts/application.js
@@ -522,7 +522,7 @@ CKAN.View.Resource = Backbone.View.extend({
     }
     self.updateIconTimer = setTimeout(function() {
         // AJAX to server API
-        $.getJSON('/api/2/util/resource/format_icon?format='+encodeURIComponent(self.formatBox.val()), function(data) {
+        $.getJSON(CKAN.SITE_URL + '/api/2/util/resource/format_icon?format='+encodeURIComponent(self.formatBox.val()), function(data) {
           if (data && data.icon && data.format==self.formatBox.val()) {
             self.li.find('.js-resource-icon').attr('src',data.icon);
             self.table.find('.js-resource-icon').attr('src',data.icon);


================================================================
Compare: https://github.com/okfn/ckan/compare/1d2ac66...b9d950f


More information about the ckan-changes mailing list