def get_saved_exports(self): exports = FormExportSchema.get_stale_exports(self.domain) new_exports = get_form_export_instances(self.domain) exports += new_exports if not self.has_deid_view_permissions: exports = filter(lambda x: not x.is_safe, exports) return sorted(exports, key=lambda x: x.name)
def test_commit_form_export(self): export_post_data = json.dumps({ "doc_type": "FormExportInstance", "domain": self.domain.name, "xmlns": "http://openrosa.org/formdesigner/237B85C0-78B1-4034-8277-5D37E3EA7FD1", "last_updated": None, "legacy_saved_export_schema_id": None, "is_daily_saved_export": False, "tables": [], "transform_dates": True, "last_accessed": None, "app_id": "6a48b8838d06febeeabb28c8c9516ab6", "is_deidentified": False, "split_multiselects": False, "external_blobs": {}, "export_format": "csv", "include_errors": False, "type": "form", "name": "A Villager's Health > Registrationaa > Reg form: 2016-06-27" }) resp = self.client.post(reverse(CreateNewCustomFormExportView.urlname, args=[self.domain.name]), export_post_data, content_type="application/json", follow=True) self.assertEqual(resp.status_code, 200) exports = get_form_export_instances(self.domain.name) self.assertEqual(len(exports), 1) export = exports[0] resp = self.client.post( reverse(EditNewCustomFormExportView.urlname, args=[self.domain.name, export._id]), export_post_data, content_type="application/json", ) self.assertEqual(resp.status_code, 200)
def test_commit_form_export(self): export_post_data = json.dumps({ "doc_type": "FormExportInstance", "domain": self.domain.name, "xmlns": "http://openrosa.org/formdesigner/237B85C0-78B1-4034-8277-5D37E3EA7FD1", "last_updated": None, "legacy_saved_export_schema_id": None, "is_daily_saved_export": False, "tables": [], "transform_dates": True, "last_accessed": None, "app_id": "6a48b8838d06febeeabb28c8c9516ab6", "is_deidentified": False, "split_multiselects": False, "external_blobs": {}, "export_format": "csv", "include_errors": False, "type": "form", "name": "A Villager's Health > Registrationaa > Reg form: 2016-06-27" }) resp = self.client.post( reverse(CreateNewCustomFormExportView.urlname, args=[self.domain.name]), export_post_data, content_type="application/json", follow=True ) self.assertEqual(resp.status_code, 200) exports = get_form_export_instances(self.domain.name) self.assertEqual(len(exports), 1) export = exports[0] resp = self.client.post( reverse( EditNewCustomFormExportView.urlname, args=[self.domain.name, export._id] ), export_post_data, content_type="application/json", ) self.assertEqual(resp.status_code, 200)
def test_get_form_export_instances(self): instances = get_form_export_instances(self.domain) self.assertEqual(len(instances), 1)