Skip to content
Snippets Groups Projects
Commit 4bf8463f authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Added helper function to format a resource format string

parent d0ce3ca3
Branches
Tags
1 merge request!50Upgraded to CKAN 2.10
......@@ -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
......@@ -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">
......
......@@ -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 %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment