Skip to content
Browse files

implemented export to tsv and csv

  • Loading branch information...
nad2000 committed Sep 12, 2019
1 parent e9a380d commit 22e083d82a2b615fe4b3fbe0936164c650264c2a
Showing with 32 additions and 2 deletions.
  1. +19 −2 orcid_hub/
  2. +13 −0 tests/
@@ -2045,9 +2045,26 @@ class ResourceRecordAdmin(RecordModelView):
], "Resource"),

export_column_headers = dict(
name="Resource Name",
type="Resource Type",
start_date="Resource Start date",
end_date="Resource End date",
url="Resource URL",
host_name="Resource Host Name",
host_city="Resource Host City",
host_region="Resource Host Region",
host_country="Resource Host Country",
host_disambiguated_id="Resource Host Disambiguated ID",
host_disambiguation_source="Resource Host Disambiguation Source",
external_id_type="Resource External ID Type",
external_id_value="Resource External Id Value",
external_id_url="Resource External ID URL",
external_id_relationship="Resource External ID Relationship")

def get_export_columns(self):
"""Create a list of exported columns with lables."""
return [(c, self.model._meta.fields[c].help_text or n) for c, n in super().get_export_columns()]
"""Create a list of exported columns with labels."""
return [(c, self.export_column_headers.get(c, n)) for c, n in super().get_export_columns()]

@@ -4487,6 +4487,19 @@ def test_research_resources(client, mocker):
task = Task.get(filename="resources.tsv")
assert task.records.count() == 2

for export_type in ["csv", "tsv"]:
resp = client.get(f"/admin/resourcerecord/export/{export_type}/?task_id={}")
file_name = f"resources_reimport.{export_type}"
resp =
data={"file_": (BytesIO(, file_name)},
assert resp.status_code == 200
assert b"SYN-18-UOA-001" in
assert b"" in
t = Task.get(filename=file_name)
assert t.records.count() == 2

send = mocker.patch("emails.message.MessageSendMixin.send")

resp ="/activate_all/?url=/resources", data=dict(

0 comments on commit 22e083d

Please sign in to comment.
You can’t perform that action at this time.