Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ch38605]: limit export access log to the last 3 accesses #381

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
----
Expand Down
2 changes: 1 addition & 1 deletion src/etools_datamart/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NAME = "etools-datamart"
VERSION = __version__ = "4.7.12"
VERSION = __version__ = "4.7.15"
__author__ = ""
30 changes: 26 additions & 4 deletions src/etools_datamart/apps/mart/data/models/fm_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down
4 changes: 4 additions & 0 deletions src/unicef_rest_framework/models/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down