From 1eb9d94077bd7d0dc586fefcb0d6b49042606b6c Mon Sep 17 00:00:00 2001
From: Sean Hammond
Date: Wed, 19 Jun 2013 15:27:33 +0200
Subject: [PATCH 01/21] [#1011] Fix a 500 to a 404
Catch Genshi TemplateNotFound errors when rendering the package read
page. This can happen if an IDatasetForm plugin returns a custom package
read template, e.g. 'read.html', but the user has requested the dataset
in RDF format and the plugin does not provide a corresponding 'read.rdf'
template. (CKAN will take the path to read.html, replace the filename
extension with rdf, try to render this non-existing template file, and
crash.)
Replace this crash with a proper 404.
Add to the IDatasetForm docs, explaining how to provide RDF templates
for datasets.
Fixes #1011.
---
ckan/controllers/package.py | 11 ++++++++++-
ckan/plugins/interfaces.py | 9 +++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py
index 65541ee33bf..693ceb851a2 100644
--- a/ckan/controllers/package.py
+++ b/ckan/controllers/package.py
@@ -5,6 +5,7 @@
from pylons import config
from genshi.template import MarkupTemplate
from genshi.template.text import NewTextTemplate
+import genshi.template.loader
from paste.deploy.converters import asbool
import ckan.logic as logic
@@ -352,7 +353,15 @@ def read(self, id, format='html'):
template = self._read_template(package_type)
template = template[:template.index('.') + 1] + format
- return render(template, loader_class=loader)
+ try:
+ return render(template, loader_class=loader)
+ except genshi.template.loader.TemplateNotFound:
+ msg = _("Viewing {package_type} datasets in {format} format is "
+ "not supported (template file {file} not found).".format(
+ package_type=package_type, format=format, file=template))
+ abort(404, msg)
+
+ assert False, "We should never get here"
def history(self, id):
package_type = self._get_package_type(id.split('@')[0])
diff --git a/ckan/plugins/interfaces.py b/ckan/plugins/interfaces.py
index a37d3c96ae8..826fec921cd 100644
--- a/ckan/plugins/interfaces.py
+++ b/ckan/plugins/interfaces.py
@@ -676,6 +676,15 @@ def read_template(self):
The path should be relative to the plugin's templates dir, e.g.
``'package/read.html'``.
+ If the user requests the dataset in a format other than HTML
+ (CKAN supports returning datasets in RDF or N3 format by appending .rdf
+ or .n3 to the dataset read URL, see :doc:`linked-data-and-rdf`) then
+ CKAN will try to render
+ a template file with the same path as returned by this function,
+ but a different filename extension, e.g. ``'package/read.rdf'``.
+ If your extension doesn't have this RDF version of the template
+ file, the user will get a 404 error.
+
:rtype: string
'''
From 25c80f16f57ecc34fda2d52bbd8d3a41e0b33d66 Mon Sep 17 00:00:00 2001
From: Dominik Moritz
Date: Sat, 6 Jul 2013 12:05:59 +0200
Subject: [PATCH 02/21] Add coverage reports with coveralls
---
.coveragerc | 3 +++
.travis.yml | 4 ++++
bin/travis-build | 2 +-
3 files changed, 8 insertions(+), 1 deletion(-)
create mode 100644 .coveragerc
diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 00000000000..28f34e39273
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,3 @@
+[run]
+omit = /ckan/migration/*
+source = ckan, ckanext
diff --git a/.travis.yml b/.travis.yml
index af450298b6c..b4f63b6c669 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,8 @@ python:
env:
- PGVERSION=9.1
- PGVERSION=8.4
+install:
+ - pip install coveralls --use-mirrors
script: ./bin/travis-build
notifications:
irc:
@@ -14,3 +16,5 @@ notifications:
on_failure: change
template:
- "%{repository} %{branch} %{commit} %{build_url} %{author}: %{message}"
+after_success:
+ - coveralls
diff --git a/bin/travis-build b/bin/travis-build
index df7c398d1b6..de7599cdddd 100755
--- a/bin/travis-build
+++ b/bin/travis-build
@@ -48,4 +48,4 @@ fi
cat test-core.ini
# And finally, run the tests
-nosetests --ckan --with-pylons=test-core.ini --nologcapture ckan ckanext
+nosetests --ckan --with-pylons=test-core.ini --nologcapture ckan ckanext --with-coverage --cover-package=ckanext --cover-package=ckan
From 4d2d54a6e3622cdf4526ab59002e19114e7776c0 Mon Sep 17 00:00:00 2001
From: Sean Hammond
Date: Thu, 18 Jul 2013 13:03:55 +0200
Subject: [PATCH 03/21] [#1011] Refactor an exception raise and catch
Raise and catch a CKAN exception, instead of a Genshi one.
---
ckan/controllers/package.py | 4 ++--
ckan/lib/base.py | 6 +-----
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py
index 693ceb851a2..d73ab4ee740 100644
--- a/ckan/controllers/package.py
+++ b/ckan/controllers/package.py
@@ -5,7 +5,6 @@
from pylons import config
from genshi.template import MarkupTemplate
from genshi.template.text import NewTextTemplate
-import genshi.template.loader
from paste.deploy.converters import asbool
import ckan.logic as logic
@@ -20,6 +19,7 @@
import ckan.lib.datapreview as datapreview
import ckan.lib.plugins
import ckan.plugins as p
+import lib.render
from ckan.common import OrderedDict, _, json, request, c, g, response
from home import CACHE_PARAMETERS
@@ -355,7 +355,7 @@ def read(self, id, format='html'):
try:
return render(template, loader_class=loader)
- except genshi.template.loader.TemplateNotFound:
+ except lib.render.TemplateNotFound:
msg = _("Viewing {package_type} datasets in {format} format is "
"not supported (template file {file} not found).".format(
package_type=package_type, format=format, file=template))
diff --git a/ckan/lib/base.py b/ckan/lib/base.py
index 7227734ddf4..914b42741ea 100644
--- a/ckan/lib/base.py
+++ b/ckan/lib/base.py
@@ -103,11 +103,7 @@ def render_template():
# we remove it so any bad templates crash and burn
del globs['url']
- try:
- template_path, template_type = lib.render.template_info(template_name)
- except lib.render.TemplateNotFound:
- template_type = 'genshi'
- template_path = ''
+ template_path, template_type = lib.render.template_info(template_name)
# snippets should not pass the context
# but allow for legacy genshi templates
From 98508d1a67b0ec0a86a1786988f3195d6535f2be Mon Sep 17 00:00:00 2001
From: Sean Hammond
Date: Mon, 26 Aug 2013 16:13:48 +0200
Subject: [PATCH 04/21] [#1011] Fix a broken import in the package controller
An exception was not getting caught because of the way this import was
done.
---
ckan/controllers/package.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py
index c9940cd57ac..e23c6e39fa1 100644
--- a/ckan/controllers/package.py
+++ b/ckan/controllers/package.py
@@ -19,7 +19,7 @@
import ckan.lib.datapreview as datapreview
import ckan.lib.plugins
import ckan.plugins as p
-import lib.render
+import ckan.lib.render
from ckan.common import OrderedDict, _, json, request, c, g, response
from home import CACHE_PARAMETERS
@@ -366,7 +366,7 @@ def read(self, id, format='html'):
try:
return render(template, loader_class=loader)
- except lib.render.TemplateNotFound:
+ except ckan.lib.render.TemplateNotFound:
msg = _("Viewing {package_type} datasets in {format} format is "
"not supported (template file {file} not found).".format(
package_type=package_type, format=format, file=template))
From 2d3bcdd7a04b27be135045cf388ef9c983a3c16a Mon Sep 17 00:00:00 2001
From: Sean Hammond
Date: Mon, 26 Aug 2013 16:14:47 +0200
Subject: [PATCH 05/21] [#1011] base.py: Explicitly re-raise TemplateNotFound
Functions should not implicitly raise exceptions by failing to catch
exceptions raised by functions that they call, they should explicitly
catch and re-raise the exceptions instead.
---
ckan/lib/base.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/ckan/lib/base.py b/ckan/lib/base.py
index a91a1170135..cf5cf031f76 100644
--- a/ckan/lib/base.py
+++ b/ckan/lib/base.py
@@ -104,7 +104,10 @@ def render_template():
# we remove it so any bad templates crash and burn
del globs['url']
- template_path, template_type = render_.template_info(template_name)
+ try:
+ template_path, template_type = render_.template_info(template_name)
+ except render_.TemplateNotFound:
+ raise
# snippets should not pass the context
# but allow for legacy genshi templates
@@ -202,6 +205,8 @@ def render_template():
raise ckan.exceptions.CkanUrlException(
'\nAn Exception has been raised for template %s\n%s' %
(template_name, e.message))
+ except render_.TemplateNotFound:
+ raise
class ValidationException(Exception):
From c136aac9c65fcde7c03a2e1c7a9e88e4b5b2f595 Mon Sep 17 00:00:00 2001
From: Sean Hammond
Date: Mon, 26 Aug 2013 16:16:03 +0200
Subject: [PATCH 06/21] [#1011] Update some exception handling in template.py
Catch the new ckan.lib.render.TemplateNotFound exception that render()
now raises, not the Genshi exception it used to.
---
ckan/controllers/template.py | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/ckan/controllers/template.py b/ckan/controllers/template.py
index 1ebc700345b..0755b1a2cf5 100644
--- a/ckan/controllers/template.py
+++ b/ckan/controllers/template.py
@@ -1,6 +1,5 @@
-from genshi.template.loader import TemplateNotFound
-
import ckan.lib.base as base
+import ckan.lib.render
class TemplateController(base.BaseController):
@@ -29,11 +28,11 @@ def view(self, url):
"""
try:
return base.render(url)
- except TemplateNotFound:
+ except ckan.lib.render.TemplateNotFound:
if url.endswith('.html'):
base.abort(404)
url += '.html'
try:
return base.render(url)
- except TemplateNotFound:
+ except ckan.lib.render.TemplateNotFound:
base.abort(404)
From 55ed1ef2b6d4eca22c324ddf627eb7fe1e0a4d24 Mon Sep 17 00:00:00 2001
From: amercader
Date: Thu, 12 Sep 2013 18:39:42 +0100
Subject: [PATCH 07/21] [#1241] Raise CkanVersionException properly
---
ckan/plugins/toolkit.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ckan/plugins/toolkit.py b/ckan/plugins/toolkit.py
index 4e4ac5da2d0..34e9d671cf1 100644
--- a/ckan/plugins/toolkit.py
+++ b/ckan/plugins/toolkit.py
@@ -348,7 +348,7 @@ def _requires_ckan_version(cls, min_version, max_version=None):
else:
error = 'Requires ckan version between %s and %s' % \
(min_version, max_version)
- raise cls.CkanVersionException(error)
+ raise CkanVersionException(error)
def __getattr__(self, name):
''' return the function/object requested '''
From 5813ae1f4b3dd0acde1e78a21b13cc533388e8e3 Mon Sep 17 00:00:00 2001
From: John Martin
Date: Wed, 18 Sep 2013 14:27:42 +0100
Subject: [PATCH 08/21] [#1092] Updates helper text for orgs, groups and
datasets
---
ckan/templates/group/snippets/helper.html | 15 ++++++++-------
ckan/templates/organization/snippets/helper.html | 16 +++++++---------
ckan/templates/package/base_form_page.html | 6 +++---
3 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/ckan/templates/group/snippets/helper.html b/ckan/templates/group/snippets/helper.html
index a73c9d6dde7..38585ab7eae 100644
--- a/ckan/templates/group/snippets/helper.html
+++ b/ckan/templates/group/snippets/helper.html
@@ -4,12 +4,13 @@
{{ _('What are Groups?') }}
- {% trans %}
-
Groups allow you to group together datasets under a community (for
- example, Civil Liberty data) or topic (e.g. Transport, Health,
- Environment) to make it easier for users to browse datasets by theme.
- Datasets can be part of a group, but do not belong to the group for
- editing or authorisation purposes.
- {% endtrans %}
+
+ {% trans %}
+ You can use CKAN Groups to create and manage collections of datasets.
+ This could be to catalogue datasets for a particular project or team,
+ or on a particular theme, or as a very simple way to help people find
+ and search your own published datasets.
+ {% endtrans %}
+
\ No newline at end of file
diff --git a/ckan/templates/organization/snippets/helper.html b/ckan/templates/organization/snippets/helper.html
index f0acbd46d73..6ec71c0d67e 100644
--- a/ckan/templates/organization/snippets/helper.html
+++ b/ckan/templates/organization/snippets/helper.html
@@ -4,14 +4,12 @@
{{ _('What are Organizations?') }}
- {% trans %}
-
Organizations act like publishing departments for datasets (for
- example, the Department of Health). This means that datasets can be
- published by and belong to a department instead of an individual
- user.
-
Within organizations, admins can assign roles and authorisation its
- members, giving individual users the right to publish datasets from
- that particular organisation (e.g. Office of National Statistics).
- {% endtrans %}
+
+ {% trans %}
+ CKAN Organizations are used to create, manage and publish collections
+ of datasets. Users can have different roles within an Organization,
+ depending on their level of authorisation to create, edit and publish.
+ {% endtrans %}
+
\ No newline at end of file
diff --git a/ckan/templates/package/base_form_page.html b/ckan/templates/package/base_form_page.html
index 049d83b1ebb..a738a8716c8 100644
--- a/ckan/templates/package/base_form_page.html
+++ b/ckan/templates/package/base_form_page.html
@@ -15,9 +15,9 @@ {{ _('What are dataset
{% trans %}
- Datasets are simply used to group related pieces of data. These
- can then be found under a single url with a description and
- licensing information.
+ A CKAN Dataset is a collection of data resources (such as files),
+ together with a description and other information, at a fixed URL.
+ Datasets are what users see when searching for data.
{% endtrans %}
From dad667eb4233b00561167db2aff41092afecfd2d Mon Sep 17 00:00:00 2001
From: Dominik Moritz
Date: Mon, 7 Oct 2013 13:35:25 -0700
Subject: [PATCH 09/21] Correct encoding to make coveralls work
---
ckan/config/environment.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ckan/config/environment.py b/ckan/config/environment.py
index 49be9b726a6..409f77435a4 100644
--- a/ckan/config/environment.py
+++ b/ckan/config/environment.py
@@ -159,7 +159,7 @@ def find_controller(self, controller):
'''
This code is based on Genshi code
- Copyright © 2006-2012 Edgewall Software
+ Copyright © 2006-2012 Edgewall Software
All rights reserved.
Redistribution and use in source and binary forms, with or
From a903ef999d8d67db48118ea8413595707c2e3080 Mon Sep 17 00:00:00 2001
From: Dominik Moritz
Date: Mon, 7 Oct 2013 14:20:57 -0700
Subject: [PATCH 10/21] Add test coverage banner to readme
---
README.rst | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README.rst b/README.rst
index 93d80e668cc..2eafd662e07 100644
--- a/README.rst
+++ b/README.rst
@@ -5,6 +5,10 @@ CKAN: The Open Source Data Portal Software
:target: http://travis-ci.org/okfn/ckan
:alt: Build Status
+.. image:: https://coveralls.io/repos/okfn/ckan/badge.png?branch=coveralls
+ :target: https://coveralls.io/r/okfn/ckan?branch=coveralls
+ :alt: Test coverage
+
**CKAN is the world’s leading open-source data portal platform**.
CKAN makes it easy to publish, share and work with data. It's a data management
system that provides a powerful platform for cataloging, storing and accessing
From 5ad2c9bc8d651c31b302499780b6926b7a798ebc Mon Sep 17 00:00:00 2001
From: Dominik Moritz
Date: Mon, 7 Oct 2013 14:25:57 -0700
Subject: [PATCH 11/21] Don't cover tests files
---
.coveragerc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.coveragerc b/.coveragerc
index 28f34e39273..ed2c3b6bc6f 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -1,3 +1,3 @@
[run]
-omit = /ckan/migration/*
+omit = /ckan/migration/*, /ckan/tests/*, */tests/*
source = ckan, ckanext
From 23cfdbee2fcbc9267f66f06b6ecf9a879c92241f Mon Sep 17 00:00:00 2001
From: John Martin
Date: Tue, 8 Oct 2013 16:44:23 +0100
Subject: [PATCH 12/21] [#1269] First working version of the proper IA for
resources
---
ckan/config/routing.py | 7 ++--
ckan/templates/package/edit.html | 29 ++------------
ckan/templates/package/edit_base.html | 23 +++++++++++
ckan/templates/package/new_resource.html | 29 ++++----------
ckan/templates/package/read_base.html | 15 +------
ckan/templates/package/resource_edit.html | 25 ++----------
.../templates/package/resource_edit_base.html | 28 +++++++++++++
ckan/templates/package/snippets/info.html | 40 ++++++++-----------
8 files changed, 85 insertions(+), 111 deletions(-)
create mode 100644 ckan/templates/package/edit_base.html
create mode 100644 ckan/templates/package/resource_edit_base.html
diff --git a/ckan/config/routing.py b/ckan/config/routing.py
index 0fbb02bb886..33175a35c12 100644
--- a/ckan/config/routing.py
+++ b/ckan/config/routing.py
@@ -222,7 +222,6 @@ def make_map():
])))
m.connect('/dataset/{action}/{id}',
requirements=dict(action='|'.join([
- 'edit',
'new_metadata',
'new_resource',
'history',
@@ -234,6 +233,8 @@ def make_map():
'delete',
'api_data',
])))
+ m.connect('dataset_edit', '/dataset/edit/{id}', action='edit',
+ ckan_icon='edit')
m.connect('dataset_followers', '/dataset/followers/{id}',
action='followers', ckan_icon='group')
m.connect('dataset_activity', '/dataset/activity/{id}',
@@ -246,8 +247,8 @@ def make_map():
action='resource_read')
m.connect('/dataset/{id}/resource_delete/{resource_id}',
action='resource_delete')
- m.connect('/dataset/{id}/resource_edit/{resource_id}',
- action='resource_edit')
+ m.connect('resource_edit', '/dataset/{id}/resource_edit/{resource_id}',
+ action='resource_edit', ckan_icon='edit')
m.connect('/dataset/{id}/resource/{resource_id}/download',
action='resource_download')
m.connect('/dataset/{id}/resource/{resource_id}/embed',
diff --git a/ckan/templates/package/edit.html b/ckan/templates/package/edit.html
index 4f15985d033..dec84769ac4 100644
--- a/ckan/templates/package/edit.html
+++ b/ckan/templates/package/edit.html
@@ -1,28 +1,5 @@
-{% extends 'package/base_form_page.html' %}
+{% extends 'package/edit_base.html' %}
-{% set pkg = c.pkg_dict %}
-
-{% block breadcrumb_content_selected %}{% endblock %}
-
-{% block breadcrumb_content %}
- {{ super() }}
- {% link_for _('Edit'), controller='package', action='edit', id=pkg.name %}
-{% endblock %}
-
-{% block resources_module %}
- {% snippet 'package/snippets/resources.html', pkg=pkg, action='resource_edit' %}
-{% endblock %}
-
-{% block content_action %}
- {% link_for _('View dataset'), controller='package', action='read', id=pkg.name, class_='btn', icon='eye-open' %}
+{% block primary_content_inner %}
+ {% block form %}{{ c.form | safe }}{% endblock %}
{% endblock %}
-
-{% block secondary_content %}
- {% snippet 'package/snippets/info.html', pkg=pkg, action='package_edit' %}
-{% endblock %}
-
-{% block primary_content %}
-
- {{ super() }}
-{% endblock %}
-
diff --git a/ckan/templates/package/edit_base.html b/ckan/templates/package/edit_base.html
new file mode 100644
index 00000000000..df1d91dfb02
--- /dev/null
+++ b/ckan/templates/package/edit_base.html
@@ -0,0 +1,23 @@
+{% extends 'package/base.html' %}
+
+{% set pkg = c.pkg_dict %}
+
+{% block breadcrumb_content_selected %}{% endblock %}
+
+{% block breadcrumb_content %}
+ {{ super() }}
+ {% link_for _('Edit'), controller='package', action='edit', id=pkg.name %}
+{% endblock %}
+
+{% block content_action %}
+ {% link_for _('View dataset'), controller='package', action='read', id=pkg.name, class_='btn', icon='eye-open' %}
+{% endblock %}
+
+{% block content_primary_nav %}
+ {{ h.build_nav_icon('dataset_edit', _('Edit'), id=pkg.name) }}
+ {#{{ h.build_nav_icon('dataset_resources', _('Resources'), id=pkg.name) }}#}
+{% endblock %}
+
+{% block secondary_content %}
+ {% snippet 'package/snippets/info.html', pkg=pkg, hide_follow_button=true %}
+{% endblock %}
diff --git a/ckan/templates/package/new_resource.html b/ckan/templates/package/new_resource.html
index 13cce195453..49d02387768 100644
--- a/ckan/templates/package/new_resource.html
+++ b/ckan/templates/package/new_resource.html
@@ -1,10 +1,6 @@
{% extends "package/base_form_page.html" %}
-{% if c.userobj %}
- {% set logged_in = true %}
-{% else %}
- {% set logged_in = false %}
-{% endif %}
+{% set logged_in = true if c.userobj else false %}
{% block subtitle %}{{ _('Add data to the dataset') }}{% endblock %}
@@ -17,26 +13,15 @@
{% block form %}{% snippet 'package/snippets/resource_form.html', data=data, errors=errors, error_summary=error_summary, include_metadata=false, pkg_name=pkg_name, stage=stage, allow_upload=g.ofs_impl and logged_in %}{% endblock %}
{% block secondary_content %}
- {% if pkg_dict and pkg_dict.state != 'draft' %}
- {% snippet 'package/snippets/info.html', pkg=pkg_dict, action='resource_new' %}
- {% else %}
-
- {{ _('What\'s a resource?') }}
-
-
{{ _('A resource can be any file or link to a file containing useful data.') }}
-
-
- {% endif %}
+
+ {{ _('What\'s a resource?') }}
+
+
{{ _('A resource can be any file or link to a file containing useful data.') }}
+
+
{% endblock %}
{% block scripts %}
{{ super() }}
{% resource 'vendor/fileupload' %}
{% endblock %}
-
-{% block primary_content %}
- {% if pkg_dict and pkg_dict.state != 'draft' %}
-
- {% endif %}
- {{ super() }}
-{% endblock %}
diff --git a/ckan/templates/package/read_base.html b/ckan/templates/package/read_base.html
index 9cf73a5c5a1..f0a58a21018 100644
--- a/ckan/templates/package/read_base.html
+++ b/ckan/templates/package/read_base.html
@@ -50,20 +50,7 @@
{% block secondary_help_content %}{% endblock %}
{% block package_info %}
-
-
-
{{ pkg.title or pkg.name }}
-
-
- - {{ _('Followers') }}
- - {{ h.SI_number_span(h.get_action('dataset_follower_count', {'id': pkg.id})) }}
-
-
-
- {{ h.follow_button('dataset', pkg.name) }}
-
-
-
+ {% snippet 'package/snippets/info.html', pkg=pkg %}
{% endblock %}
{% block package_organization %}
diff --git a/ckan/templates/package/resource_edit.html b/ckan/templates/package/resource_edit.html
index 52ac2ab4722..ab4b9aaa606 100644
--- a/ckan/templates/package/resource_edit.html
+++ b/ckan/templates/package/resource_edit.html
@@ -1,24 +1,5 @@
-{% extends "package/new_resource.html" %}
+{% extends "package/resource_edit_base.html" %}
-{% set pkg_dict = c.pkg_dict %}
-{% set res = c.resource %}
-
-{% block subtitle %}{{ h.dataset_display_name(pkg_dict) }} - {{ h.resource_display_name(res) }}{% endblock %}
-
-{% block breadcrumb_content_selected %}{% endblock %}
-
-{% block breadcrumb_content %}
- {{ super() }}
- {{ _('Edit') }}
-{% endblock %}
-
-{% block content_action %}
- {% link_for _('View resource'), controller='package', action='resource_read', id=pkg_dict.name, resource_id=res.id, class_='btn', icon='eye-open' %}
-{% endblock %}
-
-{# logged_in is defined in new_resource.html #}
-{% block form %}{{ h.snippet('package/snippets/resource_edit_form.html', data=data, errors=errors, error_summary=error_summary, pkg_name=pkg_dict.name, form_action=c.form_action, allow_upload=g.ofs_impl and logged_in) }}{% endblock %}
-
-{% block secondary_content %}
- {% snippet 'package/snippets/info.html', pkg=pkg_dict, active=data.id, action='resource_edit' %}
+{% block primary_content_inner %}
+ {{ h.snippet('package/snippets/resource_edit_form.html', data=data, errors=errors, error_summary=error_summary, pkg_name=pkg_dict.name, form_action=c.form_action, allow_upload=g.ofs_impl and logged_in) }}
{% endblock %}
diff --git a/ckan/templates/package/resource_edit_base.html b/ckan/templates/package/resource_edit_base.html
new file mode 100644
index 00000000000..fba67b43c80
--- /dev/null
+++ b/ckan/templates/package/resource_edit_base.html
@@ -0,0 +1,28 @@
+{% extends "package/base.html" %}
+
+{% set logged_in = true if c.userobj else false %}
+{% set pkg_dict = c.pkg_dict %}
+{% set res = c.resource %}
+
+{% block subtitle %}{{ _('Edit') }} - {{ h.resource_display_name(res) }} - {{ h.dataset_display_name(pkg_dict) }}{% endblock %}
+
+{% block breadcrumb_content_selected %}{% endblock %}
+
+{% block breadcrumb_content %}
+ {{ super() }}
+ {% link_for h.resource_display_name(res)|truncate(30), controller='package', action='resource_read', id=pkg_dict.name, resource_id=res.id %}
+ {{ _('Edit') }}
+{% endblock %}
+
+{% block content_action %}
+ {% link_for _('View resource'), controller='package', action='resource_read', id=pkg_dict.name, resource_id=res.id, class_='btn', icon='eye-open' %}
+{% endblock %}
+
+{% block content_primary_nav %}
+ {{ h.build_nav_icon('resource_edit', _('Edit'), id=pkg.name, resource_id=res.id) }}
+ {#{{ h.build_nav_icon('dataset_resources', _('Resources'), id=pkg.name) }}#}
+{% endblock %}
+
+{% block secondary_content %}
+ {% snippet 'package/snippets/info.html', pkg=pkg, hide_follow_button=true %}
+{% endblock %}
diff --git a/ckan/templates/package/snippets/info.html b/ckan/templates/package/snippets/info.html
index 49efa7b8fc7..b12ce3f6998 100644
--- a/ckan/templates/package/snippets/info.html
+++ b/ckan/templates/package/snippets/info.html
@@ -2,33 +2,25 @@
Displays a sidebard module with information for given package
pkg - The package dict that owns the resources.
-active - The active resource.
-action - The action that this is coming from.
Example:
{% snippet "package/snippets/info.html", pkg=pkg %}
#}
-{% if pkg and h.check_access('package_update', {'id':pkg.id }) %}
-
- {{ _("Edit Dataset") }}
-
- -
- {% link_for h.dataset_display_name(pkg)|truncate(30), controller='package', action='edit', id=pkg.name %}
-
-
- {% set resources = pkg.resources or [] %}
- {{ _("Edit Resources") }}
-
- {% block package_resource_list %}
- {% for resource in resources %}
- -
- {% link_for h.resource_display_name(resource)|truncate(30), controller='package', action='resource_edit', id=pkg.name, resource_id=resource.id, inner_span=true %}
-
- {% endfor %}
- {% endblock %}
- - {{ _('Add New Resource') }}
-
-
-{% endif %}
+
+
+
{{ pkg.title or pkg.name }}
+
+
+ - {{ _('Followers') }}
+ - {{ h.SI_number_span(h.get_action('dataset_follower_count', {'id': pkg.id})) }}
+
+
+ {% if not hide_follow_button %}
+
+ {{ h.follow_button('dataset', pkg.name) }}
+
+ {% endif %}
+
+
From 48041a4e40e837f3f84ea9bb4f7cd94918daa21a Mon Sep 17 00:00:00 2001
From: John Martin
Date: Wed, 9 Oct 2013 12:03:04 +0100
Subject: [PATCH 13/21] [#1269] Adds resource listing page within edit dataset
section
- Also tidys up the edit dataset templats
- Adds a new state to the new resource action that uses a different
template when dataset is no in draft mode (e.g. it's not part of the
dataset wizard creation any more)
---
ckan/config/routing.py | 2 ++
ckan/controllers/package.py | 30 ++++++++++++++++++-
ckan/templates/package/edit.html | 2 ++
ckan/templates/package/edit_base.html | 4 +--
.../package/new_resource_not_draft.html | 8 +++++
ckan/templates/package/resource_edit.html | 8 +++--
.../templates/package/resource_edit_base.html | 28 +++++------------
ckan/templates/package/resources.html | 21 +++++++++++++
.../package/snippets/resource_item.html | 15 +++++++++-
9 files changed, 92 insertions(+), 26 deletions(-)
create mode 100644 ckan/templates/package/new_resource_not_draft.html
create mode 100644 ckan/templates/package/resources.html
diff --git a/ckan/config/routing.py b/ckan/config/routing.py
index 33175a35c12..9ef4e0895eb 100644
--- a/ckan/config/routing.py
+++ b/ckan/config/routing.py
@@ -241,6 +241,8 @@ def make_map():
action='activity', ckan_icon='time')
m.connect('/dataset/activity/{id}/{offset}', action='activity')
m.connect('/dataset/{id}.{format}', action='read')
+ m.connect('dataset_resources', '/dataset/resources/{id}',
+ action='resources', ckan_icon='reorder')
m.connect('dataset_read', '/dataset/{id}', action='read',
ckan_icon='sitemap')
m.connect('/dataset/{id}/resource/{resource_id}',
diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py
index d1852cd95b7..8468dfa3947 100644
--- a/ckan/controllers/package.py
+++ b/ckan/controllers/package.py
@@ -301,6 +301,31 @@ def _content_type_from_accept(self):
ct, mu, ext = accept.parse_header(request.headers.get('Accept', ''))
return ct, ext, (NewTextTemplate, MarkupTemplate)[mu]
+ def resources(self, id):
+ package_type = self._get_package_type(id.split('@')[0])
+ context = {'model': model, 'session': model.Session,
+ 'user': c.user or c.author, 'for_view': True,
+ 'auth_user_obj': c.userobj}
+ data_dict = {'id': id}
+
+ try:
+ check_access('package_update', context)
+ except NotAuthorized, e:
+ abort(401, _('User %r not authorized to edit %s') % (c.user, id))
+ # check if package exists
+ try:
+ c.pkg_dict = get_action('package_show')(context, data_dict)
+ c.pkg = context['package']
+ except NotFound:
+ abort(404, _('Dataset not found'))
+ except NotAuthorized:
+ abort(401, _('Unauthorized to read package %s') % id)
+
+ self._setup_template_variables(context, {'id': id},
+ package_type=package_type)
+
+ return render('package/resources.html')
+
def read(self, id, format='html'):
if not format == 'html':
ctype, extension, loader = \
@@ -666,11 +691,14 @@ def new_resource(self, id, data=None, errors=None, error_summary=None):
abort(404, _('The dataset {id} could not be found.').format(id=id))
# required for nav menu
vars['pkg_dict'] = pkg_dict
+ template = 'package/new_resource_not_draft.html'
if pkg_dict['state'] == 'draft':
vars['stage'] = ['complete', 'active']
+ template = 'package/new_resource.html'
elif pkg_dict['state'] == 'draft-complete':
vars['stage'] = ['complete', 'active', 'complete']
- return render('package/new_resource.html', extra_vars=vars)
+ template = 'package/new_resource.html'
+ return render(template, extra_vars=vars)
def new_metadata(self, id, data=None, errors=None, error_summary=None):
''' FIXME: This is a temporary action to allow styling of the
diff --git a/ckan/templates/package/edit.html b/ckan/templates/package/edit.html
index dec84769ac4..565623f7ebd 100644
--- a/ckan/templates/package/edit.html
+++ b/ckan/templates/package/edit.html
@@ -1,5 +1,7 @@
{% extends 'package/edit_base.html' %}
+{% block subtitle %}{{ _('Edit') }} - {{ h.dataset_display_name(pkg) }}{% endblock %}
+
{% block primary_content_inner %}
{% block form %}{{ c.form | safe }}{% endblock %}
{% endblock %}
diff --git a/ckan/templates/package/edit_base.html b/ckan/templates/package/edit_base.html
index df1d91dfb02..e8b785712b3 100644
--- a/ckan/templates/package/edit_base.html
+++ b/ckan/templates/package/edit_base.html
@@ -14,8 +14,8 @@
{% endblock %}
{% block content_primary_nav %}
- {{ h.build_nav_icon('dataset_edit', _('Edit'), id=pkg.name) }}
- {#{{ h.build_nav_icon('dataset_resources', _('Resources'), id=pkg.name) }}#}
+ {{ h.build_nav_icon('dataset_edit', _('Edit metadata'), id=pkg.name) }}
+ {{ h.build_nav_icon('dataset_resources', _('Resources'), id=pkg.name) }}
{% endblock %}
{% block secondary_content %}
diff --git a/ckan/templates/package/new_resource_not_draft.html b/ckan/templates/package/new_resource_not_draft.html
new file mode 100644
index 00000000000..a24f37ce459
--- /dev/null
+++ b/ckan/templates/package/new_resource_not_draft.html
@@ -0,0 +1,8 @@
+{% extends "package/resource_edit_base.html" %}
+
+{% block subtitle %}{{ _('Add resource') }} - {{ h.dataset_display_name(pkg) }}{% endblock %}
+{% block form_title %}{{ _('Add resource') }}{% endblock %}
+
+{% block form %}
+ {% snippet 'package/snippets/resource_form.html', data=data, errors=errors, error_summary=error_summary, include_metadata=false, pkg_name=pkg_name, stage=stage, allow_upload=g.ofs_impl and logged_in %}
+{% endblock %}
diff --git a/ckan/templates/package/resource_edit.html b/ckan/templates/package/resource_edit.html
index ab4b9aaa606..9756c8f9581 100644
--- a/ckan/templates/package/resource_edit.html
+++ b/ckan/templates/package/resource_edit.html
@@ -1,5 +1,9 @@
{% extends "package/resource_edit_base.html" %}
-{% block primary_content_inner %}
- {{ h.snippet('package/snippets/resource_edit_form.html', data=data, errors=errors, error_summary=error_summary, pkg_name=pkg_dict.name, form_action=c.form_action, allow_upload=g.ofs_impl and logged_in) }}
+{% set res = c.resource %}
+
+{% block subtitle %}{{ _('Edit') }} - {{ h.resource_display_name(res) }} - {{ h.dataset_display_name(pkg) }}{% endblock %}
+
+{% block form %}
+ {{ h.snippet('package/snippets/resource_edit_form.html', data=data, errors=errors, error_summary=error_summary, pkg_name=pkg.name, form_action=c.form_action, allow_upload=g.ofs_impl and logged_in) }}
{% endblock %}
diff --git a/ckan/templates/package/resource_edit_base.html b/ckan/templates/package/resource_edit_base.html
index fba67b43c80..7c3a8d012ec 100644
--- a/ckan/templates/package/resource_edit_base.html
+++ b/ckan/templates/package/resource_edit_base.html
@@ -1,28 +1,16 @@
-{% extends "package/base.html" %}
+{% extends "package/edit_base.html" %}
{% set logged_in = true if c.userobj else false %}
-{% set pkg_dict = c.pkg_dict %}
-{% set res = c.resource %}
-
-{% block subtitle %}{{ _('Edit') }} - {{ h.resource_display_name(res) }} - {{ h.dataset_display_name(pkg_dict) }}{% endblock %}
{% block breadcrumb_content_selected %}{% endblock %}
-{% block breadcrumb_content %}
- {{ super() }}
- {% link_for h.resource_display_name(res)|truncate(30), controller='package', action='resource_read', id=pkg_dict.name, resource_id=res.id %}
- {{ _('Edit') }}
-{% endblock %}
-
-{% block content_action %}
- {% link_for _('View resource'), controller='package', action='resource_read', id=pkg_dict.name, resource_id=res.id, class_='btn', icon='eye-open' %}
+{% block primary_content_inner %}
+ {% link_for _('View all resources'), controller='package', action='resources', id=pkg.name, class_='btn pull-right', icon='arrow-left' %}
+ {% block form_title %}{{ _('Edit resource') }}{% endblock %}
+ {% block form %}{% endblock %}
{% endblock %}
-{% block content_primary_nav %}
- {{ h.build_nav_icon('resource_edit', _('Edit'), id=pkg.name, resource_id=res.id) }}
- {#{{ h.build_nav_icon('dataset_resources', _('Resources'), id=pkg.name) }}#}
-{% endblock %}
-
-{% block secondary_content %}
- {% snippet 'package/snippets/info.html', pkg=pkg, hide_follow_button=true %}
+{% block scripts %}
+ {{ super() }}
+ {% resource 'vendor/fileupload' %}
{% endblock %}
diff --git a/ckan/templates/package/resources.html b/ckan/templates/package/resources.html
new file mode 100644
index 00000000000..e353d03f10b
--- /dev/null
+++ b/ckan/templates/package/resources.html
@@ -0,0 +1,21 @@
+{% extends "package/edit_base.html" %}
+
+{% block subtitle %}{{ _('Resources') }} - {{ h.dataset_display_name(pkg) }}{% endblock %}
+
+{% block page_primary_action %}
+ {% link_for _('Add new resource'), controller='package', action='new_resource', id=c.pkg_dict.name, class_='btn btn-primary', icon='plus' %}
+{% endblock %}
+
+{% block primary_content_inner %}
+ {% if pkg.resources %}
+
+ {% for resource in pkg.resources %}
+ {% snippet 'package/snippets/resource_item.html', pkg=pkg, res=resource, url_is_edit=true %}
+ {% endfor %}
+
+ {% else %}
+ {% trans url=h.url_for(controller='package', action='new_resource', id=pkg.name) %}
+ This dataset has no data, why not add some?
+ {% endtrans %}
+ {% endif %}
+{% endblock %}
diff --git a/ckan/templates/package/snippets/resource_item.html b/ckan/templates/package/snippets/resource_item.html
index fccd94ff4d2..c5b22521d64 100644
--- a/ckan/templates/package/snippets/resource_item.html
+++ b/ckan/templates/package/snippets/resource_item.html
@@ -1,4 +1,7 @@
-{% set url = h.url_for(controller='package', action='resource_read', id=pkg.name, resource_id=res.id) %}
+{% set can_edit = h.check_access('package_update', {'id':pkg.id }) %}
+{% set url_action = 'resource_edit' if url_is_edit and can_edit else 'resource_read' %}
+{% set url = h.url_for(controller='package', action=url_action, id=pkg.name, resource_id=res.id) %}
+
{% block resource_item_title %}
@@ -14,6 +17,7 @@
{% endif %}
{% block resource_item_explore %}
+ {% if not url_is_edit %}
+ {% endif %}
{% endblock %}
From f5d168cd9018d68868644188dded4dd2b6b01f36 Mon Sep 17 00:00:00 2001
From: amercader
Date: Tue, 15 Oct 2013 13:35:08 +0100
Subject: [PATCH 14/21] [#1256] Don't load the synchronous_search plugin on cli
It is already loaded on startup
---
ckan/lib/cli.py | 6 ------
1 file changed, 6 deletions(-)
diff --git a/ckan/lib/cli.py b/ckan/lib/cli.py
index 14c217ed096..c74c25e85e2 100644
--- a/ckan/lib/cli.py
+++ b/ckan/lib/cli.py
@@ -842,12 +842,10 @@ def show(self, dataset_ref):
pprint.pprint(dataset.as_dict())
def delete(self, dataset_ref):
- from ckan import plugins
import ckan.model as model
dataset = self._get_dataset(dataset_ref)
old_state = dataset.state
- plugins.load('synchronous_search')
rev = model.repo.new_revision()
dataset.delete()
model.repo.commit_and_remove()
@@ -855,12 +853,10 @@ def delete(self, dataset_ref):
print '%s %s -> %s' % (dataset.name, old_state, dataset.state)
def purge(self, dataset_ref):
- from ckan import plugins
import ckan.model as model
dataset = self._get_dataset(dataset_ref)
name = dataset.name
- plugins.load('synchronous_search')
rev = model.repo.new_revision()
dataset.purge()
model.repo.commit_and_remove()
@@ -1286,8 +1282,6 @@ class CreateTestDataCommand(CkanCommand):
def command(self):
self._load_config()
self._setup_app()
- from ckan import plugins
- plugins.load('synchronous_search') # so packages get indexed
from create_test_data import CreateTestData
if self.args:
From 0f8727a31f26069561352017064c7febd9b48b2a Mon Sep 17 00:00:00 2001
From: John Martin
Date: Tue, 15 Oct 2013 15:44:51 +0100
Subject: [PATCH 15/21] [#1269] Tweaks to the templates to make them better
---
ckan/templates/package/resource_edit.html | 2 +-
.../templates/package/resource_edit_base.html | 24 ++++++++++++++++---
.../package/snippets/resource_info.html | 21 ++++++++++++++++
3 files changed, 43 insertions(+), 4 deletions(-)
create mode 100644 ckan/templates/package/snippets/resource_info.html
diff --git a/ckan/templates/package/resource_edit.html b/ckan/templates/package/resource_edit.html
index 9756c8f9581..3d761185230 100644
--- a/ckan/templates/package/resource_edit.html
+++ b/ckan/templates/package/resource_edit.html
@@ -5,5 +5,5 @@
{% block subtitle %}{{ _('Edit') }} - {{ h.resource_display_name(res) }} - {{ h.dataset_display_name(pkg) }}{% endblock %}
{% block form %}
- {{ h.snippet('package/snippets/resource_edit_form.html', data=data, errors=errors, error_summary=error_summary, pkg_name=pkg.name, form_action=c.form_action, allow_upload=g.ofs_impl and logged_in) }}
+ {{ h.snippet('package/snippets/resource_edit_form.html', data=data, errors=errors, error_summary=error_summary, pkg_name=pkg.name, form_action=c.form_action, allow_upload=g.ofs_impl and logged_in) }}
{% endblock %}
diff --git a/ckan/templates/package/resource_edit_base.html b/ckan/templates/package/resource_edit_base.html
index 7c3a8d012ec..e6c98ad7ca3 100644
--- a/ckan/templates/package/resource_edit_base.html
+++ b/ckan/templates/package/resource_edit_base.html
@@ -1,12 +1,30 @@
-{% extends "package/edit_base.html" %}
+{% extends "package/base.html" %}
{% set logged_in = true if c.userobj else false %}
{% block breadcrumb_content_selected %}{% endblock %}
+{% block breadcrumb_content %}
+ {{ super() }}
+ {% link_for h.resource_display_name(res)|truncate(30), controller='package', action='resource_read', id=pkg.name, resource_id=res.id %}
+ Edit
+{% endblock %}
+
+{% block content_action %}
+ {% link_for _('All resources'), controller='package', action='resources', id=pkg.name, class_='btn', icon='arrow-left' %}
+ {% link_for _('View resource'), controller='package', action='resource_read', id=pkg.name, resource_id=res.id, class_='btn', icon='eye-open' %}
+{% endblock %}
+
+{% block content_primary_nav %}
+ {{ h.build_nav_icon('resource_edit', _('Edit resource'), id=pkg.name, resource_id=res.id) }}
+{% endblock %}
+
+{% block secondary_content %}
+ {% snippet 'package/snippets/resource_info.html', res=res %}
+{% endblock %}
+
{% block primary_content_inner %}
- {% link_for _('View all resources'), controller='package', action='resources', id=pkg.name, class_='btn pull-right', icon='arrow-left' %}
- {% block form_title %}{{ _('Edit resource') }}{% endblock %}
+ {% block form_title %}{{ _('Edit resource') }}{% endblock %}
{% block form %}{% endblock %}
{% endblock %}
diff --git a/ckan/templates/package/snippets/resource_info.html b/ckan/templates/package/snippets/resource_info.html
new file mode 100644
index 00000000000..d8ada30d83a
--- /dev/null
+++ b/ckan/templates/package/snippets/resource_info.html
@@ -0,0 +1,21 @@
+{#
+Displays a sidebard module with information for given resource
+
+res - The respource dict
+
+Example:
+
+ {% snippet "package/snippets/resrouce_info.html", res=res %}
+
+#}
+
+
+
{{ res.name or res.id }}
+
+
+ - {{ _('Format') }}
+ - {{ res.format }}
+
+
+
+
From 99a677e952d7272ae4c30d892b5530b205ccba18 Mon Sep 17 00:00:00 2001
From: Nigel Babu
Date: Wed, 16 Oct 2013 11:29:19 +0530
Subject: [PATCH 16/21] Handle the case where the group doesn't exist
---
ckan/new_authz.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/ckan/new_authz.py b/ckan/new_authz.py
index abeb8f9b57a..d9c544677a3 100644
--- a/ckan/new_authz.py
+++ b/ckan/new_authz.py
@@ -235,7 +235,10 @@ def has_user_permission_for_group_or_org(group_id, user_name, permission):
''' Check if the user has the given permission for the group '''
if not group_id:
return False
- group_id = model.Group.get(group_id).id
+ group = model.Group.get(group_id)
+ if not group:
+ return False
+ group_id = group.id
# Sys admins can do anything
if is_sysadmin(user_name):
From 1b451fe28a89e9a8239ad0c7dd0fec800d4508dd Mon Sep 17 00:00:00 2001
From: Nigel Babu
Date: Wed, 16 Oct 2013 11:29:40 +0530
Subject: [PATCH 17/21] [#1257] Check for permissions against owner_org
Fix tests that were passing because they depended on this breakage.
---
ckan/logic/auth/create.py | 2 +-
ckan/tests/logic/test_auth.py | 15 +++++++++------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/ckan/logic/auth/create.py b/ckan/logic/auth/create.py
index a18485c2c57..f999803ab54 100644
--- a/ckan/logic/auth/create.py
+++ b/ckan/logic/auth/create.py
@@ -23,7 +23,7 @@ def package_create(context, data_dict=None):
# If an organization is given are we able to add a dataset to it?
data_dict = data_dict or {}
- org_id = data_dict.get('organization_id')
+ org_id = data_dict.get('owner_org')
if org_id and not new_authz.has_user_permission_for_group_or_org(
org_id, user, 'create_dataset'):
return {'success': False, 'msg': _('User %s not authorized to add dataset to this organization') % user}
diff --git a/ckan/tests/logic/test_auth.py b/ckan/tests/logic/test_auth.py
index 3ea9f2db39f..10d24e0105a 100644
--- a/ckan/tests/logic/test_auth.py
+++ b/ckan/tests/logic/test_auth.py
@@ -86,17 +86,20 @@ def test_03_create_dataset_no_org(self):
self._call_api('package_create', dataset, 'no_org', 403)
def test_04_create_dataset_with_org(self):
-
+ org_with_user = self._call_api('organization_show', {'id':
+ 'org_with_user'}, 'sysadmin')
dataset = {'name': 'admin_create_with_user',
- 'owner_org': 'org_with_user'}
+ 'owner_org': org_with_user.json['result']['id']}
self._call_api('package_create', dataset, 'sysadmin', 200)
+ org_no_user = self._call_api('organization_show', {'id':
+ 'org_no_user'}, 'sysadmin')
dataset = {'name': 'sysadmin_create_no_user',
- 'owner_org': 'org_no_user'}
+ 'owner_org': org_no_user.json['result']['id']}
self._call_api('package_create', dataset, 'sysadmin', 200)
dataset = {'name': 'user_create_with_org',
- 'owner_org': 'org_with_user'}
+ 'owner_org': org_with_user.json['result']['id']}
self._call_api('package_create', dataset, 'no_org', 403)
def test_05_add_users_to_org(self):
@@ -127,7 +130,7 @@ def _add_datasets(self, user):
#not able to add dataset to org admin does not belong to.
dataset = {'name': user + '_dataset_bad', 'owner_org': 'org_no_user'}
- self._call_api('package_create', dataset, user, 409)
+ self._call_api('package_create', dataset, user, 403)
#admin not able to make dataset not owned by a org
dataset = {'name': user + '_dataset_bad'}
@@ -135,7 +138,7 @@ def _add_datasets(self, user):
#not able to add org to not existant org
dataset = {'name': user + '_dataset_bad', 'owner_org': 'org_not_exist'}
- self._call_api('package_create', dataset, user, 409)
+ self._call_api('package_create', dataset, user, 403)
def test_07_add_datasets(self):
self._add_datasets('org_admin')
From f75e37dc3cfa2da3948ba1eb4fcf351021c60132 Mon Sep 17 00:00:00 2001
From: Dominik Moritz
Date: Wed, 16 Oct 2013 17:38:36 -0700
Subject: [PATCH 18/21] Move coveralls to dev requirements
---
.travis.yml | 2 --
dev-requirements.txt | 1 +
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index b4f63b6c669..debf9925c02 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,8 +5,6 @@ python:
env:
- PGVERSION=9.1
- PGVERSION=8.4
-install:
- - pip install coveralls --use-mirrors
script: ./bin/travis-build
notifications:
irc:
diff --git a/dev-requirements.txt b/dev-requirements.txt
index b55719c6388..77f50fcb083 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -9,3 +9,4 @@ Sphinx==1.1.3
polib==1.0.3
mock==1.0.1
factory-boy==2.1.1
+coveralls>=0.3
From be09f3c08bcd5cc668b16fdb4dea73c1ec8c6134 Mon Sep 17 00:00:00 2001
From: Vitor Baptista
Date: Wed, 16 Oct 2013 22:07:23 -0300
Subject: [PATCH 19/21] [#1266] Pin coveralls version to ==0.3
---
dev-requirements.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev-requirements.txt b/dev-requirements.txt
index 77f50fcb083..7dc81203fa7 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -9,4 +9,4 @@ Sphinx==1.1.3
polib==1.0.3
mock==1.0.1
factory-boy==2.1.1
-coveralls>=0.3
+coveralls==0.3
From b355fc79b0aa6ca62e6b104095e5b9696424cac6 Mon Sep 17 00:00:00 2001
From: Dominik Moritz
Date: Mon, 21 Oct 2013 09:32:31 -0700
Subject: [PATCH 20/21] Coveralls badge should show coverage default branch in
readme
---
README.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.rst b/README.rst
index 2eafd662e07..a85163653d8 100644
--- a/README.rst
+++ b/README.rst
@@ -6,7 +6,7 @@ CKAN: The Open Source Data Portal Software
:alt: Build Status
.. image:: https://coveralls.io/repos/okfn/ckan/badge.png?branch=coveralls
- :target: https://coveralls.io/r/okfn/ckan?branch=coveralls
+ :target: https://coveralls.io/r/okfn/ckan
:alt: Test coverage
**CKAN is the world’s leading open-source data portal platform**.
From 8afb07cec6b4e2d55bdb08de4f421dd20ab13a68 Mon Sep 17 00:00:00 2001
From: Vitor Baptista
Date: Mon, 21 Oct 2013 18:15:56 -0300
Subject: [PATCH 21/21] Forgot to change branch specification in Coveralls'
badge
---
README.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.rst b/README.rst
index a85163653d8..9c810209231 100644
--- a/README.rst
+++ b/README.rst
@@ -5,7 +5,7 @@ CKAN: The Open Source Data Portal Software
:target: http://travis-ci.org/okfn/ckan
:alt: Build Status
-.. image:: https://coveralls.io/repos/okfn/ckan/badge.png?branch=coveralls
+.. image:: https://coveralls.io/repos/okfn/ckan/badge.png
:target: https://coveralls.io/r/okfn/ckan
:alt: Test coverage