From df062da16832f6e81f8e56424c15f3e742c573ca Mon Sep 17 00:00:00 2001 From: mjanez <96422458+mjanez@users.noreply.github.com> Date: Wed, 6 Nov 2024 14:09:01 +0100 Subject: [PATCH 1/7] Fix DCAT_AP_HVD_CATEGORY_LEGISLATION duplicates bug --- ckanext/schemingdcat/validators.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ckanext/schemingdcat/validators.py b/ckanext/schemingdcat/validators.py index f6f86d1..a953d6c 100644 --- a/ckanext/schemingdcat/validators.py +++ b/ckanext/schemingdcat/validators.py @@ -1152,11 +1152,10 @@ def validator(key, data, errors, context): hvd_category = data.get(('hvd_category', )) if hvd_category: if isinstance(data.get(key), list): - if not data[key]: - data[key] = [DCAT_AP_HVD_CATEGORY_LEGISLATION] - else: + if DCAT_AP_HVD_CATEGORY_LEGISLATION not in data[key]: data[key].append(DCAT_AP_HVD_CATEGORY_LEGISLATION) else: - data[key] = [DCAT_AP_HVD_CATEGORY_LEGISLATION] + if data.get(key) != DCAT_AP_HVD_CATEGORY_LEGISLATION: + data[key] = [DCAT_AP_HVD_CATEGORY_LEGISLATION] return validator \ No newline at end of file From ea8a45a5cfcc3c1a40722bc9b90895ecbb485845 Mon Sep 17 00:00:00 2001 From: mjanez <96422458+mjanez@users.noreply.github.com> Date: Thu, 7 Nov 2024 11:42:40 +0100 Subject: [PATCH 2/7] Correct capitalization of "Land cover" in GeoDCAT-AP theme (INSPIRE) --- ckanext/schemingdcat/schemas/geodcat_ap/es_geodcat_ap_full.yaml | 2 +- ckanext/schemingdcat/schemas/geodcat_ap/eu_geodcat_ap_full.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ckanext/schemingdcat/schemas/geodcat_ap/es_geodcat_ap_full.yaml b/ckanext/schemingdcat/schemas/geodcat_ap/es_geodcat_ap_full.yaml index eed5475..e5e86d3 100644 --- a/ckanext/schemingdcat/schemas/geodcat_ap/es_geodcat_ap_full.yaml +++ b/ckanext/schemingdcat/schemas/geodcat_ap/es_geodcat_ap_full.yaml @@ -2451,7 +2451,7 @@ dataset_fields: es: Condiciones atmosféricas (AC) value: http://inspire.ec.europa.eu/theme/ac - label: - en: Land Cover (LC) + en: Land cover (LC) es: Cubierta terrestre (LC) value: http://inspire.ec.europa.eu/theme/lc - label: diff --git a/ckanext/schemingdcat/schemas/geodcat_ap/eu_geodcat_ap_full.yaml b/ckanext/schemingdcat/schemas/geodcat_ap/eu_geodcat_ap_full.yaml index b60592f..67ab939 100644 --- a/ckanext/schemingdcat/schemas/geodcat_ap/eu_geodcat_ap_full.yaml +++ b/ckanext/schemingdcat/schemas/geodcat_ap/eu_geodcat_ap_full.yaml @@ -2147,7 +2147,7 @@ dataset_fields: es: Condiciones atmosféricas (AC) value: http://inspire.ec.europa.eu/theme/ac - label: - en: Land Cover (LC) + en: Land cover (LC) es: Cubierta terrestre (LC) value: http://inspire.ec.europa.eu/theme/lc - label: From ead4bfc79068d6a63a748bbe6bd8b6a9681f7795 Mon Sep 17 00:00:00 2001 From: mjanez <96422458+mjanez@users.noreply.github.com> Date: Thu, 7 Nov 2024 11:55:49 +0100 Subject: [PATCH 3/7] Fix org label breadcrumb navigation --- .../schemingdcat/templates/package/base.html | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ckanext/schemingdcat/templates/package/base.html diff --git a/ckanext/schemingdcat/templates/package/base.html b/ckanext/schemingdcat/templates/package/base.html new file mode 100644 index 0000000..37b8482 --- /dev/null +++ b/ckanext/schemingdcat/templates/package/base.html @@ -0,0 +1,20 @@ +{% ckan_extends %} + +{% block breadcrumb_content %} + {% if pkg %} + {% set org = h.get_organization(pkg.organization.id) %} + {% set dataset = h.dataset_display_name(pkg) %} + {% if org %} + {% set organization = h.get_translated(org, 'title') or org.name %} + {% set group_type = org.type %} +
  • {% link_for h.humanize_entity_type('organization', group_type, 'breadcrumb') or _('Organizations'), named_route=group_type ~ '.index' %}
  • +
  • {% link_for organization|truncate(30), named_route=group_type ~ '.read', id=org.name, title=organization %}
  • + {% else %} +
  • {% link_for _(dataset_type.title()), named_route=dataset_type ~ '.search' %}
  • + {% endif %} + {% link_for dataset|truncate(30), named_route=pkg.type ~ '.read', id=pkg.name, title=dataset %} + {% else %} +
  • {% link_for _(dataset_type.title()), named_route=dataset_type ~ '.search' %}
  • +
  • {{ h.humanize_entity_type('package', dataset_type, 'create label') or _('Create Dataset') }}
  • + {% endif %} +{% endblock %} \ No newline at end of file From e09c8c6664158441772d4f6d923d7c2df956a20d Mon Sep 17 00:00:00 2001 From: mjanez <96422458+mjanez@users.noreply.github.com> Date: Thu, 7 Nov 2024 14:56:22 +0100 Subject: [PATCH 4/7] Add text truncation styles for dataset/resource metadata display --- ckanext/schemingdcat/assets/css/schemingdcat.css | 12 ++++++++++++ .../package/snippets/resource_extended_info.html | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ckanext/schemingdcat/assets/css/schemingdcat.css b/ckanext/schemingdcat/assets/css/schemingdcat.css index 7c86612..bc44152 100644 --- a/ckanext/schemingdcat/assets/css/schemingdcat.css +++ b/ckanext/schemingdcat/assets/css/schemingdcat.css @@ -953,10 +953,22 @@ img.spatial_uri-icon { vertical-align: middle; } +/* Rows dataset/resource metadata */ +.truncate-text { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 100%; +} + /* Links list*/ .link-list { list-style-type: "🔗 "; vertical-align: middle; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 100%; } .link-list li::marker { diff --git a/ckanext/schemingdcat/templates/schemingdcat/package/snippets/resource_extended_info.html b/ckanext/schemingdcat/templates/schemingdcat/package/snippets/resource_extended_info.html index dff08bf..3c4ba50 100644 --- a/ckanext/schemingdcat/templates/schemingdcat/package/snippets/resource_extended_info.html +++ b/ckanext/schemingdcat/templates/schemingdcat/package/snippets/resource_extended_info.html @@ -15,7 +15,7 @@ {% if res[field_name] %} {{ h.scheming_language_text(field.label) }} - + {% if res[field_name] is iterable and res[field_name] is not string %}

    + {% block harvest_info %} + {% set quote_content %} + {% trans %} + Only sysadmin users can manage harvest sources. Check the ckanext-harvest documentation for more information. + {% endtrans %} + {% endset %} + {% snippet "schemingdcat/snippets/quote_alerts.html", alert_type='info', content=quote_content %} + {% endblock %} + {% block facets %} From b3c2b0e6d280d7953ca0caf3bd2b9b753fb43de9 Mon Sep 17 00:00:00 2001 From: mjanez <96422458+mjanez@users.noreply.github.com> Date: Mon, 11 Nov 2024 00:49:57 +0100 Subject: [PATCH 6/7] Refactor import statements to simplify access to CKAN toolkit functions --- ckanext/schemingdcat/logic/auth/ckan.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ckanext/schemingdcat/logic/auth/ckan.py b/ckanext/schemingdcat/logic/auth/ckan.py index 7c1b90c..4a13ffd 100644 --- a/ckanext/schemingdcat/logic/auth/ckan.py +++ b/ckanext/schemingdcat/logic/auth/ckan.py @@ -1,7 +1,7 @@ import logging import typing -import ckan.plugins.toolkit as toolkit +import ckan.plugins as p import ckan.logic as logic import ckan.logic.auth as auth @@ -12,7 +12,7 @@ _check_access = logic.check_access # Credits to logic.auth.ckan: https://github.com/kartoza/ckanext-dalrrd-emc-dcpr -@toolkit.chained_auth_function +@p.toolkit.chained_auth_function def package_update(next_auth, context, data_dict=None): """Custom auth for the package_update action. @@ -24,7 +24,7 @@ def package_update(next_auth, context, data_dict=None): if user.sysadmin: final_result = next_auth(context, data_dict) elif data_dict is not None: - # NOTE: we do not call toolkit.get_action("package_show") here but rather do it + # NOTE: we do not call p.toolkit.get_action("package_show") here but rather do it # the same as vanilla CKAN which uses a custom way to retrieve the object from # the context - this is in order to ensure other extensions # (e.g. ckanext.harvest) are able to function correctly @@ -40,7 +40,7 @@ def package_update(next_auth, context, data_dict=None): org_id = data_dict.get("owner_org", package.owner_org) if org_id is not None: # Using the schemingdcat_member_list action to obtain correct roles - members = toolkit.get_action("schemingdcat_member_list")( + members = p.toolkit.get_action("schemingdcat_member_list")( data_dict={"id": org_id, "object_type": "user"} ) #log.debug('members:%s', members) @@ -62,7 +62,7 @@ def package_update(next_auth, context, data_dict=None): return final_result -@toolkit.chained_auth_function +@p.toolkit.chained_auth_function def package_patch( next_auth: typing.Callable, context: typing.Dict, data_dict: typing.Dict ): @@ -93,7 +93,7 @@ def authorize_package_publish( # beforehand, so we deny owner_org = data_.get("owner_org", data_.get("group_id")) if owner_org is not None: - members = toolkit.get_action("member_list")( + members = p.toolkit.get_action("member_list")( data_dict={"id": owner_org, "object_type": "user"} ) admin_member_ids = [ From a48f23925ab131d0359156fbe13842e506da48a4 Mon Sep 17 00:00:00 2001 From: mjanez <96422458+mjanez@users.noreply.github.com> Date: Mon, 11 Nov 2024 00:57:33 +0100 Subject: [PATCH 7/7] Add text truncation styles for links, texts, and lists in metadata/resource info - Avoid visual bugs. - Improve responsive. --- .../schemingdcat/assets/css/schemingdcat.css | 19 +++++++++---------- .../scheming/display_snippets/text.html | 1 + .../schemingdcat/display_snippets/link.html | 2 +- .../display_snippets/link_epsg.html | 2 +- .../display_snippets/link_name.html | 2 +- .../display_snippets/link_schema.html | 4 ++-- .../display_snippets/list_keywords.html | 2 +- .../display_snippets/list_links.html | 2 +- .../list_metadata_profiles.html | 2 +- .../display_snippets/spatial_uris.html | 2 +- .../schemingdcat/display_snippets/themes.html | 2 +- .../display_snippets/themes_es.html | 2 +- .../package/snippets/document_info.html | 12 ++++++------ .../package/snippets/metadata_info.html | 16 ++++++++-------- 14 files changed, 35 insertions(+), 35 deletions(-) create mode 100644 ckanext/schemingdcat/templates/scheming/display_snippets/text.html diff --git a/ckanext/schemingdcat/assets/css/schemingdcat.css b/ckanext/schemingdcat/assets/css/schemingdcat.css index bc44152..23babb4 100644 --- a/ckanext/schemingdcat/assets/css/schemingdcat.css +++ b/ckanext/schemingdcat/assets/css/schemingdcat.css @@ -958,17 +958,22 @@ img.spatial_uri-icon { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + display: block; + max-width: 100%; +} +.truncate-link { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + display: inline-block; max-width: 100%; + vertical-align: middle; } /* Links list*/ .link-list { list-style-type: "🔗 "; vertical-align: middle; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - max-width: 100%; } .link-list li::marker { @@ -1457,12 +1462,6 @@ img.item_image { table-layout: fixed; /* Fija el layout de la tabla */ width: 100%; /* Asegura que la tabla ocupe el 100% del contenedor */ } -/* Apply text truncation to cells in metadata_info */ -.truncate-text { - overflow: hidden; /* Hides the text overflow */ - text-overflow: ellipsis; /* Adds ellipsis if text is too long */ -} - .table tr.toggle-separator { display: table-row; } diff --git a/ckanext/schemingdcat/templates/scheming/display_snippets/text.html b/ckanext/schemingdcat/templates/scheming/display_snippets/text.html new file mode 100644 index 0000000..7b24c9c --- /dev/null +++ b/ckanext/schemingdcat/templates/scheming/display_snippets/text.html @@ -0,0 +1 @@ +{{ data[field.field_name] }} \ No newline at end of file diff --git a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link.html b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link.html index 25827e0..e3d7fcf 100644 --- a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link.html +++ b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link.html @@ -1 +1 @@ -{{ h.link_to(data[field.field_name], data[field.field_name], rel=field.display_property, target='_blank') }} +{{ h.link_to(data[field.field_name], data[field.field_name], rel=field.display_property, target='_blank', class='truncate-link') }} diff --git a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link_epsg.html b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link_epsg.html index 1bd8d09..2e78709 100644 --- a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link_epsg.html +++ b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link_epsg.html @@ -1,4 +1,4 @@ {% if data[field.field_name] %} {% set url_name = 'EPSG:' + h.schemingdcat_prettify_url_name(data[field.field_name]) %} - {{ h.link_to(url_name, data[field.field_name], rel=field.display_property, target='_blank') }} + {{ h.link_to(url_name, data[field.field_name], rel=field.display_property, target='_blank', class='truncate-link') }} {% endif %} \ No newline at end of file diff --git a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link_name.html b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link_name.html index 3359ec1..ba5fab0 100644 --- a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link_name.html +++ b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link_name.html @@ -1,3 +1,3 @@ {% set url_name = h.schemingdcat_prettify_url_name(data[field.field_name]) %} -{{ h.link_to(url_name, data[field.field_name], rel=field.display_property, target='_blank') }} +{{ h.link_to(url_name, data[field.field_name], rel=field.display_property, target='_blank', class='truncate-link') }} diff --git a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link_schema.html b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link_schema.html index 695c7d3..e902a0b 100644 --- a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link_schema.html +++ b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/link_schema.html @@ -29,13 +29,13 @@ {% else %} {% for val, label in filtered_choices %} - {{ label }} + {{ label }} {% endfor %} {% endif %} {% endblock %} \ No newline at end of file diff --git a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/list_keywords.html b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/list_keywords.html index 59abdfb..f7647cf 100644 --- a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/list_keywords.html +++ b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/list_keywords.html @@ -27,7 +27,7 @@ {% set value = h.scheming_clean_json_value(value.replace(' ', '')) %} {% set label = h.scheming_clean_json_value(label.replace(' ', '')) %}
  • - {{ label }} + {{ label }}
  • {% endfor %} diff --git a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/list_links.html b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/list_links.html index 20eec72..55d35fd 100644 --- a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/list_links.html +++ b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/list_links.html @@ -20,7 +20,7 @@ {% for value in values if value|length %} {% set value = h.scheming_clean_json_value(value.replace(' ', '')) %}
  • - {{ value }} + {{ value }}
  • {% endfor %} diff --git a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/list_metadata_profiles.html b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/list_metadata_profiles.html index 0a4d5d2..34dd34f 100644 --- a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/list_metadata_profiles.html +++ b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/list_metadata_profiles.html @@ -20,7 +20,7 @@ {% for value in values if value|length %} {% set value = h.scheming_clean_json_value(value.replace(' ', '')) %}
  • - {{ value }} + {{ value }}
  • {% endfor %} diff --git a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/spatial_uris.html b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/spatial_uris.html index d4af475..ab01c8b 100644 --- a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/spatial_uris.html +++ b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/spatial_uris.html @@ -17,7 +17,7 @@ {% if val in spatial_uris_list %} {% set img_url = h.url_for_static('/images/icons/theme_es/spain.svg') %}
  • - {{ label }} {{ label }} + {{ label }} {{ label }}
  • {% endif %} {% endfor %} diff --git a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/themes.html b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/themes.html index 56048c0..8f56b80 100644 --- a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/themes.html +++ b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/themes.html @@ -17,7 +17,7 @@ {% if val in themes_list %} {% set img_url = h.url_for_static('/images/icons/inspire/' + val.split('/')[-1].lower() + '.svg') %}
  • - {{ label }} {{ label }} + {{ label }} {{ label }}
  • {% endif %} {% endfor %} diff --git a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/themes_es.html b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/themes_es.html index e58a970..da95d59 100644 --- a/ckanext/schemingdcat/templates/schemingdcat/display_snippets/themes_es.html +++ b/ckanext/schemingdcat/templates/schemingdcat/display_snippets/themes_es.html @@ -17,7 +17,7 @@ {% if val in themes_list %} {% set img_url = h.url_for_static('/images/icons/theme_es/' + val.split('/')[-1].lower() + '.png') %}
  • - {{ label }} {{ label }} + {{ label }} {{ label }}
  • {% endif %} {% endfor %} diff --git a/ckanext/schemingdcat/templates/schemingdcat/package/snippets/document_info.html b/ckanext/schemingdcat/templates/schemingdcat/package/snippets/document_info.html index df4662d..5822904 100644 --- a/ckanext/schemingdcat/templates/schemingdcat/package/snippets/document_info.html +++ b/ckanext/schemingdcat/templates/schemingdcat/package/snippets/document_info.html @@ -46,7 +46,7 @@

    {{ h.scheming_language_text(field.label) }} {{ h.scheming_language_text(field.label) }} {{ h.scheming_language_text(field.label) }} {{ h.scheming_language_text(field.label) }} {{ h.scheming_language_text(field.label) }} {{ h.scheming_language_text(field.label) }} {{ h.scheming_language_text(field.label) }} {{ h.scheming_language_text(field.label) }} {{ h.scheming_language_text(field.label) }} {{ h.scheming_language_text(field.label) }} {{ h.scheming_language_text(field.label) }} {{ h.scheming_language_text(field.label) }} {{ h.scheming_language_text(field.label) }} {{ h.scheming_language_text(field.label) }}