Merge branch 'upstream' of https://github.com/pgalves/ckanext-privatedatasets into pgalves-upstream
This commit is contained in:
commit
2b860aa8e5
|
@ -4,4 +4,10 @@
|
|||
|
||||
.label-owner {
|
||||
background-color: #e0051e;
|
||||
}
|
||||
|
||||
.divider {
|
||||
margin-left:10px;
|
||||
height:auto;
|
||||
display:inline-block;
|
||||
}
|
|
@ -23,6 +23,10 @@ import db
|
|||
|
||||
from pylons import config
|
||||
|
||||
from ckan.common import request
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
def is_dataset_acquired(pkg_dict):
|
||||
|
||||
|
@ -68,3 +72,32 @@ def show_acquire_url_on_create():
|
|||
|
||||
def show_acquire_url_on_edit():
|
||||
return get_config_bool_value('ckan.privatedatasets.show_acquire_url_on_edit')
|
||||
|
||||
|
||||
def snippet(template_name, data=None):
|
||||
''' This function is used to load html snippets into pages. keywords
|
||||
can be used to pass parameters into the snippet rendering '''
|
||||
return tk.render_snippet(template_name, data)
|
||||
|
||||
|
||||
def getaccess_button(package):
|
||||
'''Return a Get Access button for the given package id.
|
||||
|
||||
If the user is not logged in return an empty string instead.
|
||||
|
||||
:param package: the the package to request access when the get access
|
||||
button is clicked
|
||||
:type package: Package
|
||||
|
||||
:returns: a get access button as an HTML snippet
|
||||
:rtype: string
|
||||
|
||||
'''
|
||||
|
||||
if 'acquire_url' in package and request.path.startswith('/dataset')\
|
||||
and package['acquire_url'] != '':
|
||||
url_dest = package['acquire_url']
|
||||
data = {'url_dest': url_dest}
|
||||
return snippet('snippets/fiware_getaccess_button.html', data)
|
||||
else:
|
||||
return ''
|
||||
|
|
|
@ -288,5 +288,6 @@ class PrivateDatasets(p.SingletonPlugin, tk.DefaultDatasetForm):
|
|||
'is_owner': helpers.is_owner,
|
||||
'can_read': helpers.can_read,
|
||||
'show_acquire_url_on_create': helpers.show_acquire_url_on_create,
|
||||
'show_acquire_url_on_edit': helpers.show_acquire_url_on_edit
|
||||
'show_acquire_url_on_edit': helpers.show_acquire_url_on_edit,
|
||||
'getaccess_button': helpers.getaccess_button
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
{#
|
||||
|
||||
Displays a Get Access button to request access to a private dataset.
|
||||
|
||||
ulr_dest - target url
|
||||
|
||||
Example:
|
||||
|
||||
{% snippet 'snippets/fiware_getaccess_button.html', url_dest=url %}
|
||||
|
||||
#}
|
||||
<a href={{ url_dest }} class="btn btn-mini">
|
||||
<i class="icon-plus-sign"></i>
|
||||
{{ _('Get Access') }}
|
||||
</a>
|
|
@ -44,7 +44,15 @@ Example:
|
|||
{{ _('Owner') }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{{ h.link_to(h.truncate(title, truncate_title), h.url_for(controller='package', action='read', id=package.name)) }}
|
||||
<!-- Customizations FIWARE GETACCESS GETACCESSBUTTON-->
|
||||
{% if package.private and not h.can_read(package) %}
|
||||
{{ _(h.truncate(title, truncate_title)) }}
|
||||
<div class="divider"/>
|
||||
{{ h.getaccess_button(package) }}
|
||||
{% else %}
|
||||
{{ h.link_to(h.truncate(title, truncate_title), h.url_for(controller='package', action='read', id=package.name)) }}
|
||||
{% endif %}
|
||||
<!-- End of customizations FIWARE GETACCESSBUTTON -->
|
||||
{% if package.get('state', '').startswith('draft') %}
|
||||
<span class="label label-info">{{ _('Draft') }}</span>
|
||||
{% elif package.get('state', '').startswith('deleted') %}
|
||||
|
|
Loading…
Reference in New Issue