From 31bb1186bb1baedce9d2f11a2fd1663a07706d25 Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Fri, 5 May 2023 18:35:38 +0300 Subject: [PATCH 01/17] SXDEDPCXZIC-149 / upgrade ckanext-check-link --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 64b7e005..f597a825 100644 --- a/setup.py +++ b/setup.py @@ -56,7 +56,7 @@ namespace_packages=['ckanext'], install_requires=[ - "ckanext-check-link~=0.0.16", + "ckanext-check-link~=0.1.0", "ckanext-oidc-pkce~=0.2.3", # CKAN extensions should not list dependencies here, but in a separate # ``requirements.txt`` file. From ceafd3149448497666e39d09944c4424fdb7271a Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Fri, 5 May 2023 19:55:47 +0300 Subject: [PATCH 02/17] SXDEDPCXZIC-149 / override button label --- .../datavic_iar_theme/templates/check_link/report.html | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 ckanext/datavic_iar_theme/templates/check_link/report.html diff --git a/ckanext/datavic_iar_theme/templates/check_link/report.html b/ckanext/datavic_iar_theme/templates/check_link/report.html new file mode 100644 index 00000000..3f955b98 --- /dev/null +++ b/ckanext/datavic_iar_theme/templates/check_link/report.html @@ -0,0 +1,9 @@ +{% ckan_extends %} + +{% block check_link_action_download_csv %} +
  • + + {{ _("Download link report") }} + +
  • +{% endblock check_link_action_download_csv %} From 31ad1eb5787fbdfc9803f38ff0753efb35e9da91 Mon Sep 17 00:00:00 2001 From: mutantsan Date: Tue, 30 May 2023 10:09:47 +0300 Subject: [PATCH 03/17] SXDEDPCXZIC-164 / Save data record before adding data resources --- .../datavic_iar_theme/grunt/sass/_form.scss | 36 +++++++++++++++++++ .../package/snippets/package_form.html | 9 ++++- .../webassets/css/datavic_iar_theme.css | 21 +++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/ckanext/datavic_iar_theme/grunt/sass/_form.scss b/ckanext/datavic_iar_theme/grunt/sass/_form.scss index ded60f24..85e845ab 100644 --- a/ckanext/datavic_iar_theme/grunt/sass/_form.scss +++ b/ckanext/datavic_iar_theme/grunt/sass/_form.scss @@ -131,3 +131,39 @@ $break-stages-text-small: 545px; select.form-control { appearance: auto; } + + +.dataset-form { + + .form-actions { + display: flex; + flex-direction: column; + gap: 10px; + + .action-info { + margin: 0; + } + + .btn { + width: 100%; + display: block; + } + } + + @media (min-width: 768px) { + .form-actions { + flex-direction: row; + align-items: center; + + .action-info { + min-width: 250px; + margin-right: 35px; + } + + .btn { + height: fit-content; + max-width: 260px; + } + } + } +} diff --git a/ckanext/datavic_iar_theme/templates/package/snippets/package_form.html b/ckanext/datavic_iar_theme/templates/package/snippets/package_form.html index 20b82cec..d28a1fd5 100644 --- a/ckanext/datavic_iar_theme/templates/package/snippets/package_form.html +++ b/ckanext/datavic_iar_theme/templates/package/snippets/package_form.html @@ -47,18 +47,25 @@

    {%- endtrans -%}

    {% endblock %} + {% block delete_button %} {% if h.check_access('package_delete', {'id': data.id}) and not data.state == 'deleted' %} {% block delete_button_text %}{{ _('Delete') }}{% endblock %} {% endif %} {% endblock %} + {% block save_button %} {% if form_style == 'edit' and is_dataset_harvested %} {% asset 'ckanext-datavicmain/datavicmain-confirm-action' %} + {% elif form_style == "edit" and not is_dataset_harvested %} + {% else %} - + + {% endif %} {% endblock %} diff --git a/ckanext/datavic_iar_theme/webassets/css/datavic_iar_theme.css b/ckanext/datavic_iar_theme/webassets/css/datavic_iar_theme.css index 80ca92ed..5332f84e 100644 --- a/ckanext/datavic_iar_theme/webassets/css/datavic_iar_theme.css +++ b/ckanext/datavic_iar_theme/webassets/css/datavic_iar_theme.css @@ -2028,6 +2028,27 @@ nav { select.form-control { appearance: auto; } +.dataset-form .form-actions { + display: flex; + flex-direction: column; + gap: 10px; } + .dataset-form .form-actions .action-info { + margin: 0; } + .dataset-form .form-actions .btn { + width: 100%; + display: block; } + +@media (min-width: 768px) { + .dataset-form .form-actions { + flex-direction: row; + align-items: center; } + .dataset-form .form-actions .action-info { + min-width: 250px; + margin-right: 35px; } + .dataset-form .form-actions .btn { + height: fit-content; + max-width: 260px; } } + .rpl-form { font-family: "VIC-Regular", "Arial", "Helvetica", "sans-serif"; font-size: 0.875rem; From ad28fc34caa86da4712c50c0f1b4641179c1ee62 Mon Sep 17 00:00:00 2001 From: mutantsan Date: Tue, 30 May 2023 14:54:52 +0300 Subject: [PATCH 04/17] SXDEDPCXZIC-161 / Display Data Visualisation on Record page for CSVs --- ckanext/datavic_iar_theme/helpers.py | 50 ++++++++++++++++--- .../package/snippets/featured_resource.html | 8 +-- .../snippets/resource_views_list_item.html | 24 --------- 3 files changed, 46 insertions(+), 36 deletions(-) diff --git a/ckanext/datavic_iar_theme/helpers.py b/ckanext/datavic_iar_theme/helpers.py index e5ef4245..437b033b 100644 --- a/ckanext/datavic_iar_theme/helpers.py +++ b/ckanext/datavic_iar_theme/helpers.py @@ -127,17 +127,51 @@ def visibility_list() -> list[dict[str, str]]: @helper def featured_resource_preview(package: dict[str, Any]) -> Optional[dict[str, Any]]: - """Return a featured resource preview if exists for a specific dataset""" + """Return a featured resource preview + - It takes only CSV resources with an existing preview + - Only resources uploaded to datastore + - Only not historical resources + """ + featured_preview = None - if package.get("nominated_view_id", None): + + historical_resouce: dict[str, Any] | None = _get_last_resource_if_historical( + package + ) + + resources: list[dict[str, Any]] = ( + sorted(package.get("resources", []), key=lambda res: res["metadata_modified"]) + if not historical_resouce + else [historical_resouce] + ) + + for resource in resources: + if resource.get("format", "").lower() != "csv": + continue + + if not resource.get("datastore_active"): + continue + try: - resource_view = tk.get_action("resource_view_show")( - {}, {"id": package["nominated_view_id"]} + resource_views = tk.get_action("resource_view_list")( + {}, {"id": resource["id"]} ) - resource = tk.get_action("resource_show")( - {}, {"id": resource_view["resource_id"]} - ) - featured_preview = {"preview": resource_view, "resource": resource} except tk.ObjectNotFound: pass + else: + featured_preview = {"preview": resource_views[0], "resource": resource} + return featured_preview + + +def _get_last_resource_if_historical(package: dict[str, Any]) -> dict[str, Any] | None: + """If the dataset contains historical resources, return the most recent one""" + historical_resources = tk.h.historical_resources_list(package.get("resources", [])) + + if len(historical_resources) <= 1: + return + + if historical_resources[1].get("period_start"): + return historical_resources[0] + + return diff --git a/ckanext/datavic_iar_theme/templates/package/snippets/featured_resource.html b/ckanext/datavic_iar_theme/templates/package/snippets/featured_resource.html index 305a5f66..1738bbc5 100644 --- a/ckanext/datavic_iar_theme/templates/package/snippets/featured_resource.html +++ b/ckanext/datavic_iar_theme/templates/package/snippets/featured_resource.html @@ -1,12 +1,12 @@ {% set resource_view = h.vic_iar_featured_resource_preview(pkg) %} -{% if request.args.get('no_preview') != '1' and resource_view %} +{% if resource_view %}
    -

    {{ _('Data preview') }}

    +

    {{ _('Data preview') }} - {{ resource_view.resource.name }}

    {% snippet 'package/snippets/resource_view.html', - resource_view=resource_view['preview'], - resource=resource_view['resource'], + resource_view=resource_view.preview, + resource=resource_view.resource, package=pkg %}
    diff --git a/ckanext/datavic_iar_theme/templates/package/snippets/resource_views_list_item.html b/ckanext/datavic_iar_theme/templates/package/snippets/resource_views_list_item.html index 9802b952..10068e51 100644 --- a/ckanext/datavic_iar_theme/templates/package/snippets/resource_views_list_item.html +++ b/ckanext/datavic_iar_theme/templates/package/snippets/resource_views_list_item.html @@ -10,32 +10,8 @@ {% endif %}
  • - {{ view.title }} - - {% if pkg.nominated_view_id == view.id %} - {% set url_denominate = h.url_for('datavicmain.denominate_view', package_id=pkg.id, view_id=view.id) %} -
    - {{ h.csrf_input() }} - - -
    - {% else %} - - {% set url_nominate = h.url_for('datavicmain.nominate_view', package_id=pkg.id, view_id=view.id) %} -
    - {{ h.csrf_input() }} - - -
    - {% endif %} - -
  • From 795252f28d111dd676c7fb88639a50173c5bb6a8 Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Fri, 16 Jun 2023 19:10:36 +0300 Subject: [PATCH 05/17] SXDEDPCXZIC-174_DATAVIC-537 / configurable org uploads --- .../templates/organization/edit_base.html | 13 +++++++++++++ setup.py | 1 + 2 files changed, 14 insertions(+) create mode 100644 ckanext/datavic_iar_theme/templates/organization/edit_base.html diff --git a/ckanext/datavic_iar_theme/templates/organization/edit_base.html b/ckanext/datavic_iar_theme/templates/organization/edit_base.html new file mode 100644 index 00000000..77d86a6e --- /dev/null +++ b/ckanext/datavic_iar_theme/templates/organization/edit_base.html @@ -0,0 +1,13 @@ +{% ckan_extends %} + +{% block content_action %} + {% if organization and h.check_access('datavic_toggle_organization_uploads', {'id': organization.id}) %} +
    + +
    + {% endif %} + {{ super() }} +{% endblock %} diff --git a/setup.py b/setup.py index d35b0cd2..6cd1864b 100644 --- a/setup.py +++ b/setup.py @@ -48,6 +48,7 @@ "ckanext-oidc-pkce~=0.2.3", "ckanext-vip-portal~=0.2.1", "ckanext-toolbelt >=0.2.3, <1.0.0", + "ckanext-flakes~=0.4.1", ], # If there are data files included in your packages that need to be # installed, specify them here. If using Python 2.6 or less, then these From 85bd9ff6926845a0ccd04759a062301810606292 Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Mon, 19 Jun 2023 11:16:20 +0300 Subject: [PATCH 06/17] SXDEDPCXZIC-178 / fix 500 error when resource has no views --- ckanext/datavic_iar_theme/helpers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ckanext/datavic_iar_theme/helpers.py b/ckanext/datavic_iar_theme/helpers.py index 437b033b..697d3c9d 100644 --- a/ckanext/datavic_iar_theme/helpers.py +++ b/ckanext/datavic_iar_theme/helpers.py @@ -159,7 +159,8 @@ def featured_resource_preview(package: dict[str, Any]) -> Optional[dict[str, Any except tk.ObjectNotFound: pass else: - featured_preview = {"preview": resource_views[0], "resource": resource} + if resource_views: + featured_preview = {"preview": resource_views[0], "resource": resource} return featured_preview From 2fe4d6be59f6f6f8a906951487afbf583e7c67bf Mon Sep 17 00:00:00 2001 From: oleksandrivaniuk Date: Mon, 7 Aug 2023 15:24:18 +0300 Subject: [PATCH 07/17] SXDEDPCXZIC-200 / changes to datatables --- .../grunt/sass/_datatables.scss | 81 +++++++++++++++++++ .../datavic_iar_theme/grunt/sass/styles.scss | 1 + .../webassets/css/datavic_iar_theme.css | 50 ++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 ckanext/datavic_iar_theme/grunt/sass/_datatables.scss diff --git a/ckanext/datavic_iar_theme/grunt/sass/_datatables.scss b/ckanext/datavic_iar_theme/grunt/sass/_datatables.scss new file mode 100644 index 00000000..3cf717e7 --- /dev/null +++ b/ckanext/datavic_iar_theme/grunt/sass/_datatables.scss @@ -0,0 +1,81 @@ +.dataTables_wrapper { + .dt-buttons { + .btn-secondary { + background-color: #f6f6f6; + padding: 16px 16px; + } + + button[title="Table/List toggle"], + button[title="Toggle column visibility"], + button[title="Share current view"] { + display: none; + visibility: hidden; + } + + button[title="Copy to clipboard"] { + border-top-left-radius: 0.25rem; + border-bottom-left-radius: 0.25rem; + } + + button[title="Print"] { + border-top-right-radius: 0.25rem !important; + border-top-right-radius: 0.25rem !important; + } + + .btn-secondary { + background-color: #f6f6f6; + border: #dee2e6 solid 1px; + } + } + + #dtprv_filter { + display: block; + text-align: left; + margin-top: 0; + float: none; + + #filterinfoicon { + display: none; + } + + label { + display: flex; + align-items: center; + + input { + width: 100%; + } + + &::after { + content: ""; + } + } + + } + + .sortinfo, .resourceinfo { + display: none; + } + + .dataTables_scroll + .dtr-control:before { + background-color: #3A833A !important; + } + + #dtprv_paginate { + ul { + li { + &.active { + a { + background-color: #3A833A !important; + } + } + } + } + } + + .pagination { + padding-top: 2.5rem; + } + +} \ No newline at end of file diff --git a/ckanext/datavic_iar_theme/grunt/sass/styles.scss b/ckanext/datavic_iar_theme/grunt/sass/styles.scss index 5d3e9f8b..17360b27 100644 --- a/ckanext/datavic_iar_theme/grunt/sass/styles.scss +++ b/ckanext/datavic_iar_theme/grunt/sass/styles.scss @@ -61,3 +61,4 @@ @import 'reporting'; @import 'login'; @import 'activity'; +@import 'datatables'; diff --git a/ckanext/datavic_iar_theme/webassets/css/datavic_iar_theme.css b/ckanext/datavic_iar_theme/webassets/css/datavic_iar_theme.css index 5332f84e..e062b458 100644 --- a/ckanext/datavic_iar_theme/webassets/css/datavic_iar_theme.css +++ b/ckanext/datavic_iar_theme/webassets/css/datavic_iar_theme.css @@ -3203,3 +3203,53 @@ a.close { .activity .item .date { color: #757575; } + +.dataTables_wrapper .dt-buttons .btn-secondary { + background-color: #f6f6f6; + padding: 16px 16px; } + +.dataTables_wrapper .dt-buttons button[title="Table/List toggle"], +.dataTables_wrapper .dt-buttons button[title="Toggle column visibility"], +.dataTables_wrapper .dt-buttons button[title="Share current view"] { + display: none; + visibility: hidden; } + +.dataTables_wrapper .dt-buttons button[title="Copy to clipboard"] { + border-top-left-radius: 0.25rem; + border-bottom-left-radius: 0.25rem; } + +.dataTables_wrapper .dt-buttons button[title="Print"] { + border-top-right-radius: 0.25rem !important; + border-top-right-radius: 0.25rem !important; } + +.dataTables_wrapper .dt-buttons .btn-secondary { + background-color: #f6f6f6; + border: #dee2e6 solid 1px; } + +.dataTables_wrapper #dtprv_filter { + display: block; + text-align: left; + margin-top: 0; + float: none; } + .dataTables_wrapper #dtprv_filter #filterinfoicon { + display: none; } + .dataTables_wrapper #dtprv_filter label { + display: flex; + align-items: center; } + .dataTables_wrapper #dtprv_filter label input { + width: 100%; } + .dataTables_wrapper #dtprv_filter label::after { + content: ""; } + +.dataTables_wrapper .sortinfo, .dataTables_wrapper .resourceinfo { + display: none; } + +.dataTables_wrapper .dataTables_scroll +.dtr-control:before { + background-color: #3A833A !important; } + +.dataTables_wrapper #dtprv_paginate ul li.active a { + background-color: #3A833A !important; } + +.dataTables_wrapper .pagination { + padding-top: 2.5rem; } From 1d274e97ff9785cdc0ba3934a188e2452ea0c4cf Mon Sep 17 00:00:00 2001 From: oleksandrivaniuk Date: Mon, 7 Aug 2023 15:42:01 +0300 Subject: [PATCH 08/17] SXDEDPCXZIC-196 / fix html language attribute --- ckanext/datavic_iar_theme/templates/base.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ckanext/datavic_iar_theme/templates/base.html b/ckanext/datavic_iar_theme/templates/base.html index 0c704884..48d1acb1 100644 --- a/ckanext/datavic_iar_theme/templates/base.html +++ b/ckanext/datavic_iar_theme/templates/base.html @@ -24,6 +24,6 @@ {% endblock %} {%- block htmltag -%} - - + + {%- endblock -%} From 6acf0d57a1b01f760cfa6f8f34eac809ea97ada1 Mon Sep 17 00:00:00 2001 From: Iaroslav Pereiaslovets Date: Tue, 8 Aug 2023 15:23:26 +1000 Subject: [PATCH 09/17] move gtm to the new GA extension --- ckanext/datavic_iar_theme/templates/base.html | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ckanext/datavic_iar_theme/templates/base.html b/ckanext/datavic_iar_theme/templates/base.html index 0c704884..edf1293e 100644 --- a/ckanext/datavic_iar_theme/templates/base.html +++ b/ckanext/datavic_iar_theme/templates/base.html @@ -3,10 +3,6 @@ {% block head_extras %} {{ super() }} - {% if h.vic_iar_get_gtm_container_id() %} - {% snippet "snippets/gtm_include.html" %} - {% endif %} - {% if h.vic_iar_hotjar_tracking_enabled() %} {% snippet "snippets/hotjar.html" %} {% endif %} From f3c88fb3d608f5cc80a2ce6ff2965e39ab021a10 Mon Sep 17 00:00:00 2001 From: Iaroslav Pereiaslovets Date: Tue, 8 Aug 2023 15:24:11 +1000 Subject: [PATCH 10/17] move gtm to the new GA extension --- ckanext/datavic_iar_theme/templates/page.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/ckanext/datavic_iar_theme/templates/page.html b/ckanext/datavic_iar_theme/templates/page.html index 243dba9d..6c14c130 100644 --- a/ckanext/datavic_iar_theme/templates/page.html +++ b/ckanext/datavic_iar_theme/templates/page.html @@ -1,9 +1,6 @@ {% ckan_extends %} {% block skip %} - {% if h.vic_iar_get_gtm_container_id() %} - {% snippet "snippets/gtm_include_noscript.html" %} - {% endif %} {{ super() }} {% endblock %} From df58804fa0ef6650ae48cad422a6cd691b6717af Mon Sep 17 00:00:00 2001 From: Iaroslav Pereiaslovets Date: Tue, 8 Aug 2023 15:24:46 +1000 Subject: [PATCH 11/17] move gtm to the new GA extension --- .../templates/snippets/gtm_include_noscript.html | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 ckanext/datavic_iar_theme/templates/snippets/gtm_include_noscript.html diff --git a/ckanext/datavic_iar_theme/templates/snippets/gtm_include_noscript.html b/ckanext/datavic_iar_theme/templates/snippets/gtm_include_noscript.html deleted file mode 100644 index e33de804..00000000 --- a/ckanext/datavic_iar_theme/templates/snippets/gtm_include_noscript.html +++ /dev/null @@ -1,4 +0,0 @@ - - - From 55d44165afbe39508be5d9f78b7256e044045e37 Mon Sep 17 00:00:00 2001 From: Iaroslav Pereiaslovets Date: Tue, 8 Aug 2023 15:25:30 +1000 Subject: [PATCH 12/17] move GTM to the new GA extension --- .../datavic_iar_theme/templates/snippets/gtm_include.html | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 ckanext/datavic_iar_theme/templates/snippets/gtm_include.html diff --git a/ckanext/datavic_iar_theme/templates/snippets/gtm_include.html b/ckanext/datavic_iar_theme/templates/snippets/gtm_include.html deleted file mode 100644 index f06a9aa7..00000000 --- a/ckanext/datavic_iar_theme/templates/snippets/gtm_include.html +++ /dev/null @@ -1,7 +0,0 @@ - - - From c5400fe5bb6d5143edc7d085e7910acc119bacf1 Mon Sep 17 00:00:00 2001 From: Iaroslav Pereiaslovets Date: Tue, 8 Aug 2023 15:26:37 +1000 Subject: [PATCH 13/17] move gtm to the new ga extension --- ckanext/datavic_iar_theme/helpers.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ckanext/datavic_iar_theme/helpers.py b/ckanext/datavic_iar_theme/helpers.py index 697d3c9d..5b675972 100644 --- a/ckanext/datavic_iar_theme/helpers.py +++ b/ckanext/datavic_iar_theme/helpers.py @@ -80,11 +80,6 @@ def get_hotjar_hjsv(): return conf.get_hotjar_hjsv() -@helper -def get_gtm_container_id(): - return conf.get_gtm_container_id() - - @helper def linked_user(user: str, maxlength: int = 0, avatar: int = 20): """Custom linked_user helper""" From 6b05ba6611693aede6446a1d23bf247f4b473fc0 Mon Sep 17 00:00:00 2001 From: Iaroslav Pereiaslovets Date: Tue, 8 Aug 2023 15:27:20 +1000 Subject: [PATCH 14/17] move gtm to the new ga extension --- ckanext/datavic_iar_theme/config.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ckanext/datavic_iar_theme/config.py b/ckanext/datavic_iar_theme/config.py index 85b552c7..19a40594 100644 --- a/ckanext/datavic_iar_theme/config.py +++ b/ckanext/datavic_iar_theme/config.py @@ -9,7 +9,6 @@ CONFIG_HOTJAR_ENABLED = "ckan.tracking.hotjar_enabled" CONFIG_HOTJAR_HJID = "ckan.tracking.hotjar.hjid" CONFIG_HOTJAR_HJSV = "ckan.tracking.hotjar.hjsv" -CONFIG_GTM_CONTAINER_ID = "ckan.google_tag_manager.gtm_container_id" def get_parent_site_url() -> str: @@ -27,6 +26,3 @@ def get_hotjar_hsid() -> str | None: def get_hotjar_hjsv() -> str | None: return tk.config.get(CONFIG_HOTJAR_HJSV) - -def get_gtm_container_id() -> str | None: - return tk.config.get(CONFIG_GTM_CONTAINER_ID) From 18d5437c75747a251ee837f41710242c6d0f9183 Mon Sep 17 00:00:00 2001 From: oleksandrivaniuk Date: Tue, 8 Aug 2023 11:17:31 +0300 Subject: [PATCH 15/17] SXDEDPCXZIC-196 / fix html language attribute --- ckanext/datavic_iar_theme/templates/base.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ckanext/datavic_iar_theme/templates/base.html b/ckanext/datavic_iar_theme/templates/base.html index 48d1acb1..1cdbc5e1 100644 --- a/ckanext/datavic_iar_theme/templates/base.html +++ b/ckanext/datavic_iar_theme/templates/base.html @@ -24,6 +24,12 @@ {% endblock %} {%- block htmltag -%} + {% set lang = h.lang() %} + + {% if lang == 'en_AU' %} + {% set lang = 'en-au' %} + {% endif %} + {%- endblock -%} From eeb7b47b800aa5fbabaa3a44e0a96f1ec6336968 Mon Sep 17 00:00:00 2001 From: amorev Date: Sun, 13 Aug 2023 21:43:25 +0300 Subject: [PATCH 16/17] SXDEDPCXZIC-202_DATAVIC-598 / add search autosuggest --- .../snippets/dataset_search_form.html | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/ckanext/datavic_iar_theme/templates/snippets/dataset_search_form.html b/ckanext/datavic_iar_theme/templates/snippets/dataset_search_form.html index aff7bd48..96d400d6 100644 --- a/ckanext/datavic_iar_theme/templates/snippets/dataset_search_form.html +++ b/ckanext/datavic_iar_theme/templates/snippets/dataset_search_form.html @@ -29,19 +29,32 @@

    -
    +
    {% block search_input_button %} - + +
      + {% set suggestion_groups = [ + ('datasets', 'Relevant datasets'), + ('categories','Browse filters') + ] + %} + + {% for section, label in suggestion_groups %} +
    • +
        +
      • + {% endfor %} +
      {% endblock %}
      {% if facets %} From 7a42a161da5d2e44250107afa246a0c9a4809b5d Mon Sep 17 00:00:00 2001 From: Oleksandr Cherniavskyi Date: Fri, 18 Aug 2023 11:31:04 +0300 Subject: [PATCH 17/17] SXDEDPCXZIC-206 / Improve historical data view --- ckanext/datavic_iar_theme/helpers.py | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/ckanext/datavic_iar_theme/helpers.py b/ckanext/datavic_iar_theme/helpers.py index 5b675972..be9f2b35 100644 --- a/ckanext/datavic_iar_theme/helpers.py +++ b/ckanext/datavic_iar_theme/helpers.py @@ -130,15 +130,11 @@ def featured_resource_preview(package: dict[str, Any]) -> Optional[dict[str, Any featured_preview = None - historical_resouce: dict[str, Any] | None = _get_last_resource_if_historical( - package + resource_groups: list[list[dict[str, Any]]] = tk.h.group_resources_by_temporal_range( + package.get("resources", []) ) - resources: list[dict[str, Any]] = ( - sorted(package.get("resources", []), key=lambda res: res["metadata_modified"]) - if not historical_resouce - else [historical_resouce] - ) + resources = resource_groups[0] if resource_groups else [] for resource in resources: if resource.get("format", "").lower() != "csv": @@ -158,16 +154,3 @@ def featured_resource_preview(package: dict[str, Any]) -> Optional[dict[str, Any featured_preview = {"preview": resource_views[0], "resource": resource} return featured_preview - - -def _get_last_resource_if_historical(package: dict[str, Any]) -> dict[str, Any] | None: - """If the dataset contains historical resources, return the most recent one""" - historical_resources = tk.h.historical_resources_list(package.get("resources", [])) - - if len(historical_resources) <= 1: - return - - if historical_resources[1].get("period_start"): - return historical_resources[0] - - return