From 6af5e8891960e39cf22a22580aeb6a2702a5ba27 Mon Sep 17 00:00:00 2001 From: avdata99 Date: Wed, 23 Oct 2024 20:33:33 -0300 Subject: [PATCH 1/2] Mostrar la version en el footer --- ckanext-unckan/ckanext/unckan/helpers/__init__.py | 0 ckanext-unckan/ckanext/unckan/helpers/base.py | 6 ++++++ ckanext-unckan/ckanext/unckan/plugin.py | 9 +++++++++ ckanext-unckan/ckanext/unckan/templates/page.html | 6 ++++++ docker/ckan/files/env/base.env | 2 +- docker/ckan/files/scripts/entrypoint.sh | 2 ++ 6 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 ckanext-unckan/ckanext/unckan/helpers/__init__.py create mode 100644 ckanext-unckan/ckanext/unckan/helpers/base.py create mode 100644 ckanext-unckan/ckanext/unckan/templates/page.html diff --git a/ckanext-unckan/ckanext/unckan/helpers/__init__.py b/ckanext-unckan/ckanext/unckan/helpers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ckanext-unckan/ckanext/unckan/helpers/base.py b/ckanext-unckan/ckanext/unckan/helpers/base.py new file mode 100644 index 0000000..9497863 --- /dev/null +++ b/ckanext-unckan/ckanext/unckan/helpers/base.py @@ -0,0 +1,6 @@ +from ckan.common import config + + +def get_unckan_version(): + """ Get the UNCKAN extnsion version from CKAN_UNI_VERSION """ + return config.get('ckanext.unckan.version') diff --git a/ckanext-unckan/ckanext/unckan/plugin.py b/ckanext-unckan/ckanext/unckan/plugin.py index 8614722..5773dd5 100644 --- a/ckanext-unckan/ckanext/unckan/plugin.py +++ b/ckanext-unckan/ckanext/unckan/plugin.py @@ -1,6 +1,7 @@ import logging from ckan import plugins from ckan.plugins import toolkit +from ckanext.unckan.helpers import base log = logging.getLogger(__name__) @@ -8,6 +9,7 @@ class UnCKANPlugin(plugins.SingletonPlugin): plugins.implements(plugins.IConfigurer) + plugins.implements(plugins.ITemplateHelpers) # IConfigurer @@ -15,3 +17,10 @@ def update_config(self, config_): toolkit.add_template_directory(config_, "templates") toolkit.add_public_directory(config_, "public") toolkit.add_resource("assets", "unckan") + + # ITemplateHelpers + + def get_helpers(self): + return { + 'get_unckan_version': base.get_unckan_version + } diff --git a/ckanext-unckan/ckanext/unckan/templates/page.html b/ckanext-unckan/ckanext/unckan/templates/page.html new file mode 100644 index 0000000..af580e3 --- /dev/null +++ b/ckanext-unckan/ckanext/unckan/templates/page.html @@ -0,0 +1,6 @@ +{% ckan extends %} + +{%- block footer %} + {{ super() }} + UNCKAN v{{ h.get_unckan_version }} +{% endblock -%} \ No newline at end of file diff --git a/docker/ckan/files/env/base.env b/docker/ckan/files/env/base.env index 2b682e8..d4b8914 100644 --- a/docker/ckan/files/env/base.env +++ b/docker/ckan/files/env/base.env @@ -1,7 +1,7 @@ # Do not change this file for your local env # Use local.env to set your local env variables -CKAN_UNI_VERSION=0.4.2 +CKAN_UNI_VERSION=0.4.3 CKAN_GIT_URL=https://github.com/ckan/ckan.git CKAN_GIT_BRANCH=ckan-2.10.5 diff --git a/docker/ckan/files/scripts/entrypoint.sh b/docker/ckan/files/scripts/entrypoint.sh index 8142954..2b88696 100755 --- a/docker/ckan/files/scripts/entrypoint.sh +++ b/docker/ckan/files/scripts/entrypoint.sh @@ -38,6 +38,8 @@ DATAPUSHER_TOKEN=$(ckan user token add default datapusher_multi expires_in=365 u ckan config-tool ckan.ini "ckan.datapusher.api_token=${DATAPUSHER_TOKEN}" ckan config-tool ckan.ini "ckanext.datapusher_plus.api_token=${DATAPUSHER_TOKEN}" +ckan config-tool ckan.ini "ckanext.unckan.version=${CKAN_UNI_VERSION}" + # Rebuild webassets in can they were patched ckan asset build From d3387ad41cb8f7c8bd567056dd1ae06fabcdb0af Mon Sep 17 00:00:00 2001 From: avdata99 Date: Wed, 23 Oct 2024 21:28:01 -0300 Subject: [PATCH 2/2] Fix helper --- ckanext-unckan/ckanext/unckan/plugin.py | 2 +- ckanext-unckan/ckanext/unckan/templates/footer.html | 6 ++++++ ckanext-unckan/ckanext/unckan/templates/page.html | 6 ------ 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 ckanext-unckan/ckanext/unckan/templates/footer.html delete mode 100644 ckanext-unckan/ckanext/unckan/templates/page.html diff --git a/ckanext-unckan/ckanext/unckan/plugin.py b/ckanext-unckan/ckanext/unckan/plugin.py index 5773dd5..69c49ee 100644 --- a/ckanext-unckan/ckanext/unckan/plugin.py +++ b/ckanext-unckan/ckanext/unckan/plugin.py @@ -22,5 +22,5 @@ def update_config(self, config_): def get_helpers(self): return { - 'get_unckan_version': base.get_unckan_version + 'get_unckan_version': base.get_unckan_version, } diff --git a/ckanext-unckan/ckanext/unckan/templates/footer.html b/ckanext-unckan/ckanext/unckan/templates/footer.html new file mode 100644 index 0000000..fe49431 --- /dev/null +++ b/ckanext-unckan/ckanext/unckan/templates/footer.html @@ -0,0 +1,6 @@ +{% ckan_extends %} + +{% block footer_attribution %} + {{ super() }} +

UNCKAN v{{ h.get_unckan_version() }}

+{% endblock %} diff --git a/ckanext-unckan/ckanext/unckan/templates/page.html b/ckanext-unckan/ckanext/unckan/templates/page.html deleted file mode 100644 index af580e3..0000000 --- a/ckanext-unckan/ckanext/unckan/templates/page.html +++ /dev/null @@ -1,6 +0,0 @@ -{% ckan extends %} - -{%- block footer %} - {{ super() }} - UNCKAN v{{ h.get_unckan_version }} -{% endblock -%} \ No newline at end of file