Skip to content

Commit

Permalink
Merge pull request #17 from qld-gov-au/develop
Browse files Browse the repository at this point in the history
Develop to master
  • Loading branch information
duttonw authored Jul 11, 2023
2 parents 0866675 + 31d02dc commit 029a3f5
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ckanext/resource_visibility/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
EMPTY = "EMPTY"
UPDATED = "UPDATED"

RES_RESTRICTED_FIELDS = [FIELD_ASSESS_RESULT, FIELD_RESOURCE_VISIBLE, FIELD_GOVERNANCE_ACKN]
RES_RESTRICTED_FIELDS = [FIELD_ASSESS_RESULT, FIELD_RESOURCE_VISIBLE, FIELD_GOVERNANCE_ACKN, FIELD_REQUEST_ASSESS]
PKG_RESTRICTED_FIELDS = [FIELD_DE_IDENTIFIED, FIELD_NEXT_UPDATE_DUE]

PRIVACY_ASSESS_RESULT_LINK = "ckanext.resource_visibility.assessment_result_help_url"
Empty file.
27 changes: 19 additions & 8 deletions ckanext/resource_visibility/logic/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ def package_show(next_func, context, data_dict):

data_dict = next_func(context, data_dict)

data_dict['resources'] = [
resource for resource in data_dict['resources']
if is_resource_visible(context, resource, data_dict)
]
data_dict['resources'] = remove_hidden_resources(context, data_dict)
data_dict['num_resources'] = len(data_dict['resources'])

# set a default value to 'NO', probably of some old datasets
Expand All @@ -39,6 +36,19 @@ def package_show(next_func, context, data_dict):
return data_dict


def remove_hidden_resources(context, data_dict):
for res in data_dict["resources"]:
if _is_resource_visible(res, data_dict):
continue

res["qld_hidden"] = True

return [
resource for resource in data_dict['resources']
if is_resource_visible(context, resource, data_dict)
]


def is_resource_visible(context, res_dict, pkg_dict):
"""Check if resource visible for a specific user"""

Expand All @@ -48,6 +58,10 @@ def is_resource_visible(context, res_dict, pkg_dict):
if user_is_editor_or_admin(context, pkg_dict):
return True

return _is_resource_visible(res_dict, pkg_dict)


def _is_resource_visible(res_dict, pkg_dict):
resource_visible = res_dict.get(c.FIELD_RESOURCE_VISIBLE)
gov_acknowledgement = res_dict.get(c.FIELD_GOVERNANCE_ACKN)
request_privacy_assess = res_dict.get(c.FIELD_REQUEST_ASSESS)
Expand All @@ -60,10 +74,7 @@ def is_resource_visible(context, res_dict, pkg_dict):
if request_privacy_assess == c.NO or not request_privacy_assess:
return True
if request_privacy_assess == c.YES:
if de_identified_data == c.NO:
return True
elif de_identified_data == c.YES:
return False
return False
elif gov_acknowledgement == c.NO:
return de_identified_data == c.NO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
<div class="info-block">
<i class="fa fa-info-circle"></i>
<span>
{{ _('Privacy assessment information, including the meaning of the Privacy assessment result, can be found ') }}
<a href="{{ h.resource_visibility_get_assessment_result_help_url() or "#" }}" target="_blank">{{ _('here.') }}</a>
{{ _('Leave this field blank. It is automatically populated with the URL of the privacy assessment report (if requested and completed).') }}
</span>
</div>
{% endcall %}
Expand Down
Empty file.
7 changes: 5 additions & 2 deletions ckanext/resource_visibility/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ def test_some_endpoint(app):
def test_some_action():
pass
"""
import ckanext.resource_visibility.plugin as plugin # noqa
from ckanext.resource_visibility import plugin


def test_plugin():
pass
test_plugin = plugin.ResourceVisibilityPlugin()
test_plugin.get_helpers()
test_plugin.get_actions()
test_plugin.get_commands()

0 comments on commit 029a3f5

Please sign in to comment.