From ba13c46555ee768558a9163735c4a61255c49cd1 Mon Sep 17 00:00:00 2001 From: Jad Date: Mon, 17 Jun 2024 13:10:10 -0700 Subject: [PATCH] Fix unable to reactivate deactivated works --- epictrack-api/src/api/resources/work_issues.py | 2 +- epictrack-api/src/api/services/work_issues.py | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/epictrack-api/src/api/resources/work_issues.py b/epictrack-api/src/api/resources/work_issues.py index 8387c7468..714e8de49 100644 --- a/epictrack-api/src/api/resources/work_issues.py +++ b/epictrack-api/src/api/resources/work_issues.py @@ -95,7 +95,7 @@ class EditIssues(Resource): def patch(work_id, issue_id, update_id): """Approve a work status.""" request_dict = req.WorkIssuesUpdateEditSchema().load(API.payload) - edited_issue_update = WorkIssuesService.edit_issue_update(work_id, issue_id, update_id, request_dict) + edited_issue_update = WorkIssuesService.edit_issue_update(issue_id, update_id, request_dict) return res.WorkIssueUpdatesResponseSchema().dump(edited_issue_update), HTTPStatus.OK diff --git a/epictrack-api/src/api/services/work_issues.py b/epictrack-api/src/api/services/work_issues.py index f6e29239e..0a4190ec9 100644 --- a/epictrack-api/src/api/services/work_issues.py +++ b/epictrack-api/src/api/services/work_issues.py @@ -35,10 +35,9 @@ def find_all_work_issues(cls, work_id): return work_issues @classmethod - def find_work_issue_by_id(cls, work_id, issue_id): + def find_work_issue_by_id(cls, issue_id): """Find all status related to a work""" - results = WorkIssuesModel.find_by_params({"work_id": work_id, "id": issue_id}) - return results[0] if results else None + return WorkIssuesModel.find_by_id(issue_id) @classmethod def find_work_issues_by_work_ids(cls, work_ids): @@ -132,7 +131,7 @@ def _check_valid_issue_edit_data(cls, new_data, work_issue_db): @classmethod def edit_issue(cls, work_id, issue_id, issue_data): """Edit an existing work issue, and save it only if there are changes.""" - work_issue = WorkIssuesService.find_work_issue_by_id(work_id, issue_id) + work_issue = WorkIssuesService.find_work_issue_by_id(issue_id) if not work_issue: raise ResourceNotFoundError("Work issue doesnt exist") @@ -160,9 +159,9 @@ def _check_edit_auth(cls, work_id): authorisation.check_auth(one_of_roles=one_of_roles, work_id=work_id) @classmethod - def edit_issue_update(cls, work_id, issue_id, issue_update_id, issue_update_data): + def edit_issue_update(cls, issue_id, issue_update_id, issue_update_data): """Edit an existing work issue update.""" - work_issue = WorkIssuesService.find_work_issue_by_id(work_id, issue_id) + work_issue = WorkIssuesService.find_work_issue_by_id(issue_id) if not work_issue: raise ResourceNotFoundError("Work issue doesnt exist")