Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Elwell <[email protected]>
  • Loading branch information
tushar5526 and matthewelwell authored Nov 16, 2023
1 parent 89adb29 commit c6879fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/projects/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def has_permission(self, request, view):
total_projects_created = Project.objects.filter(
organisation=organisation
).count()
if total_projects_created >= subscription_metadata.projects:
if subscription_metadata.projects and total_projects_created >= subscription_metadata.projects:
return False
if organisation.restrict_project_create_to_admin:
return request.user.is_organisation_admin(organisation.pk)
Expand Down
3 changes: 1 addition & 2 deletions api/projects/tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ def test_free_plan_has_only_fixed_projects_permission():
mock_request.user = user

for i in range(MAX_PROJECTS_IN_FREE_PLAN):
result = project_permissions.has_permission(mock_request, mock_view)
assert project_permissions.has_permission(mock_request, mock_view)
Project.objects.create(name=f"Test project{i}", organisation=organisation)
assert result

assert not project_permissions.has_permission(mock_request, mock_view)

0 comments on commit c6879fb

Please sign in to comment.