diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt index 3c2a755..8b14ded 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -1,6 +1,11 @@ Changelog ========= +10.3 - (2024-06-11) +--------------------------- +* Change: Release + [claudiaifrim] + 10.2 - (2024-05-08) --------------------------- * Change: Release diff --git a/eea/api/dataconnector/behavior.py b/eea/api/dataconnector/behavior.py index 3ded1fa..6a4fee7 100644 --- a/eea/api/dataconnector/behavior.py +++ b/eea/api/dataconnector/behavior.py @@ -1,26 +1,31 @@ """ behavior module """ + import csv import logging from io import StringIO -from plone.app.dexterity.behaviors.metadata import DCFieldProperty -from plone.app.dexterity.behaviors.metadata import MetadataBase + +from plone.app.dexterity.behaviors.metadata import ( + DCFieldProperty, + MetadataBase +) from plone.dexterity.interfaces import IDexterityContent from plone.rfc822.interfaces import IPrimaryFieldInfo +from plone.restapi.deserializer import json_body from zope.component import adapter from zope.interface import implementer from zope.publisher.interfaces.browser import IBrowserRequest + from eea.api.dataconnector.queryparser import computeDataQuery from eea.api.dataconnector.queryfilter import filteredData -from .interfaces import IConnectorDataParameters -from .interfaces import IDataConnector -from .interfaces import IDataProvider -from .interfaces import IDataVisualization -from .interfaces import IMaps -from .interfaces import IMapVisualization -from .interfaces import ITableauVisualization -from .interfaces import IFileDataProvider -from .interfaces import IElasticConnector -from .interfaces import IFigureNote + +from .interfaces import ( + IConnectorDataParameters, IDataConnector, + IDataProvider, + IDataVisualization, + IMaps, IMapVisualization, ITableauVisualization, + IFileDataProvider, + IElasticConnector, IFigureNote +) logger = logging.getLogger(__name__) @@ -38,8 +43,7 @@ class DataConnector(MetadataBase): sql_query = DCFieldProperty(IDataConnector["sql_query"]) parameters = DCFieldProperty(IDataConnector["parameters"]) required_parameters = DCFieldProperty( - IDataConnector["required_parameters"] - ) + IDataConnector["required_parameters"]) collate = DCFieldProperty(IDataConnector["collate"]) readme = DCFieldProperty(IDataConnector["readme"]) @@ -58,6 +62,9 @@ def provided_data(self): """provided data""" field = IPrimaryFieldInfo(self.context) + page = json_body(self.request).get("form", {}).get("p", 0) + nrOfHits = json_body(self.request).get("form", {}).get("nrOfHits", 0) + if not field.value: return [] @@ -76,9 +83,13 @@ def provided_data(self): keys = rows[0] data = [] - for index, row in enumerate(rows[1:]): + for index, row in enumerate( + rows[((page - 1) * nrOfHits + 1):(page * nrOfHits + 1)] + if page >= 1 and nrOfHits >= 1 + else rows[1:] + ): data.append({}) - for (i, k) in enumerate(keys): + for i, k in enumerate(keys): data[index][k] = row[i] data_query = computeDataQuery(self.request) @@ -102,9 +113,9 @@ def __init__(self, context, request): def provided_data(self): """provided data""" - widget = getattr(self.context, 'elastic_csv_widget', None) + widget = getattr(self.context, "elastic_csv_widget", None) - data = widget['tableData'] if widget else {} + data = widget["tableData"] if widget else {} return { "results": data, @@ -150,13 +161,10 @@ class ElasticConnectorWidget(MetadataBase): """Build csv data from ES data""" elastic_csv_widget = DCFieldProperty( - IElasticConnector["elastic_csv_widget"] - ) + IElasticConnector["elastic_csv_widget"]) class FigureNoteField(MetadataBase): """Insert Figure Note field""" - figure_note = DCFieldProperty( - IFigureNote["figure_note"] - ) + figure_note = DCFieldProperty(IFigureNote["figure_note"]) diff --git a/eea/api/dataconnector/browser/blocks.py b/eea/api/dataconnector/browser/blocks.py index 111e992..dc63a26 100644 --- a/eea/api/dataconnector/browser/blocks.py +++ b/eea/api/dataconnector/browser/blocks.py @@ -266,9 +266,9 @@ def __call__(self, value): return { **value, "vis_url": vis_url, "visualization": { - **getMetadata(doc_serializer), **getVisualization(serializer=doc_serializer, layout=use_data_sources), + **getMetadata(doc_serializer), } } return {**value, "vis_url": uid_to_url(value.get('vis_url'))} @@ -369,8 +369,8 @@ def __call__(self, value): return { **value, "tableau_vis_url": tableau_vis_url, "tableau_visualization": { - **getMetadata(doc_serializer), **doc_serializer.get('tableau_visualization', {}), + **getMetadata(doc_serializer), } } return { @@ -474,8 +474,8 @@ def __call__(self, value): return { **value, "vis_url": vis_url, "map_visualization_data": { - **getMetadata(doc_serializer), **doc_serializer.get('map_visualization_data', {}), + **getMetadata(doc_serializer), } } return { @@ -574,8 +574,8 @@ def __call__(self, value): if doc_serializer: return { **value, "maps": { - **getMetadata(doc_serializer), **doc_serializer.get('maps', {}), + **getMetadata(doc_serializer), } } return value diff --git a/eea/api/dataconnector/version.txt b/eea/api/dataconnector/version.txt index e2498ea..260e375 100644 --- a/eea/api/dataconnector/version.txt +++ b/eea/api/dataconnector/version.txt @@ -1 +1 @@ -10.2 +10.3