Skip to content

Commit

Permalink
Merge pull request #18130 from davelopez/24.0_fix_invenio_record_miss…
Browse files Browse the repository at this point in the history
…ing_title

[24.0] Fix listing possibly untitled records in Invenio Plugin
  • Loading branch information
bgruening authored May 13, 2024
2 parents 1552e06 + 299b607 commit fa3ef46
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/galaxy/files/sources/invenio.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def _create_entry(
record = self.repository.create_draft_record(entry_data["name"], public_name, user_context=user_context)
return {
"uri": self.repository.to_plugin_uri(record["id"]),
"name": record["metadata"]["title"],
"name": record["title"],
"external_link": record["links"]["self_html"],
}

Expand Down Expand Up @@ -225,6 +225,7 @@ def create_draft_record(
response = requests.post(self.records_url, json=create_record_request, headers=headers)
self._ensure_response_has_expected_status_code(response, 201)
record = response.json()
record["title"] = self._get_record_title(record)
return record

def upload_file_to_draft_record(
Expand Down Expand Up @@ -331,16 +332,23 @@ def _get_records_from_response(self, response: dict) -> List[RemoteDirectory]:
for record in records:
uri = self.to_plugin_uri(record_id=record["id"])
path = self.plugin.to_relative_path(uri)
name = self._get_record_title(record)
rval.append(
{
"class": "Directory",
"name": record["metadata"]["title"],
"name": name,
"uri": uri,
"path": path,
}
)
return rval

def _get_record_title(self, record: InvenioRecord) -> str:
title = record.get("title")
if not title and "metadata" in record:
title = record["metadata"].get("title")
return title or "No title"

def _get_record_files_from_response(self, record_id: str, response: dict) -> List[RemoteFile]:
files_enabled = response.get("enabled", False)
if not files_enabled:
Expand Down

0 comments on commit fa3ef46

Please sign in to comment.