Minor bugfixes
This commit is contained in:
parent
845d377b8f
commit
11a0a349f9
|
@ -32,12 +32,12 @@ class AdquiredDatasetsControllerUI(base.BaseController):
|
|||
query = model.Session.query(model.PackageExtra).filter(
|
||||
# Select only the allowed_users key
|
||||
'package_extra.key=\'%s\' AND package_extra.value!=\'\' ' % 'allowed_users' +
|
||||
# Selec only when the state is 'active'
|
||||
# Select only when the state is 'active'
|
||||
'AND package_extra.state=\'%s\' ' % 'active' +
|
||||
# The user name should be contained in the list
|
||||
'AND regexp_split_to_array(package_extra.value,\',\') @> ARRAY[\'%s\']' % context['user'])
|
||||
|
||||
# Get full information about the datasets
|
||||
# Get the datasets
|
||||
for dataset in query:
|
||||
try:
|
||||
dataset_dict = plugins.toolkit.get_action('package_show')(context, {'id': dataset.package_id})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Dataset allowed_users and adquire_url toggler
|
||||
* allowd_users and adquire_url can only be active when a user attempts to create
|
||||
* a private dataset outside an organization
|
||||
* allowed_users, adquire_url and searchable can only be active when a
|
||||
* user attempts to create a private dataset outside an organization
|
||||
*/
|
||||
|
||||
this.ckan.module('allowed-users', function ($, _) {
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
.label-adquired {
|
||||
background-color: #55a1ce;
|
||||
}
|
|
@ -13,9 +13,7 @@
|
|||
{% else %}
|
||||
<p class="empty">
|
||||
{{ _('You haven\'t adquired any datasets.') }}
|
||||
{% if h.check_access('package_create') %}
|
||||
{% link_for _('Adquire one now?'), controller='package', action='search' %}
|
||||
{% endif %}
|
||||
{% link_for _('Adquire one now?'), controller='package', action='search' %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -69,21 +69,21 @@ class FiWareParserTest(unittest.TestCase):
|
|||
fiware.request = self._request
|
||||
|
||||
@parameterized.expand([
|
||||
(TEST_CASES['one_ds']['host'], TEST_CASES['one_ds']['json'], TEST_CASES['one_ds']['result']),
|
||||
(TEST_CASES['two_ds']['host'], TEST_CASES['two_ds']['json'], TEST_CASES['two_ds']['result']),
|
||||
(TEST_CASES['error']['host'], TEST_CASES['error']['json'], TEST_CASES['error']['result']),
|
||||
(TEST_CASES['error_one_ds']['host'], TEST_CASES['error_one_ds']['json'], TEST_CASES['error_one_ds']['result']),
|
||||
(TEST_CASES['two_errors']['host'], TEST_CASES['two_errors']['json'], TEST_CASES['two_errors']['result']),
|
||||
(TEST_CASES['two_errors_two_ds']['host'], TEST_CASES['two_errors_two_ds']['json'], TEST_CASES['two_errors_two_ds']['result']),
|
||||
('one_ds',),
|
||||
('two_ds',),
|
||||
('error',),
|
||||
('error_one_ds',),
|
||||
('two_errors',),
|
||||
('two_errors_two_ds',),
|
||||
])
|
||||
def test_parse_notification(self, my_host, request_body, expected_result):
|
||||
def test_parse_notification(self, case):
|
||||
|
||||
# Configure
|
||||
fiware.request.host = my_host
|
||||
fiware.request.body = request_body
|
||||
fiware.request.host = TEST_CASES[case]['host']
|
||||
fiware.request.body = TEST_CASES[case]['json']
|
||||
|
||||
# Call the function
|
||||
result = self.parser.parse_notification()
|
||||
|
||||
# Assert that the result is what we expected to be
|
||||
self.assertEquals(expected_result, result)
|
||||
self.assertEquals(TEST_CASES[case]['result'], result)
|
||||
|
|
|
@ -168,8 +168,8 @@ class PluginTest(unittest.TestCase):
|
|||
plugin.new_authz.has_user_permission_for_group_or_org.assert_called_once_with(owner_org, user, 'update_dataset')
|
||||
|
||||
@parameterized.expand([
|
||||
(True, True),
|
||||
(True, False),
|
||||
(True, True),
|
||||
(True, False),
|
||||
(False, False),
|
||||
(False, False)
|
||||
])
|
||||
|
@ -393,5 +393,11 @@ class PluginTest(unittest.TestCase):
|
|||
(True, 'another_user,user2', 'user', False),
|
||||
])
|
||||
def test_adquired(self, include_allowed_users, allowed_users, user, adquired):
|
||||
# Configure test
|
||||
plugin.tk.c.user = user
|
||||
self.assertEquals(adquired, plugin.adquired({'allowed_users': allowed_users}))
|
||||
pkg_dict = {}
|
||||
if include_allowed_users:
|
||||
pkg_dict['allowed_users'] = allowed_users
|
||||
|
||||
# Check the function returns the expected result
|
||||
self.assertEquals(adquired, plugin.adquired(pkg_dict))
|
||||
|
|
2
setup.py
2
setup.py
|
@ -6,7 +6,7 @@ version = '0.1'
|
|||
setup(
|
||||
name='ckanext-privatedatasets',
|
||||
version=version,
|
||||
description="This extensions allows a user to create private datasets only visible to certain users. The extension provides also an API to specify which users can access private datasets",
|
||||
description="This extensions allows users to create private datasets only visible to certain users. The extension provides also an API to specify programatically which users can access private datasets",
|
||||
long_description='''
|
||||
''',
|
||||
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
|
|
Loading…
Reference in New Issue