diff --git a/ckanext/odsh/helpers.py b/ckanext/odsh/helpers.py index 9fec873dc120fb233a86085f7085e0266b72316b..208d4385c011217eb6ee30d8da7deb57ad5937b9 100644 --- a/ckanext/odsh/helpers.py +++ b/ckanext/odsh/helpers.py @@ -773,3 +773,21 @@ def get_body_mail(organization, package): message = mail_titel + mail_document + mail_url + \ "Mein Kommentar:" + "%0D%0A" + "%0D%0A" + "%0D%0A" + "%0D%0A" return anrede + message + + +def format_resource_format(format_str): + """ + This function takes a format string as input and removes the trailing '_SRVC' + from it if present. If '_SRVC' is not found, the original format string is returned. + + Args: + format_str (str): The format string to be processed. + + Returns: + str: The processed format string with '_SRVC' removed if present. + """ + + if format_str.endswith('_SRVC'): + return format_str[:-5] + else: + return format_str diff --git a/ckanext/odsh/templates/package/snippets/resource_item.html b/ckanext/odsh/templates/package/snippets/resource_item.html index cdead041bf533daa79ddbd1b7c115d67d3cfbe79..aa68b3f3413469047988edd25fa79aca3c6d7396 100644 --- a/ckanext/odsh/templates/package/snippets/resource_item.html +++ b/ckanext/odsh/templates/package/snippets/resource_item.html @@ -6,7 +6,7 @@ {% set rtitle=h.resource_display_name(res) if res.name else ' '%} {% set resource_size = h.get_resource_size(res) %} -{% set res_format = res.format.replace('_SRVC','') %} +{% set res_format = h.format_resource_format(res.format) %} <li class="resource-item" data-id="{{ res.id }}"> <div class="resource-title-container"> diff --git a/ckanext/odsh/templates/snippets/package_item.html b/ckanext/odsh/templates/snippets/package_item.html index aa19f52dfbc17c6872070a80220c00d2cfff5b58..af56d32b0412be195455e800a548512e5bb22d32 100644 --- a/ckanext/odsh/templates/snippets/package_item.html +++ b/ckanext/odsh/templates/snippets/package_item.html @@ -128,8 +128,9 @@ Example: {% for resource in h.dict_list_reduce(package.resources, 'format') %} <li> <a href="{{ h.url_for(package.type ~ '.read', id=package.name) }}" class="badge badge-default dataformat-label" - data-format="{{ resource.lower().replace('_srvc','') }}">{{ - resource.replace('_SRVC','') }}</a> + data-format="{{ resource.lower().replace('_srvc','') }}"> + {{ h.format_resource_format(resource) }} + </a> </li> {% endfor %} {% endblock %}