Skip to content

Commit

Permalink
Merge 22e083d into e9a380d
Browse files Browse the repository at this point in the history
  • Loading branch information
nad2000 committed Sep 12, 2019
2 parents e9a380d + 22e083d commit 12f0103
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
21 changes: 19 additions & 2 deletions orcid_hub/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()]


admin.add_view(UserAdmin(User))
Expand Down
13 changes: 13 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={task.id}")
file_name = f"resources_reimport.{export_type}"
resp = client.post(
"/load/task/RESOURCE",
data={"file_": (BytesIO(resp.data), file_name)},
follow_redirects=True)
assert resp.status_code == 200
assert b"SYN-18-UOA-001" in resp.data
assert b"invitee1@mailinator.com" in resp.data
t = Task.get(filename=file_name)
assert t.records.count() == 2

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

resp = client.post("/activate_all/?url=/resources", data=dict(task_id=task.id))
Expand Down

0 comments on commit 12f0103

Please sign in to comment.