Improve FiWare parser to recieve dataset names properly. Show adquire message only when the dataset is accessed via its URL.
This commit is contained in:
parent
d448c6aae9
commit
ecebb74eeb
|
@ -21,6 +21,8 @@ class AdquiredDatasetsController(base.BaseController):
|
|||
|
||||
def add_user(self):
|
||||
|
||||
log.info('Notification Request received')
|
||||
|
||||
# Get the parser from the configuration
|
||||
class_path = config.get(PARSER_CONFIG_PROP, '')
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class FiWareNotificationParser(object):
|
|||
for resource in resources:
|
||||
if 'url' in resource:
|
||||
parsed_url = urlparse(resource['url'])
|
||||
dataset_name = re.findall('^/dataset/(.+)$', parsed_url.path)
|
||||
dataset_name = re.findall('^/dataset/([^/]+).*$', parsed_url.path)
|
||||
|
||||
if len(dataset_name) == 1:
|
||||
if parsed_url.netloc == my_host:
|
||||
|
|
|
@ -4,7 +4,7 @@ import ckan.plugins as p
|
|||
import ckan.plugins.toolkit as tk
|
||||
import ckan.new_authz as new_authz
|
||||
|
||||
from ckan.common import _
|
||||
from ckan.common import _, request
|
||||
|
||||
|
||||
@tk.auth_allow_anonymous_access
|
||||
|
@ -37,10 +37,16 @@ def package_show(context, data_dict):
|
|||
authorized = True
|
||||
|
||||
if not authorized:
|
||||
if hasattr(package, 'extras') and 'adquire_url' in package.extras:
|
||||
# Show a flash message with the URL to adquire the dataset
|
||||
# This message only can be shown when the user tries to access the dataset via its URL (/dataset/...)
|
||||
# The message cannot be displayed in other pages that uses the package_show function such as
|
||||
# the user profile page
|
||||
|
||||
if hasattr(package, 'extras') and 'adquire_url' in package.extras and request.path.startswith('/dataset/'):
|
||||
helpers.flash_notice(_('This private dataset can be adquired. To do so, please click ' +
|
||||
'<a target="_blank" href="%s">here</a>') % package.extras['adquire_url'],
|
||||
allow_html=True)
|
||||
|
||||
return {'success': False, 'msg': _('User %s not authorized to read package %s') % (user, package.id)}
|
||||
else:
|
||||
return {'success': True}
|
||||
|
|
Loading…
Reference in New Issue