Skip to content

Commit

Permalink
Merge branch 'master' into 3196-blueprints-and-templates
Browse files Browse the repository at this point in the history
Conflicts:
	ckan/config/middleware/flask_app.py
  • Loading branch information
amercader committed Sep 15, 2016
2 parents ffa526c + d73326a commit c207980
Show file tree
Hide file tree
Showing 21 changed files with 917 additions and 289 deletions.
2 changes: 0 additions & 2 deletions ckan/config/deployment.ini_tmpl
Expand Up @@ -78,8 +78,6 @@ ckan.auth.roles_that_cascade_to_sub_groups = admin
ckan.site_id = default
#solr_url = http://127.0.0.1:8983/solr

#ckan.simple_search = 1


## CORS Settings

Expand Down
6 changes: 6 additions & 0 deletions ckan/config/middleware/flask_app.py
Expand Up @@ -134,6 +134,12 @@ def hello_world_post():
}
app = Fanstatic(app, **fanstatic_config)

# Update the main CKAN config object with the Flask specific keys
# that were set here or autogenerated
flask_config_keys = set(flask_app.config.keys()) - set(config.keys())
for key in flask_config_keys:
config[key] = flask_app.config[key]

# Add a reference to the actual Flask app so it's easier to access
app._wsgi_app = flask_app

Expand Down
2 changes: 1 addition & 1 deletion ckan/config/routing.py
Expand Up @@ -9,10 +9,10 @@
"""
import re

from pylons import config
from routes.mapper import SubMapper, Mapper as _Mapper

import ckan.plugins as p
from ckan.common import config

named_routes = {}

Expand Down
13 changes: 9 additions & 4 deletions ckan/controllers/feed.py
Expand Up @@ -170,12 +170,17 @@ def _alternate_url(self, params, **kwargs):
def _group_or_organization(self, obj_dict, is_org):

data_dict, params = self._parse_url_params()
key = 'owner_org' if is_org else 'groups'
data_dict['fq'] = '%s:"%s"' % (key, obj_dict['id'],)
group_type = 'organization'
if not is_org:
if is_org:
key = 'owner_org'
value = obj_dict['id']
group_type = 'organization'
else:
key = 'groups'
value = obj_dict['name']
group_type = 'group'

data_dict['fq'] = '{0}:"{1}"'.format(key, value)

item_count, results = _package_search(data_dict)

navigation_urls = self._navigation_urls(params,
Expand Down
2 changes: 1 addition & 1 deletion ckan/i18n/zh_CN/LC_MESSAGES/ckan.po
Expand Up @@ -959,7 +959,7 @@ msgstr[0] "{years}年前"

#: ckan/lib/formatters.py:146
msgid "{month} {day}, {year}, {hour:02}:{min:02} ({timezone})"
msgstr "{} {日},{年},{时}:{:02}({时区})"
msgstr "{month} {day}, {year}, {hour:02}:{min:02} ({timezone})"

#: ckan/lib/formatters.py:151
msgid "{month} {day}, {year}"
Expand Down
2 changes: 1 addition & 1 deletion ckan/lib/render.py
Expand Up @@ -4,7 +4,7 @@
import re
import logging

from pylons import config
from ckan.common import config

log = logging.getLogger(__name__)

Expand Down
21 changes: 4 additions & 17 deletions ckan/lib/search/__init__.py
Expand Up @@ -7,7 +7,6 @@
import xml.dom.minidom
import urllib2

from ckan.common import config
from paste.deploy.converters import asbool

import ckan.model as model
Expand All @@ -23,7 +22,6 @@
log = logging.getLogger(__name__)



def text_traceback():
with warnings.catch_warnings():
warnings.simplefilter("ignore")
Expand All @@ -32,7 +30,6 @@ def text_traceback():
).strip()
return res

SIMPLE_SEARCH = asbool(config.get('ckan.simple_search', False))

SUPPORTED_SCHEMA_VERSIONS = ['2.3']

Expand Down Expand Up @@ -60,11 +57,6 @@ def text_traceback():

SOLR_SCHEMA_FILE_OFFSET = '/admin/file/?file=schema.xml'

if SIMPLE_SEARCH:
import sql as sql
_INDICES['package'] = NoopSearchIndex
_QUERIES['package'] = sql.PackageSearchQuery


def _normalize_type(_type):
if isinstance(_type, model.domain_object.DomainObject):
Expand Down Expand Up @@ -219,6 +211,7 @@ def commit():
package_index.commit()
log.info('Commited pending changes on the search index')


def check():
package_query = query_for(model.Package)

Expand Down Expand Up @@ -249,10 +242,9 @@ def clear(package_reference):


def clear_all():
if not SIMPLE_SEARCH:
package_index = index_for(model.Package)
log.debug("Clearing search index...")
package_index.clear()
package_index = index_for(model.Package)
log.debug("Clearing search index...")
package_index.clear()


def check_solr_schema_version(schema_file=None):
Expand All @@ -276,11 +268,6 @@ def check_solr_schema_version(schema_file=None):
be only used for testing purposes (Default is None)
'''


if SIMPLE_SEARCH:
# Not using the SOLR search backend
return False

if not is_available():
# Something is wrong with the SOLR server
log.warn('Problems were found while connecting to the SOLR server')
Expand Down
42 changes: 0 additions & 42 deletions ckan/lib/search/sql.py

This file was deleted.

746 changes: 669 additions & 77 deletions ckan/public/base/vendor/moment-with-locales.js

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions ckan/tests/controllers/test_feed.py
Expand Up @@ -8,6 +8,10 @@

class TestFeedNew(helpers.FunctionalTestBase):

@classmethod
def teardown_class(cls):
helpers.reset_db()

def test_atom_feed_page_zero_gives_error(self):
group = factories.Group()
offset = url_for(controller='feed', action='group',
Expand All @@ -31,3 +35,49 @@ def test_atom_feed_page_not_int_gives_error(self):
app = self._get_test_app()
res = app.get(offset, status=400)
assert '"page" parameter must be a positive integer' in res, res

def test_general_atom_feed_works(self):
dataset = factories.Dataset()
offset = url_for(controller='feed', action='general')
app = self._get_test_app()
res = app.get(offset)

assert '<title>{0}</title>'.format(dataset['title']) in res.body

def test_group_atom_feed_works(self):
group = factories.Group()
dataset = factories.Dataset(groups=[{'id': group['id']}])
offset = url_for(controller='feed', action='group',
id=group['name'])
app = self._get_test_app()
res = app.get(offset)

assert '<title>{0}</title>'.format(dataset['title']) in res.body

def test_organization_atom_feed_works(self):
group = factories.Organization()
dataset = factories.Dataset(owner_org=group['id'])
offset = url_for(controller='feed', action='organization',
id=group['name'])
app = self._get_test_app()
res = app.get(offset)

assert '<title>{0}</title>'.format(dataset['title']) in res.body

def test_custom_atom_feed_works(self):
dataset1 = factories.Dataset(
title='Test weekly',
extras=[{'key': 'frequency', 'value': 'weekly'}])
dataset2 = factories.Dataset(
title='Test daily',
extras=[{'key': 'frequency', 'value': 'daily'}])
offset = url_for(controller='feed', action='custom')
params = {
'q': 'frequency:weekly'
}
app = self._get_test_app()
res = app.get(offset, params=params)

assert '<title>{0}</title>'.format(dataset1['title']) in res.body

assert '<title>{0}</title>'.format(dataset2['title']) not in res.body
37 changes: 0 additions & 37 deletions ckan/tests/legacy/lib/test_simple_search.py

This file was deleted.

2 changes: 1 addition & 1 deletion ckanext/datapusher/cli.py
Expand Up @@ -60,7 +60,7 @@ def _confirm_or_abort(self):
sys.exit(0)

def _resubmit_all(self):
resources_ids = datastore_db.get_all_resources_ids_in_datastore()
resource_ids = datastore_db.get_all_resources_ids_in_datastore()
self._submit(resource_ids)

def _submit_all_packages(self):
Expand Down
2 changes: 1 addition & 1 deletion ckanext/example_theme/custom_config_setting/plugin.py
@@ -1,9 +1,9 @@
# encoding: utf-8

import pylons.config as config

import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
from ckan.common import config


def show_most_popular_groups():
Expand Down
2 changes: 1 addition & 1 deletion ckanext/example_theme/custom_emails/tests.py
@@ -1,12 +1,12 @@
# encoding: utf-8

import os
from pylons import config
from ckan import plugins
import ckan.model as model
import ckan.lib.mailer as mailer
from ckan.tests import factories
from ckan.lib.base import render_jinja2
from ckan.common import config

from ckan.tests.lib.test_mailer import MailerBase
import ckan.tests.helpers as helpers
Expand Down
23 changes: 7 additions & 16 deletions ckanext/reclineview/plugin.py
Expand Up @@ -2,10 +2,9 @@

from logging import getLogger

from ckan.common import json
from ckan.common import json, config
import ckan.plugins as p
import ckan.plugins.toolkit as toolkit
from pylons import config

log = getLogger(__name__)
ignore_empty = p.toolkit.get_validator('ignore_empty')
Expand Down Expand Up @@ -59,6 +58,7 @@ class ReclineViewBase(p.SingletonPlugin):
'''
p.implements(p.IConfigurer, inherit=True)
p.implements(p.IResourceView, inherit=True)
p.implements(p.ITemplateHelpers, inherit=True)

def update_config(self, config):
'''
Expand All @@ -81,14 +81,17 @@ def setup_template_variables(self, context, data_dict):
def view_template(self, context, data_dict):
return 'recline_view.html'

def get_helpers(self):
return {
'get_map_config': get_mapview_config
}


class ReclineView(ReclineViewBase):
'''
This extension views resources using a Recline MultiView.
'''

p.implements(p.ITemplateHelpers, inherit=True)

def info(self):
return {'name': 'recline_view',
'title': 'Data Explorer',
Expand All @@ -110,11 +113,6 @@ def can_view(self, data_dict):
else:
return False

def get_helpers(self):
return {
'get_map_config': get_mapview_config
}


class ReclineGridView(ReclineViewBase):
'''
Expand Down Expand Up @@ -191,8 +189,6 @@ class ReclineMapView(ReclineViewBase):
This extension views resources using a Recline map.
'''

p.implements(p.ITemplateHelpers, inherit=True)

map_field_types = [{'value': 'lat_long',
'text': 'Latitude / Longitude fields'},
{'value': 'geojson', 'text': 'GeoJSON'}]
Expand Down Expand Up @@ -253,8 +249,3 @@ def setup_template_variables(self, context, data_dict):

def form_template(self, context, data_dict):
return 'recline_map_form.html'

def get_helpers(self):
return {
'get_mapview_config': get_mapview_config
}
2 changes: 1 addition & 1 deletion ckanext/reclineview/theme/templates/recline_view.html
Expand Up @@ -2,7 +2,7 @@

{% block page %}

{% set map_config = h.get_map_config() or h.get_mapview_config() %}
{% set map_config = h.get_map_config() %}
<div data-module="recline_view"
data-module-site_url="{{ h.dump_json(h.url('/', locale='default', qualified=true)) }}"
data-module-resource = "{{ h.dump_json(resource_json) }}";
Expand Down

0 comments on commit c207980

Please sign in to comment.