palasangha / Treasures-Of-Dhamma

GNU General Public License v3.0
0 stars 0 forks source link

Role wise segregate download image option using twig template #46

Closed paladhamma closed 2 years ago

paladhamma commented 2 years ago

Replace the exisiting code-block in Object Description Metadata Display Note: Example taken for as:image data here

{% if attribute(data, 'as:image')|length <= 10 and attribute(data, 'as:image')|length > 0 %}
<h2>Images in this Digital Object</h2>
<ul>
    {% for singleimage in attribute(data, 'as:image') %}
        <li><a href="/do/{{ node.id }}/iiif/{{ singleimage['dr:uuid'] }}/full/full/0/{{  singleimage.name }}" target="_blank">Download Image {{ singleimage.name }}</a></li>
    {% endfor %}
</ul>
{% endif %}

TO

{% if data['as:image'] is defined and data['as:image'] is iterable %}
    {% for image in data['as:image'] %}
        {% if bamboo_has_role('conservator') and image['dr:for'] == "raw_image_files" %}
           <li><a download href="/do/{{ node.id }}/iiif/{{ image['dr:uuid'] }}/full/full/0/{{  image.name }}" target="_blank">Download {{ image.name }}</a></li>
        {% elseif bamboo_has_role('administrator') %}
           <li><a download href="/do/{{ node.id }}/iiif/{{ image['dr:uuid'] }}/full/full/0/{{  image.name }}" target="_blank">Super user, Download TIFF {{ image.name }}</a></li>
        {% endif %}
    {% endfor %}
{% endif %}