def get_latest_workgroup_submissions_by_id(self, group_id): """ :param int group_id: Group ID :rtype: dict[dict] """ submission_list = self.get_workgroup_submissions(group_id) submissions_by_id = {} for submission in submission_list: submission_id = submission['document_id'] if submission['user']: submission[u'user_details'] = self.get_user_details(submission['user']) if submission_id in submissions_by_id: last_modified = build_date_field(submissions_by_id[submission_id]["modified"]) this_modified = build_date_field(submission["modified"]) if this_modified > last_modified: submissions_by_id[submission["document_id"]] = submission else: submissions_by_id[submission["document_id"]] = submission return submissions_by_id
def get_upload(self, group_id): submission_map = self.project_api.get_latest_workgroup_submissions_by_id(group_id) submission_data = submission_map.get(self.upload_id, None) if submission_data is None: return None return SubmissionUpload( submission_data["document_url"], submission_data["document_filename"], format_date(build_date_field(submission_data["modified"])), submission_data.get("user_details", None) )
def get_upload(self, group_id): submission_map = self.project_api.get_latest_workgroup_submissions_by_id( group_id) submission_data = submission_map.get(self.upload_id, None) if submission_data is None: return None return SubmissionUpload( submission_data["document_url"], submission_data["document_filename"], format_date(build_date_field(submission_data["modified"])), submission_data.get("user_details", None))
def get_latest_workgroup_submissions_by_id(self, group_id): """ :param int group_id: Group ID :rtype: dict[dict] """ submission_list = self.get_workgroup_submissions(group_id) submissions_by_id = {} for submission in submission_list: submission_id = submission['document_id'] if submission['user']: submission[u'user_details'] = self.get_user_details( submission['user']) if submission_id in submissions_by_id: last_modified = build_date_field( submissions_by_id[submission_id]["modified"]) this_modified = build_date_field(submission["modified"]) if this_modified > last_modified: submissions_by_id[submission["document_id"]] = submission else: submissions_by_id[submission["document_id"]] = submission return submissions_by_id
def get_upload(self, group_id): submission_map = self.project_api.get_latest_workgroup_submissions_by_id( group_id) submission_data = submission_map.get(self.upload_id, None) if submission_data is None: return None document_signed_url = make_s3_link_temporary( submission_data.get('workgroup'), submission_data['document_url'].split('/')[-2], submission_data['document_filename'], submission_data["document_url"]) return SubmissionUpload( document_signed_url, submission_data["document_filename"], format_date(build_date_field(submission_data["modified"])), submission_data.get("user_details", None))
def test_build_date_field(self, json_string, expected): actual = build_date_field(json_string) self.assertEqual(actual, expected)