Skip to content

Commit

Permalink
Merge branch 'master' into 3196-common-requests-code
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Jan 4, 2017
2 parents 47d878e + 97da20e commit fbe614d
Show file tree
Hide file tree
Showing 114 changed files with 72 additions and 11 deletions.
7 changes: 7 additions & 0 deletions ckan/config/deployment.ini_tmpl
Expand Up @@ -106,6 +106,13 @@ ckan.plugins = stats text_view image_view recline_view
# (plugins must be loaded in ckan.plugins)
ckan.views.default_views = image_view text_view recline_view

# Customize which text formats the text_view plugin will show
#ckan.preview.json_formats = json
#ckan.preview.xml_formats = xml rdf rdf+xml owl+xml atom rss
#ckan.preview.text_formats = text plain text/plain

# Customize which image formats the image_view plugin will show
#ckan.preview.image_formats = png jpeg jpg gif

## Front-End Settings
ckan.site_title = CKAN
Expand Down
3 changes: 2 additions & 1 deletion ckan/lib/i18n.py
Expand Up @@ -36,6 +36,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''

import collections
import json
import logging
import os
Expand Down Expand Up @@ -362,7 +363,7 @@ def build_js_translations():
# Collect all language codes (an extension might add support for a
# language that isn't supported by CKAN core, yet).
langs = set()
i18n_dirs = {ckan_i18n_dir: u'ckan'}
i18n_dirs = collections.OrderedDict([(ckan_i18n_dir, u'ckan')])
for item in os.listdir(ckan_i18n_dir):
if os.path.isdir(os.path.join(ckan_i18n_dir, item)):
langs.add(item)
Expand Down
2 changes: 1 addition & 1 deletion ckan/logic/action/update.py
Expand Up @@ -994,7 +994,7 @@ def dashboard_mark_activities_old(context, data_dict):
model = context['model']
user_id = model.User.get(context['user']).id
model.Dashboard.get(user_id).activity_stream_last_viewed = (
datetime.datetime.now())
datetime.datetime.utcnow())
if not context.get('defer_commit'):
model.repo.commit()

Expand Down
4 changes: 2 additions & 2 deletions ckan/model/dashboard.py
Expand Up @@ -21,8 +21,8 @@ class Dashboard(object):

def __init__(self, user_id):
self.user_id = user_id
self.activity_stream_last_viewed = datetime.datetime.now()
self.email_last_sent = datetime.datetime.now()
self.activity_stream_last_viewed = datetime.datetime.utcnow()
self.email_last_sent = datetime.datetime.utcnow()

@classmethod
def get(cls, user_id):
Expand Down
Binary file modified ckan/public/base/images/background-tag-ie7.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/background-tag.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/background-tile.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/bg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/breadcrumb-slash-ie7.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/ckan-logo-footer.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/ckan-logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/dashboard-followee-related.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/dotted.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/editing.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/full-width-nav-right.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/icon-search-27x26.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/nav-active.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/nav.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/od_80x15_blue.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/placeholder-200x125.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/placeholder-420x220.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/placeholder-680x400.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/placeholder-application.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/placeholder-group.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/placeholder-image.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/placeholder-organization.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/sprite-ckan-icons.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/sprite-resource-icons.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/images/table-seperator.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ckan/public/base/vendor/bootstrap/img/glyphicons-halflings.png
Binary file modified ckan/public/base/vendor/select2/select2.png
Binary file modified ckan/public/base/vendor/select2/select2x2.png
Expand Up @@ -12,6 +12,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.1.1\n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

# Overriding a JS translation from CKAN core
msgid "Loading..."
Expand Down
34 changes: 34 additions & 0 deletions ckan/tests/lib/test_base.py
Expand Up @@ -3,7 +3,9 @@
from nose import tools as nose_tools

import ckan.tests.helpers as helpers

import ckan.plugins as p
import ckan.tests.factories as factories


class TestRenderSnippet(helpers.FunctionalTestBase):
Expand All @@ -21,6 +23,38 @@ def test_comment_absent_if_debug_false(self):
assert '<!-- Snippet ' not in response


class TestGetUserForApikey(helpers.FunctionalTestBase):

def test_apikey_missing(self):
app = self._get_test_app()
request_headers = {}

app.get('/dataset/new', headers=request_headers, status=403)

def test_apikey_in_authorization_header(self):
user = factories.Sysadmin()
app = self._get_test_app()
request_headers = {'Authorization': str(user['apikey'])}

app.get('/dataset/new', headers=request_headers)

def test_apikey_in_x_ckan_header(self):
user = factories.Sysadmin()
app = self._get_test_app()
# non-standard header name is defined in test-core.ini
request_headers = {'X-Non-Standard-CKAN-API-Key': str(user['apikey'])}

app.get('/dataset/new', headers=request_headers)

def test_apikey_contains_unicode(self):
# there is no valid apikey containing unicode, but we should fail
# nicely if unicode is supplied
app = self._get_test_app()
request_headers = {'Authorization': '\xc2\xb7'}

app.get('/dataset/new', headers=request_headers, status=403)


class TestCORS(helpers.FunctionalTestBase):

def test_options(self):
Expand Down
2 changes: 1 addition & 1 deletion ckan/views/__init__.py
Expand Up @@ -174,7 +174,7 @@ def _get_user_for_apikey():
if not apikey:
return None
log.debug(u'Received API Key: %s' % apikey)
apikey = unicode(apikey)
apikey = apikey.decode('utf8', 'ignore')
query = model.Session.query(model.User)
user = query.filter_by(apikey=apikey).first()
return user
7 changes: 5 additions & 2 deletions ckanext/imageview/plugin.py
Expand Up @@ -6,7 +6,7 @@
log = logging.getLogger(__name__)
ignore_empty = p.toolkit.get_validator('ignore_empty')

DEFAULT_IMAGE_FORMATS = ['png', 'jpeg', 'jpg', 'gif']
DEFAULT_IMAGE_FORMATS = 'png jpeg jpg gif'


class ImageView(p.SingletonPlugin):
Expand All @@ -17,6 +17,9 @@ class ImageView(p.SingletonPlugin):

def update_config(self, config):
p.toolkit.add_template_directory(config, 'theme/templates')
self.formats = config.get(
'ckan.preview.image_formats',
DEFAULT_IMAGE_FORMATS).split()

def info(self):
return {'name': 'image_view',
Expand All @@ -30,7 +33,7 @@ def info(self):

def can_view(self, data_dict):
return (data_dict['resource'].get('format', '').lower()
in DEFAULT_IMAGE_FORMATS)
in self.formats)

def view_template(self, context, data_dict):
return 'image_view.html'
Expand Down
Binary file modified doc/_static/ckanlogo.png
Binary file modified doc/images/9.png
Binary file modified doc/images/add_dataset_1.jpg
Binary file modified doc/images/add_dataset_2.jpg
Binary file modified doc/images/add_dataset_3.jpg
Binary file modified doc/images/architecture.png
Binary file modified doc/images/ckan_importing_diagram.png
Binary file modified doc/images/create_organization.jpg
Binary file modified doc/images/custom-css.png
Binary file modified doc/images/custom_config_fields.png
Binary file modified doc/images/customize_look_and_feel.jpg
Binary file modified doc/images/debug-footer.png
Binary file modified doc/images/edit_dataset.jpg
Binary file modified doc/images/example_theme_javascript_popover.png
Binary file modified doc/images/example_theme_overlapping_popovers.png
Binary file modified doc/images/exploring_datasets.jpg
Binary file modified doc/images/extra-public-dir.png
Binary file modified doc/images/html_and_css.png
Binary file modified doc/images/image_view.png
Binary file modified doc/images/manage_news_feed.jpg
Binary file modified doc/images/manage_organization.jpg
Binary file modified doc/images/manage_user_profile.jpg
Binary file modified doc/images/manage_users.jpg
Binary file modified doc/images/manage_views.png
Binary file modified doc/images/more-custom-css.png
Binary file modified doc/images/most-popular-groups-custom-snippet.png
Binary file modified doc/images/most-popular-groups-snippet.png
Binary file modified doc/images/most-popular-groups.png
Binary file modified doc/images/move_dataset_between_organizations.jpg
Binary file modified doc/images/popular-dataset.png
Binary file modified doc/images/popular-resource.png
Binary file modified doc/images/recently-changed-packages-activity-stream.png
Binary file modified doc/images/recline_graph_view.png
Binary file modified doc/images/recline_grid_view.png
Binary file modified doc/images/recline_map_view.png
Binary file modified doc/images/recline_view.png
Binary file modified doc/images/register_account.jpg
Binary file modified doc/images/search_the_site.jpg
Binary file modified doc/images/sort-datasets-by-popularity.png
Binary file modified doc/images/text_view.png
Binary file modified doc/images/views_overview.png
Binary file modified doc/images/webpage_view.png
19 changes: 16 additions & 3 deletions doc/maintaining/configuration.rst
Expand Up @@ -1186,7 +1186,7 @@ Example::

Default value: ``json``

JSON based resource formats that will be rendered by the Text view plugin (``text_view``)
Space-delimited list of JSON based resource formats that will be rendered by the Text view plugin (``text_view``)

.. _ckan.preview.xml_formats:

Expand All @@ -1199,7 +1199,7 @@ Example::

Default value: ``xml rdf rdf+xml owl+xml atom rss``

XML based resource formats that will be rendered by the Text view plugin (``text_view``)
Space-delimited list of XML based resource formats that will be rendered by the Text view plugin (``text_view``)

.. _ckan.preview.text_formats:

Expand All @@ -1212,7 +1212,20 @@ Example::

Default value: ``text plain text/plain``

Plain text based resource formats that will be rendered by the Text view plugin (``text_view``)
Space-delimited list of plain text based resource formats that will be rendered by the Text view plugin (``text_view``)

.. _ckan.preview.image_formats:

ckan.preview.image_formats
^^^^^^^^^^^^^^^^^^^^^^^^^^

Example::

ckan.preview.image_formats = png jpeg jpg gif

Default value: ``png jpeg jpg gif``

Space-delimited list of image-based resource formats that will be rendered by the Image view plugin (``image_view``)

.. end_resource-views
Expand Down
3 changes: 2 additions & 1 deletion doc/maintaining/data-viewer.rst
Expand Up @@ -200,7 +200,8 @@ View plugin: ``image_view``

If the resource format is a common image format like PNG, JPEG or GIF, it adds
an ``<img>`` tag pointing to the resource URL. You can provide an alternative
URL on the edit view form.
URL on the edit view form. The available formats can be configured using the
:ref:`ckan.preview.image_formats` configuration option.

Web page view
+++++++++++++
Expand Down

0 comments on commit fbe614d

Please sign in to comment.