Skip to content
This repository has been archived by the owner on Mar 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #19 from intuitem/18-fresh-instance-creating-a-pro…
Browse files Browse the repository at this point in the history
…ject-results-in-error-500

18 fresh instance creating a project results in error 500
  • Loading branch information
eric-intuitem authored Nov 9, 2023
2 parents 653f518 + a08f908 commit 90707de
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
8 changes: 3 additions & 5 deletions core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,11 @@ class Meta:


class SecurityMeasureCreateForm(LinkCleanMixin, StyledModelForm):
folder = forms.ModelChoiceField(queryset=Folder.objects.filter(content_type=Folder.ContentType.DOMAIN))
def __init__(self, user=None, *args, **kwargs):
super().__init__(*args, **kwargs)
if user:
self.fields['folder'].queryset = Folder.objects.filter(id__in=RoleAssignment.get_accessible_folders(Folder.get_root_folder(), user, Folder.ContentType.DOMAIN, codename="add_securitymeasure"))
else:
self.fields['folder'].queryset = Folder.objects.filter(content_type=Folder.ContentType.DOMAIN)
self.fields['folder'].widget = SearchableSelect(attrs={'class': 'text-sm rounded',
'searchbar_class': '[&_.search-icon]:text-gray-500 text-sm px-3',
'wrapper_class': 'border border-gray-300 bg-gray-50 text-gray-900 text-sm rounded-b-lg focus:ring-blue-500 focus:border-blue-500 max-h-56 overflow-y-scroll'},
Expand Down Expand Up @@ -389,12 +388,11 @@ def clean(self):


class ProjectForm(StyledModelForm):
def __init__(self, user=None, *args, **kwargs):
folder = forms.ModelChoiceField(queryset=Folder.objects.filter(content_type=Folder.ContentType.DOMAIN))
def __init__(self, user=None, *args, **kwargs):
super(ProjectForm, self).__init__(*args, **kwargs)
if user:
self.fields['folder'].queryset = Folder.objects.filter(id__in=RoleAssignment.get_accessible_folders(Folder.get_root_folder(), user, Folder.ContentType.DOMAIN, codename="add_project"))
else:
self.fields['folder'].queryset = Folder.objects.filter(content_type=Folder.ContentType.DOMAIN)
self.fields['folder'].widget = SearchableSelect(attrs={'class': 'text-sm rounded',
'searchbar_class': '[&_.search-icon]:text-gray-500 text-sm px-3',
'wrapper_class': 'border border-gray-300 bg-gray-50 text-gray-900 text-sm rounded-b-lg focus:ring-blue-500 focus:border-blue-500 max-h-56 overflow-y-scroll'},
Expand Down
4 changes: 2 additions & 2 deletions core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,13 +889,13 @@ def test_func(self):
return RoleAssignment.is_access_allowed(user=self.request.user, perm=Permission.objects.get(codename='add_project'), folder=Folder.objects.get(id=self.request.POST['folder']))


class ProjectCreateViewModal(UserPassesTestMixin, CreateViewModal):
class ProjectCreateViewModal(CreateViewModal, UserPassesTestMixin):
model = Project
context_object_name = 'project'
form_class = ProjectForm

def test_func(self):
return RoleAssignment.is_access_allowed(user=self.request.user, perm=Permission.objects.get(codename='add_project'), folder=Folder.objects.get(id=self.request.POST['folder']))
return RoleAssignment.is_access_allowed(user=self.request.user, perm=Permission.objects.get(codename="add_project"), folder=Folder.objects.get(id=self.request.POST['folder']))


class ProjectUpdateView(BaseContextMixin, UserPassesTestMixin, UpdateView):
Expand Down
2 changes: 1 addition & 1 deletion mira/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.2b
3.0.2c

0 comments on commit 90707de

Please sign in to comment.