Allow organizations to choose the users that can view their private datasets
This commit is contained in:
parent
3144e8de18
commit
ed9359e251
|
@ -12,9 +12,8 @@ this.ckan.module('allowed-users', function ($, _) {
|
|||
},
|
||||
_onChange: function() {
|
||||
var ds_private = $('#field-private').val();
|
||||
var organization = $('#field-organizations').val();
|
||||
|
||||
if (ds_private == "True" && !organization) {
|
||||
if (ds_private == "True") {
|
||||
$('#field-allowed_users').prop('disabled', false); //Enable
|
||||
$('#field-adquire_url').prop('disabled', false); //Enable
|
||||
} else {
|
||||
|
|
|
@ -121,12 +121,11 @@ def private_datasets_metadata_checker(key, data, errors, context):
|
|||
# TODO: In some cases, we will need to retireve all the dataset information if it isn't present...
|
||||
|
||||
private_val = data.get(('private',))
|
||||
owner_org = data.get(('owner_org',))
|
||||
private = private_val is True if isinstance(private_val, bool) else private_val == "True"
|
||||
metadata_value = data[key]
|
||||
|
||||
# If allowed users are included and the dataset is not private outside and organization, an error will be raised.
|
||||
if metadata_value != '' and (not private or owner_org):
|
||||
if metadata_value != '' and not private:
|
||||
errors[key].append(_('This field is only valid when you create a private dataset outside an organization'))
|
||||
|
||||
|
||||
|
|
|
@ -78,7 +78,12 @@ class PluginTest(unittest.TestCase):
|
|||
(1, 2, 'test', False, 'active', 'conwet', False, None, None, None, True),
|
||||
(1, 2, 'test', True, 'active', 'conwet', False, None, None, None, False),
|
||||
(1, 2, 'test', True, 'active', 'conwet', True, None, None, None, True),
|
||||
(1, 2, 'test', True, 'draft', 'conwet', True, None, None, None, False)
|
||||
(1, 2, 'test', True, 'draft', 'conwet', True, None, None, None, False),
|
||||
# Other user with organizations (user is not in the organization)
|
||||
(1, 2, 'test', True, 'active', 'conwet', False, 'test', None, None, True),
|
||||
(1, 2, 'test', True, 'active', 'conwet', False, 'some,another,other', None, None, False),
|
||||
(1, 2, 'test', True, 'active', 'conwet', False, 'some,another,other', 'google.es', '/dataset/testds', False),
|
||||
(1, 2, 'test', True, 'active', 'conwet', False, 'some,another,other', 'google.es', '/', False)
|
||||
])
|
||||
def test_auth_package_show(self, creator_user_id, user_obj_id, user, private, state, owner_org,
|
||||
owner_member, allowed_users, adquire_url, request_path, authorized):
|
||||
|
@ -309,8 +314,8 @@ class PluginTest(unittest.TestCase):
|
|||
('False', None, '', False),
|
||||
# When data is present, the field is only valid when the
|
||||
# organization is not set and the private field is set to true
|
||||
(True, 'conwet', 'test', True),
|
||||
('True', 'conwet', 'test', True),
|
||||
(True, 'conwet', 'test', False),
|
||||
('True', 'conwet', 'test', False),
|
||||
(False, 'conwet', 'test', True),
|
||||
('False', 'conwet', 'test', True),
|
||||
(True, None, 'test', False),
|
||||
|
|
Loading…
Reference in New Issue