diff --git a/.travis.yml b/.travis.yml
index 62f7f11..5ab0865 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,7 +9,12 @@ services:
- redis-server
- postgresql
addons:
- firefox: "46.0"
+ firefox: "60.1.0esr"
+before_install:
+ - wget https://github.com/mozilla/geckodriver/releases/download/v0.21.0/geckodriver-v0.21.0-linux64.tar.gz
+ - mkdir geckodriver
+ - tar -xzf geckodriver-v0.21.0-linux64.tar.gz -C geckodriver
+ - export PATH=$PATH:$PWD/geckodriver
install:
- bash bin/travis-build.bash
before_script:
diff --git a/MANIFEST.in b/MANIFEST.in
index 597f7a8..3543c0f 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,2 +1,3 @@
recursive-include ckanext/privatedatasets/templates *
-recursive-include ckanext/privatedatasets/fanstatic *
\ No newline at end of file
+recursive-include ckanext/privatedatasets/templates_2.8 *
+recursive-include ckanext/privatedatasets/fanstatic *
diff --git a/ckanext/privatedatasets/controllers/__init__.py b/ckanext/privatedatasets/controllers/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/ckanext/privatedatasets/controllers/ui_controller.py b/ckanext/privatedatasets/controllers/ui_controller.py
deleted file mode 100644
index 573ae25..0000000
--- a/ckanext/privatedatasets/controllers/ui_controller.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright (c) 2014 CoNWeT Lab., Universidad Politécnica de Madrid
-
-# This file is part of CKAN Private Dataset Extension.
-
-# CKAN Private Dataset Extension is free software: you can redistribute it and/or
-# modify it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# CKAN Private Dataset Extension is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-
-# You should have received a copy of the GNU Affero General Public License
-# along with CKAN Private Dataset Extension. If not, see .
-
-import ckanext.privatedatasets.constants as constants
-import ckan.lib.base as base
-import ckan.model as model
-import ckan.plugins as plugins
-import logging
-
-from ckan.common import _
-
-log = logging.getLogger(__name__)
-
-
-class AcquiredDatasetsControllerUI(base.BaseController):
-
- def user_acquired_datasets(self):
-
- c = plugins.toolkit.c
- context = {
- 'model': model,
- 'session': model.Session,
- 'user': plugins.toolkit.c.user,
- }
-
- # Get user information
- try:
- c.user_dict = plugins.toolkit.get_action('user_show')(context.copy(), {'user_obj': c.userobj})
- c.user_dict['acquired_datasets'] = plugins.toolkit.get_action(constants.ACQUISITIONS_LIST)(context.copy(), None)
- except plugins.toolkit.ObjectNotFound:
- plugins.toolkit.abort(404, _('User not found'))
- except plugins.toolkit.NotAuthorized:
- plugins.toolkit.abort(401, _('Not authorized to see this page'))
-
- return plugins.toolkit.render('user/dashboard_acquired.html')
diff --git a/ckanext/privatedatasets/plugin.py b/ckanext/privatedatasets/plugin.py
index 38ba9a8..eb165c4 100755
--- a/ckanext/privatedatasets/plugin.py
+++ b/ckanext/privatedatasets/plugin.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2014 - 2017 CoNWeT Lab., Universidad Politécnica de Madrid
+# Copyright (c) 2018 Future Internet Consulting and Development Solutions S.L.
# This file is part of CKAN Private Dataset Extension.
@@ -17,15 +18,16 @@
# You should have received a copy of the GNU Affero General Public License
# along with CKAN Private Dataset Extension. If not, see .
-from __future__ import absolute_import
+from __future__ import absolute_import, unicode_literals
from ckan import model, plugins as p
from ckan.lib import search
from ckan.lib.plugins import DefaultPermissionLabels
from ckan.plugins import toolkit as tk
+from flask import Blueprint
from ckanext.privatedatasets import auth, actions, constants, converters_validators as conv_val, db, helpers
-
+from ckanext.privatedatasets.views import acquired_datasets
HIDDEN_FIELDS = [constants.ALLOWED_USERS, constants.SEARCHABLE]
@@ -35,6 +37,7 @@ class PrivateDatasets(p.SingletonPlugin, tk.DefaultDatasetForm, DefaultPermissio
p.implements(p.IDatasetForm)
p.implements(p.IAuthFunctions)
p.implements(p.IConfigurer)
+ p.implements(p.IBlueprint)
p.implements(p.IRoutes, inherit=True)
p.implements(p.IActions)
p.implements(p.IPackageController, inherit=True)
@@ -128,23 +131,32 @@ class PrivateDatasets(p.SingletonPlugin, tk.DefaultDatasetForm, DefaultPermissio
def update_config(self, config):
# Add this plugin's templates dir to CKAN's extra_template_paths, so
# that CKAN will use this plugin's custom templates.
- tk.add_template_directory(config, 'templates')
+ if p.toolkit.check_ckan_version(min_version='2.8'):
+ tk.add_template_directory(config, 'templates_2.8')
+ else:
+ tk.add_template_directory(config, 'templates')
# Register this plugin's fanstatic directory with CKAN.
- tk.add_resource('fanstatic', 'privatedatasets')
+ tk.add_resource(b'fanstatic', b'privatedatasets')
######################################################################
- ############################## IROUTES ###############################
+ ############################# IBLUEPRINT #############################
######################################################################
+ # Deprecated but Required for CKAN 2.7
def before_map(self, m):
- # DataSet acquired notification
- m.connect('user_acquired_datasets', '/dashboard/acquired', ckan_icon='shopping-cart',
- controller='ckanext.privatedatasets.controllers.ui_controller:AcquiredDatasetsControllerUI',
- action='user_acquired_datasets', conditions=dict(method=['GET']))
-
+ if p.toolkit.check_ckan_version(max_version='2.7.99'):
+ m.connect('user_acquired_datasets', '/dashboard/acquired', ckan_icon='shopping-cart',
+ controller='ckanext.privatedatasets.views:AcquiredDatasetsControllerUI',
+ action='acquired_datasets', conditions=dict(method=['GET']))
return m
+ def get_blueprint(self):
+ blueprint = Blueprint('privatedatasets', self.__module__)
+ if p.toolkit.check_ckan_version(min_version='2.8'):
+ blueprint.add_url_rule('/dashboard/acquired', 'acquired_datasets', acquired_datasets)
+ return blueprint
+
######################################################################
############################## IACTIONS ##############################
######################################################################
diff --git a/ckanext/privatedatasets/templates/user/dashboard.html b/ckanext/privatedatasets/templates/user/dashboard.html
index b172e88..0d66542 100644
--- a/ckanext/privatedatasets/templates/user/dashboard.html
+++ b/ckanext/privatedatasets/templates/user/dashboard.html
@@ -46,4 +46,4 @@
{% endblock %}
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/ckanext/privatedatasets/templates/user/dashboard_acquired.html b/ckanext/privatedatasets/templates/user/dashboard_acquired.html
index ac791e7..a9fc325 100644
--- a/ckanext/privatedatasets/templates/user/dashboard_acquired.html
+++ b/ckanext/privatedatasets/templates/user/dashboard_acquired.html
@@ -8,12 +8,12 @@
{% block primary_content_inner %}
{{ _('You haven\'t acquired any datasets.') }}
{% link_for _('Acquire one now?'), controller='package', action='search' %}
{% endif %}
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/ckanext/privatedatasets/templates_2.8/package/snippets/package_basic_fields.html b/ckanext/privatedatasets/templates_2.8/package/snippets/package_basic_fields.html
new file mode 100644
index 0000000..b240f46
--- /dev/null
+++ b/ckanext/privatedatasets/templates_2.8/package/snippets/package_basic_fields.html
@@ -0,0 +1,107 @@
+{% ckan_extends %}
+
+{% block package_basic_fields_org %}
+
+ {% resource 'privatedatasets/allowed_users.js' %}
+
+ {# if we have a default group then this wants remembering #}
+ {% if data.group_id %}
+
+ {% endif %}
+
+ {% set dataset_is_draft = data.get('state', 'draft').startswith('draft') or data.get('state', 'none') == 'none' %}
+ {% set dataset_has_organization = data.owner_org or data.group_id %}
+ {% set organizations_available = h.organizations_available('create_dataset') %}
+ {% set user_is_sysadmin = h.check_access('sysadmin') %}
+ {% set show_organizations_selector = organizations_available and (user_is_sysadmin or dataset_is_draft) %}
+ {% set editing = 'id' in data %}
+
+ {% if show_organizations_selector and show_visibility_selector %}
+
+ {% endif %}
+
+ {% if show_organizations_selector %}
+ {% set existing_org = data.owner_org or data.group_id %}
+
+
+
+
+ {% trans %}
+ Searchable datasets can be searched by anyone, while not-searchable datasets can only be accessed by entering directly its URL.
+ {% endtrans %}
+
+
+
+ {% endblock %}
+
+
+ {% if show_organizations_selector and show_visibility_selector %}
+
+ {% endif %}
+
+ {% set users_attrs = {'data-module': 'autocomplete', 'data-module-tags': '', 'data-module-source': '/api/2/util/user/autocomplete?q=?'} %}
+ {{ form.input('allowed_users_str', label=_('Allowed Users'), id='field-allowed_users_str', placeholder=_('Allowed Users'), value=h.get_allowed_users_str(data.allowed_users), error=errors.custom_text, classes=['control-full'], attrs=users_attrs) }}
+
+
+ {% if editing and h.show_acquire_url_on_edit() or not editing and h.show_acquire_url_on_create() %}
+ {{ form.input('acquire_url', label=_('Acquire URL'), id='field-acquire_url', placeholder=_('http://example.com/acquire/'), value=data.acquire_url, error=errors.custom_text, classes=['control-medium']) }}
+ {% else %}
+
+ {% endif %}
+
+ {% if data.id and h.check_access('package_delete', {'id': data.id}) and data.state != 'active' %}
+
+
+
+
+
+
+ {% endif %}
+
+{% endblock %}
diff --git a/ckanext/privatedatasets/templates_2.8/snippets/acquire_button.html b/ckanext/privatedatasets/templates_2.8/snippets/acquire_button.html
new file mode 100644
index 0000000..ca49b29
--- /dev/null
+++ b/ckanext/privatedatasets/templates_2.8/snippets/acquire_button.html
@@ -0,0 +1,15 @@
+{#
+
+Displays a Get Access button to request access to a private dataset.
+
+ulr_dest - target url
+
+Example:
+
+ {% snippet 'snippets/acquire_button.html', url_dest=url %}
+
+#}
+
+
+ {{ _('Acquire') }}
+
diff --git a/ckanext/privatedatasets/templates_2.8/snippets/package_item.html b/ckanext/privatedatasets/templates_2.8/snippets/package_item.html
new file mode 100755
index 0000000..5db5776
--- /dev/null
+++ b/ckanext/privatedatasets/templates_2.8/snippets/package_item.html
@@ -0,0 +1,82 @@
+{#
+Displays a single of dataset.
+
+package - A package to display.
+item_class - The class name to use on the list item.
+hide_resources - If true hides the resources (default: false).
+banner - If true displays a popular banner (default: false).
+truncate - The length to trucate the description to (default: 180)
+truncate_title - The length to truncate the title to (default: 80).
+
+Example:
+
+ {% snippet 'snippets/package_item.html', package=c.datasets[0] %}
+
+#}
+{% set truncate = truncate or 180 %}
+{% set truncate_title = truncate_title or 80 %}
+{% set title = package.title or package.name %}
+{% set notes = h.markdown_extract(package.notes, extract_length=truncate) %}
+{% set acquired = h.is_dataset_acquired(package) %}
+{% set owner = h.is_owner(package) %}
+
+{% resource 'privatedatasets/custom.css' %}
+
+