Skip to content

Commit

Permalink
Merge pull request #68 from eea/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
claudiaifrim authored Jun 11, 2024
2 parents 13b1083 + 08ff432 commit 98d1ac7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 28 deletions.
5 changes: 5 additions & 0 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

10.3 - (2024-06-11)
---------------------------
* Change: Release
[claudiaifrim]

10.2 - (2024-05-08)
---------------------------
* Change: Release
Expand Down
54 changes: 31 additions & 23 deletions eea/api/dataconnector/behavior.py
Original file line number Diff line number Diff line change
@@ -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__)
Expand All @@ -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"])

Expand All @@ -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 []

Expand All @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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"])
8 changes: 4 additions & 4 deletions eea/api/dataconnector/browser/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion eea/api/dataconnector/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.2
10.3

0 comments on commit 98d1ac7

Please sign in to comment.