Skip to content

Commit

Permalink
Merge pull request #10 from oarepo/krist/post-communities-merge-fixes
Browse files Browse the repository at this point in the history
get_workflow crashing on community record fix
  • Loading branch information
mesemus authored Aug 15, 2024
2 parents f058970 + d353acf commit 9e3a159
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions oarepo_workflows/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,20 @@ def get_workflow_from_record(self, record, **kwargs):
def record_workflows(self):
return self.app.config["WORKFLOWS"]

def _get_id_from_record(self, record):
# community record doesn't have id in dict form, only uuid
return record["id"] if "id" in record else record.id

def get_workflow(self, record):
try:
return self.record_workflows[record.parent.workflow]
except AttributeError:
raise MissingWorkflowError(f"Workflow not found on record {record['id']}.")
raise MissingWorkflowError(
f"Workflow not found on record {self._get_id_from_record(record)}."
)
except KeyError:
raise InvalidWorkflowError(
f"Workflow {record.parent.workflow} on record {record['id']} doesn't exist."
f"Workflow {record.parent.workflow} on record {self._get_id_from_record(record)} doesn't exist."
)

def init_app(self, app):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-workflows
version = 1.0.6
version = 1.0.7
description =
authors = Ronald Krist <[email protected]>
readme = README.md
Expand Down

0 comments on commit 9e3a159

Please sign in to comment.