Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into release/2.024.17
Browse files Browse the repository at this point in the history
  • Loading branch information
jnm committed Jun 4, 2024
2 parents 81c9c41 + 39ca6d4 commit 8e14964
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion kpi/deployment_backends/base_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ def calculated_submission_count(self, user: 'auth.User', **kwargs):
def connect(self, active=False):
pass

@property
@abc.abstractmethod
def form_uuid(self):
pass

@abc.abstractmethod
def nlp_tracking_data(self, start_date: Optional[datetime.date] = None):
pass
Expand Down Expand Up @@ -793,7 +798,8 @@ def _rewrite_json_attachment_urls(
attachment['filename'] = os.path.join(
self.asset.owner.username,
'attachments',
submission['formhub/uuid'],
# KoboCAT accepts submissions even when they lack `formhub/uuid`
self.form_uuid or submission['formhub/uuid'],
submission['_uuid'],
os.path.basename(filename)
)
Expand Down
10 changes: 10 additions & 0 deletions kpi/deployment_backends/kobocat_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ def connect(self, active=False):
}
)

@property
def form_uuid(self):
try:
return self.backend_response['uuid']
except KeyError:
logging.warning(
'KoboCAT backend response has no `uuid`', exc_info=True
)
return None

@staticmethod
def nlp_tracking_data(asset_ids, start_date=None):
"""
Expand Down
4 changes: 4 additions & 0 deletions kpi/deployment_backends/mock_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ def generate_uuid_for_form():
'version': self.asset.version_id,
})

@property
def form_uuid(self):
return 'formhub-uuid' # to match existing tests

def nlp_tracking_data(self, start_date=None):
"""
Get the NLP tracking data since a specified date
Expand Down

0 comments on commit 8e14964

Please sign in to comment.