diff --git a/CHANGES b/CHANGES index 868f3313..f1347a52 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,21 @@ + +4.7.15 +---- +* ExportAccessLog usage has been simplified by keeping the last access as the sole purpose + it to see if an export is in use at all. + +4.7.14 +---- +* Fix logic error extract_longitude function + +4.7.13 +---- +* Improved FMQuestion and FMOntrack loaders to extract latitude and longitude from +Location.point when Location.longitude and Location.latitude. + 4.7.12 ---- -Formula for SpotCheckFindings.pending_unsupported_amount has been updated as below; +* Formula for SpotCheckFindings.pending_unsupported_amount has been updated as below; = audit_spotcheck.total_amount_of_ineligible_expenditure audit_engagement.additional_supporting_documentation_provided audit_engagement.justification_provided_and_accepted @@ -9,19 +24,19 @@ Formula for SpotCheckFindings.pending_unsupported_amount has been updated as bel 4.7.11 ---- -CI pipline improvements for version tagging. +* CI pipline improvements for version tagging. 4.7.10 ---- -Further improve Celery task failure error report +* Further improve Celery task failure error report 4.7.9 ---- -Make groups parameter name consistent +* Make groups parameter name consistent ---- -Hotfix for export access log to handle non-standard date format +* Hotfix for export access log to handle non-standard date format 4.7.6 ---- diff --git a/src/etools_datamart/__init__.py b/src/etools_datamart/__init__.py index 8a2d0aee..f7c6faf2 100644 --- a/src/etools_datamart/__init__.py +++ b/src/etools_datamart/__init__.py @@ -1,3 +1,3 @@ NAME = "etools-datamart" -VERSION = __version__ = "4.7.12" +VERSION = __version__ = "4.7.15" __author__ = "" diff --git a/src/etools_datamart/apps/mart/data/models/fm_questions.py b/src/etools_datamart/apps/mart/data/models/fm_questions.py index 8c5298b1..6213bf0f 100644 --- a/src/etools_datamart/apps/mart/data/models/fm_questions.py +++ b/src/etools_datamart/apps/mart/data/models/fm_questions.py @@ -25,6 +25,28 @@ logger = get_task_logger(__name__) +def extract_latitude(location): + if location.latitude is not None: + return location.latitude + elif location.point is not None: + return location.point.y + elif location.geom is not None: + return location.centroid.y + else: + return None + + +def extract_longitude(location): + if location.longitude is not None: + return location.longitude + elif location.point is not None: + return location.point.x + elif location.geom is not None: + return location.centroid.x + else: + return None + + class FMQuestionLoader(EtoolsLoader): """Loader for FM Questions""" @@ -244,8 +266,8 @@ def get_location(self, record: FieldMonitoringDataCollectionFinding, values: dic "admin_level": instance.admin_level, "source_id": instance.source_id, "location_type": instance.admin_level_name, - "latitude": instance.latitude, - "longitude": instance.longitude, + "latitude": extract_latitude(instance), + "longitude": extract_longitude(instance), } except Location.DoesNotExist: return {key: "N/A" for key in loc_fields} @@ -486,8 +508,8 @@ def get_location(self, record: FieldMonitoringDataCollectionActivityoverallfindi "admin_level": instance.admin_level, "source_id": instance.source_id, "location_type": instance.admin_level_name, - "latitude": instance.latitude, - "longitude": instance.longitude, + "latitude": extract_latitude(instance), + "longitude": extract_longitude(instance), } except Location.DoesNotExist: return {key: "N/A" for key in loc_fields} diff --git a/src/unicef_rest_framework/models/export.py b/src/unicef_rest_framework/models/export.py index 991aa466..c2e1acb3 100644 --- a/src/unicef_rest_framework/models/export.py +++ b/src/unicef_rest_framework/models/export.py @@ -149,6 +149,10 @@ def log_access(cls, export, username): try: access_log = cls.objects.get(export=export) + + while len(access_log.access_history) >= 3: + access_log.access_history.pop(0) + access_log.access_history.append(log_entry) access_log.save() except cls.DoesNotExist: