Skip to content

Commit

Permalink
fix(project_management): if user not hav org specified dont attempt t…
Browse files Browse the repository at this point in the history
…o access

ref: #358
  • Loading branch information
jon-nfc committed Nov 7, 2024
1 parent 5de3bd3 commit a7c26f0
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions app/api/views/project_management/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a7c26f0

Please sign in to comment.