From a7c26f09c14a2dfcc332e840dc146f1683a5931d Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 23 Oct 2024 14:09:41 +0930 Subject: [PATCH] fix(project_management): if user not hav org specified dont attempt to access ref: #358 --- app/api/views/project_management/projects.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/api/views/project_management/projects.py b/app/api/views/project_management/projects.py index 39bf86c9e..54d697aef 100644 --- a/app/api/views/project_management/projects.py +++ b/app/api/views/project_management/projects.py @@ -39,12 +39,18 @@ class View(OrganizationMixin, viewsets.ModelViewSet): def get_serializer_class(self): - if self.has_organization_permission( - organization = UserSettings.objects.get(user = self.request.user).default_organization.id, - permissions_required = ['project_management.import_project'] - ) or self.request.user.is_superuser: + user_default_organization = UserSettings.objects.get(user = self.request.user).default_organization - return ProjectImportSerializer + if user_default_organization: + + if hasattr(user_default_organization, 'default_organization'): + + if self.has_organization_permission( + organization = user_default_organization.default_organization.id, + permissions_required = ['project_management.import_project'] + ) or self.request.user.is_superuser: + + return ProjectImportSerializer return ProjectSerializer