This commit is contained in:
zandercymatics 2024-08-22 08:33:03 -06:00
parent 76fef5303b
commit bef49a85c1
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 5 additions and 21 deletions

View file

@ -100,12 +100,12 @@ class UserPortfolioPermission(TimeStampedModel):
# Check if a user is set without accessing the related object.
has_user = bool(self.user_id)
# Have to create a bogus request to set the user and pass to flag_is_active
request = HttpRequest()
request.user = self.user
if not flag_is_active(request, "multiple_portfolios") and self.pk is None and has_user:
if self.pk is None and has_user:
# Have to create a bogus request to set the user and pass to flag_is_active
request = HttpRequest()
request.user = self.user
existing_permissions = UserPortfolioPermission.objects.filter(user=self.user)
if existing_permissions.exists():
if not flag_is_active(request, "multiple_portfolios") and existing_permissions.exists():
raise ValidationError(
"Only one portfolio permission is allowed per user when multiple portfolios are disabled."
)