diff --git a/.gitignore b/.gitignore
index a04365f9..04c35530 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,7 +11,7 @@ syntax: glob
.vscode/
# Cypress
-cypress/e2e/videos/*
+cypress/videos/*
cypress/e2e/screenshots/*
cypress/e2e/results/output.xml
node_modules
diff --git a/ckanext/datagovtheme/fanstatic_library/scripts/geoplatform.js b/ckanext/datagovtheme/fanstatic_library/scripts/geoplatform.js
new file mode 100644
index 00000000..e3b83534
--- /dev/null
+++ b/ckanext/datagovtheme/fanstatic_library/scripts/geoplatform.js
@@ -0,0 +1,41 @@
+jQuery(function ($) {
+ async function getGeoplatformLink() {
+ let parentEl = document.getElementById("geoplatform-link-section");
+ if (parentEl == null) {
+ return;
+ }
+ let datasetName = parentEl.getAttribute("data-package-name");
+ try {
+ const response = await fetch(
+ `https://api.geoplatform.gov/v3/public/lookups/data-gov/dataset?name=${datasetName}`,
+ { signal: AbortSignal.timeout(20000) }
+ )
+ .then((response) => {
+ if (response.ok) {
+ return response.json();
+ }
+ if (response.status == 404) {
+ console.log("dataset doesn't exist on geoplatform");
+ }
+ if (response.status >= 500) {
+ console.warn(
+ "geoplatform couldn't fulfill the request"
+ );
+ }
+ })
+ .then((data) => {
+ let el = document.getElementById("geoplatform-link");
+ el.href = data.geoplatform_url;
+ parentEl.classList.remove("hide");
+ });
+ } catch (error) {
+ if (error.name === "TimeoutError") {
+ console.error("request timeout. geoplatform not reachable");
+ } else {
+ console.error(error);
+ }
+ }
+ }
+
+ getGeoplatformLink();
+});
diff --git a/ckanext/datagovtheme/fanstatic_library/webassets.yml b/ckanext/datagovtheme/fanstatic_library/webassets.yml
index 98157f92..28b6fff9 100644
--- a/ckanext/datagovtheme/fanstatic_library/webassets.yml
+++ b/ckanext/datagovtheme/fanstatic_library/webassets.yml
@@ -10,6 +10,7 @@ js:
- scripts/tracking.js
- scripts/hideMaxListItem.js
- scripts/sorting.js
+ - scripts/geoplatform.js
styles:
# This name is used in development/debug mode, must match the css file in test_datagovtheme.py
diff --git a/ckanext/datagovtheme/templates/package/read.html b/ckanext/datagovtheme/templates/package/read.html
index 91b6f7f1..fed81cc0 100644
--- a/ckanext/datagovtheme/templates/package/read.html
+++ b/ckanext/datagovtheme/templates/package/read.html
@@ -275,6 +275,8 @@
{{ _('Metadata Source') }}
{% endif %}
{% endif %}
+
+ {% include 'package/snippets/geoplatform_link.html' %}
{% set graphic_preview_file =h.get_pkg_dict_extra(pkg, 'graphic-preview-file', None) %}
{% if graphic_preview_file and graphic_preview_file.lower()[:4] == 'http' %}
diff --git a/ckanext/datagovtheme/templates/package/snippets/geoplatform_link.html b/ckanext/datagovtheme/templates/package/snippets/geoplatform_link.html
new file mode 100644
index 00000000..83bb861d
--- /dev/null
+++ b/ckanext/datagovtheme/templates/package/snippets/geoplatform_link.html
@@ -0,0 +1,16 @@
+
+ Other Data Resources
+
+
diff --git a/cypress/e2e/geoplatform.cy.js b/cypress/e2e/geoplatform.cy.js
new file mode 100644
index 00000000..0f09fc46
--- /dev/null
+++ b/cypress/e2e/geoplatform.cy.js
@@ -0,0 +1,40 @@
+describe("Geoplatform Link", () => {
+ it("Check if other data resources section is visible", () => {
+ cy.intercept(
+ {
+ method: "GET",
+ url: "https://api.geoplatform.gov/v3/public/lookups/data-gov/dataset?name=test_mock_geoplatform_data",
+ },
+ {
+ statusCode: 200,
+ body: {
+ geoplatform_url: "https://www.youtube.com/",
+ },
+ }
+ );
+
+ cy.visit("/dataset/test_mock_geoplatform_data");
+ cy.wait(10000);
+ cy.get('section[id="geoplatform-link-section"]')
+ .scrollIntoView()
+ .should("be.visible");
+ });
+
+ it("Check if other data resources section is not visible", () => {
+ cy.intercept(
+ {
+ method: "GET",
+ url: "https://api.geoplatform.gov/v3/public/lookups/data-gov/dataset?name=test_bad_mock_geoplatform_data",
+ },
+ {
+ statusCode: 404,
+ body: {},
+ }
+ );
+
+ cy.visit("/dataset/test_bad_mock_geoplatform_data");
+ cy.get('section[id="geoplatform-link-section"]').should(
+ "not.be.visible"
+ );
+ });
+});
diff --git a/docker-entrypoint.d/seed.py b/docker-entrypoint.d/seed.py
index 234ebdc5..064799b5 100644
--- a/docker-entrypoint.d/seed.py
+++ b/docker-entrypoint.d/seed.py
@@ -63,3 +63,12 @@ def get_base_dataset():
print(f'Dataset {x} created')
except Exception as er:
print(f'exception: {er}')
+
+ # Create our test geoplatform datasets
+ dataset = get_base_dataset()
+ dataset['name'] = 'test_mock_geoplatform_data'
+ factories.Dataset(**dataset)
+
+ dataset = get_base_dataset()
+ dataset['name'] = 'test_bad_mock_geoplatform_data'
+ factories.Dataset(**dataset)
diff --git a/package.json b/package.json
new file mode 100644
index 00000000..dfba8d29
--- /dev/null
+++ b/package.json
@@ -0,0 +1,5 @@
+{
+ "devDependencies": {
+ "cypress": "^13.6.1"
+ }
+}
diff --git a/setup.py b/setup.py
index 58fcfe99..1a987d8c 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@
setup(
name="ckanext-datagovtheme",
- version="0.2.8",
+ version="0.2.9",
description="CKAN Extension to manage data.gov theme",
long_description=long_description,
classifiers=[