Applied business logic described here

https://support.d4science.org/issues/26641
This commit is contained in:
Francesco Mangiacrapa 2024-05-17 11:13:18 +02:00
parent c58d85f762
commit fc3a5b2e2d
1 changed files with 7 additions and 16 deletions

View File

@ -36,27 +36,18 @@ if(window.addEventListener){
</script>
{% if h.check_access('package_update', {'id':pkg.id }) %}
{# CODE ADDED BY Francesco Mangiacrapa #}
{# see ticket #26641 - ONLY THE SYSADMINS see the Manage button #}
{% set is_sys_admin = true if (c.userobj and c.userobj.sysadmin) else false %}
{% set hide = h.get_cookie_value('ckan_hide_header') %}
{# INTO PORTAL - FROM D4SCIENCE PORTAL #}
{% if hide and hide == 'true' %}
{% set username_id = c.userobj.id %}
{% set pkg_creator_user_id = pkg.creator_user_id %}
{% set role_for_user = h.d4science_theme_get_user_role_for_group_or_org(pkg.organization.id, username_id) %}
{% if role_for_user %}
{% if role_for_user == 'admin' %}
{% link_for _('Manage'), controller='package', action='edit', id=pkg.name, class_='btn', icon='wrench' %}
{% else %}
{% if role_for_user == 'editor' %}
{# IF THE USER HAS ROLE EDITOR HE/SHE CAN EDIT ONLY ITS DATASET, see related ticket #5119 #}
{% if username_id == pkg_creator_user_id %}
{% link_for _('Manage'), controller='package', action='edit', id=pkg.name, class_='btn', icon='wrench' %}
{% endif %}
{% endif %}
{# NOT SHOW 'Manage' #}
{% endif %}
{% if is_sys_admin %}
{% link_for _('Manage'), controller='package', action='edit', id=pkg.name, class_='btn', icon='wrench' %}
{% endif %}
{% else %}
{% link_for _('Manage'), controller='package', action='edit', id=pkg.name, class_='btn', icon='wrench' %}
{% if is_sys_admin %}
{% link_for _('Manage'), controller='package', action='edit', id=pkg.name, class_='btn', icon='wrench' %}
{% endif %}
{% endif %}
{% endif %}
{% endblock %}