Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor metadata profile rendering logic to improve conditional checks for GeoDCAT-AP/INSPIRE (spatial datasets) profiles #117

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions ckanext/schemingdcat/statistics/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def setup():
define_tables()

if not statistics_table.exists():
statistics_table.create()
statistics_table.create(checkfirst=True)
log.debug('SchemingDCAT statistics table defined in DB')

def clean():
Expand All @@ -62,10 +62,13 @@ def clean():
"""
global statistics_table

if statistics_table is not None and statistics_table.exists():
statistics_table.drop()
log.debug('SchemingDCAT statistics table dropped from DB')

try:
if statistics_table is not None and statistics_table.exists():
statistics_table.drop(checkfirst=True)
log.debug('SchemingDCAT statistics table dropped from DB')
except Exception as e:
log.error('Error dropping statistics table: %s', e)

setup()

def update_table():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@
{% set added_profiles = [] %}
{% for profile in profiles %}
{% if profile.profile_label not in added_profiles %}
{% if 'eu_dcat_ap' in profile.profile or (pkg.theme_es and 'es_dcat' in profile.profile) %}
<li class="dropdown-header" title="{{ _('RDF DCAT Endpoint') }}"><i class="fa fa-share-alt"></i> {{ profile.profile_label }} - {{ _('Linked Data') }}</li>
{% if ('eu_dcat_ap' in profile.profile or (pkg.theme_es and 'es_dcat' in profile.profile)) and not ('eu_geodcat_ap' in profile.profile and pkg.dcat_type not in inspire_metadata_values) %}
<li class="dropdown-header" title="{{ _('RDF DCAT Endpoint') }}">
<i class="fa fa-share-alt"></i> {{ profile.profile_label }} - {{ _('Linked Data') }}
</li>
{% for link in linked_data_links if link.endpoint_type == 'dcat' %}
{% set url = h.url_for(link.endpoint, profiles=profile.profile, **link.endpoint_data) %}
{% set format_label = '<strong>' + link.format + '</strong>' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#}

{% set processed_profiles = [] %}
{% set has_geodcat_ap = false %}

{% macro render_metadata_label(profile_label, profile_title, profile_info_url, profile_fa_icon) %}
<div class="metadata-label pull-left">
Expand All @@ -31,24 +30,13 @@
{% if profile_key not in processed_profiles %}
{% if profile.profile_id == 'inspire' and pkg.dcat_type in inspire_metadata_values %}
{{ render_metadata_label(profile.profile_label, profile.profile_label, profile.profile_info_url, profile.profile_fa_icon) }}
{% elif profile.profile_id == 'geodcat_ap' %}
{% elif profile.profile_id == 'geodcat_ap' and pkg.dcat_type in inspire_metadata_values %}
{{ render_metadata_label('GeoDCAT-AP', profile.profile_label, profile.profile_info_url, profile.profile_fa_icon) }}
{% set has_geodcat_ap = True %}
{% elif profile.profile_id == 'dcat_ap' and pkg.dcat_type not in inspire_metadata_values %}
{{ render_metadata_label('DCAT-AP', profile.profile_label, profile.profile_info_url, profile.profile_fa_icon) }}
{% elif profile.profile_id == 'nti_risp' and pkg.theme_es %}
{{ render_metadata_label(profile.profile_label, profile.profile_label, profile.profile_info_url, profile.profile_fa_icon) }}
{% endif %}
{% set _ = processed_profiles.append(profile_key) %}
{% endif %}
{% endfor %}

{% if not has_geodcat_ap %}
{% for profile in sorted_profiles %}
{% set profile_key = profile.profile_id if profile.profile_id else profile.profile_label %}
{% if profile_key not in processed_profiles %}
{% if profile.profile_id == 'dcat_ap' %}
{{ render_metadata_label('DCAT-AP', profile.profile_label, profile.profile_info_url, profile.profile_fa_icon) }}
{% endif %}
{% set _ = processed_profiles.append(profile_key) %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
1 change: 0 additions & 1 deletion ckanext/schemingdcat/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,6 @@ def validator(key, data, errors, context):

return validator

@staticmethod
@lru_cache(maxsize=44)
def normalize_string(s):
"""Normalizes a string according to the rules:
Expand Down
Loading