adsasdasd
This commit is contained in:
@@ -135,6 +135,7 @@ def validate_account_and_plan(user_or_account):
|
||||
"""
|
||||
Validate account exists and has active plan.
|
||||
Allows trial, active, and pending_payment statuses.
|
||||
Bypasses validation for superusers, developers, and system accounts.
|
||||
|
||||
Args:
|
||||
user_or_account: User or Account instance
|
||||
@@ -145,6 +146,22 @@ def validate_account_and_plan(user_or_account):
|
||||
from rest_framework import status
|
||||
from .models import User, Account
|
||||
|
||||
# Bypass validation for superusers
|
||||
if isinstance(user_or_account, User):
|
||||
if getattr(user_or_account, 'is_superuser', False):
|
||||
return (True, None, None)
|
||||
|
||||
# Bypass validation for developers
|
||||
if hasattr(user_or_account, 'role') and user_or_account.role == 'developer':
|
||||
return (True, None, None)
|
||||
|
||||
# Bypass validation for system account users
|
||||
try:
|
||||
if hasattr(user_or_account, 'is_system_account_user') and user_or_account.is_system_account_user():
|
||||
return (True, None, None)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Extract account from user or use directly
|
||||
if isinstance(user_or_account, User):
|
||||
try:
|
||||
@@ -153,6 +170,12 @@ def validate_account_and_plan(user_or_account):
|
||||
account = None
|
||||
elif isinstance(user_or_account, Account):
|
||||
account = user_or_account
|
||||
# Check if account is a system account
|
||||
try:
|
||||
if hasattr(account, 'is_system_account') and account.is_system_account():
|
||||
return (True, None, None)
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
return (False, 'Invalid object type', status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user