From a1968edd216617786da41aa9d5fa3c6d45ef6508 Mon Sep 17 00:00:00 2001 From: sshugsc Date: Thu, 29 Jan 2026 12:27:54 -0800 Subject: [PATCH 1/2] checking for project membership before creating the report --- pori_python/ipr/connection.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pori_python/ipr/connection.py b/pori_python/ipr/connection.py index dca4687..cc126c4 100644 --- a/pori_python/ipr/connection.py +++ b/pori_python/ipr/connection.py @@ -107,6 +107,10 @@ def upload_report( projects = self.get("project") project_names = [item["name"] for item in projects] + project_users = { + item["name"]: [user["username"] for user in item.get("users", [])] + for item in projects + } # if project is not exist, create one if content["project"] not in project_names: @@ -118,6 +122,9 @@ def upload_report( except Exception as err: raise Exception(f"Project creation failed due to {err}") + if self.username not in project_users[content["project"]]: + raise Exception(f"User have no permission to create report in project {content['project']}") + if ignore_extra_fields: initial_result = self.post("reports-async?ignore_extra_fields=true", content) else: From be3add72f8502b74160e2bd5cecc22d0b1ab8bd1 Mon Sep 17 00:00:00 2001 From: sshugsc Date: Fri, 30 Jan 2026 12:01:43 -0800 Subject: [PATCH 2/2] lint --- pori_python/ipr/connection.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pori_python/ipr/connection.py b/pori_python/ipr/connection.py index cc126c4..1cfd260 100644 --- a/pori_python/ipr/connection.py +++ b/pori_python/ipr/connection.py @@ -123,8 +123,10 @@ def upload_report( raise Exception(f"Project creation failed due to {err}") if self.username not in project_users[content["project"]]: - raise Exception(f"User have no permission to create report in project {content['project']}") - + raise Exception( + f"User have no permission to create report in project {content['project']}" + ) + if ignore_extra_fields: initial_result = self.post("reports-async?ignore_extra_fields=true", content) else: