6
This commit is contained in:
@@ -10,11 +10,11 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
def validate_ids(payload: dict, max_items: Optional[int] = None) -> Dict[str, Any]:
|
||||
"""
|
||||
Base validation: checks for 'ids' array and max_items limit.
|
||||
Base validation: checks for 'ids' array.
|
||||
|
||||
Args:
|
||||
payload: Request payload containing 'ids' array
|
||||
max_items: Maximum number of items allowed (None = no limit)
|
||||
max_items: Maximum number of items allowed (deprecated - no longer enforced)
|
||||
|
||||
Returns:
|
||||
Dict with 'valid' (bool) and optional 'error' (str)
|
||||
@@ -23,8 +23,7 @@ def validate_ids(payload: dict, max_items: Optional[int] = None) -> Dict[str, An
|
||||
if not ids:
|
||||
return {'valid': False, 'error': 'No IDs provided'}
|
||||
|
||||
if max_items and len(ids) > max_items:
|
||||
return {'valid': False, 'error': f'Maximum {max_items} items allowed'}
|
||||
# Removed max_items limit check - no limits enforced
|
||||
|
||||
return {'valid': True}
|
||||
|
||||
@@ -55,46 +54,16 @@ def validate_keywords_exist(ids: list, account=None) -> Dict[str, Any]:
|
||||
def validate_cluster_limits(account, operation_type: str = 'cluster') -> Dict[str, Any]:
|
||||
"""
|
||||
Validate plan limits for cluster operations.
|
||||
DISABLED: All limits have been removed.
|
||||
|
||||
Args:
|
||||
account: Account object
|
||||
operation_type: Type of operation ('cluster', 'idea', etc.)
|
||||
|
||||
Returns:
|
||||
Dict with 'valid' (bool) and optional 'error' (str)
|
||||
Dict with 'valid' (bool) - always returns valid
|
||||
"""
|
||||
if not account:
|
||||
return {'valid': False, 'error': 'Account is required'}
|
||||
|
||||
plan = getattr(account, 'plan', None)
|
||||
if not plan:
|
||||
return {'valid': False, 'error': 'Account does not have an active plan'}
|
||||
|
||||
if operation_type == 'cluster':
|
||||
from igny8_core.modules.planner.models import Clusters
|
||||
|
||||
# Check daily cluster limit
|
||||
now = timezone.now()
|
||||
start_of_day = now.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
clusters_today = Clusters.objects.filter(
|
||||
account=account,
|
||||
created_at__gte=start_of_day
|
||||
).count()
|
||||
|
||||
if plan.daily_cluster_limit and clusters_today >= plan.daily_cluster_limit:
|
||||
return {
|
||||
'valid': False,
|
||||
'error': f'Daily cluster limit reached ({plan.daily_cluster_limit} clusters per day). Please try again tomorrow.'
|
||||
}
|
||||
|
||||
# Check max clusters limit
|
||||
total_clusters = Clusters.objects.filter(account=account).count()
|
||||
if plan.max_clusters and total_clusters >= plan.max_clusters:
|
||||
return {
|
||||
'valid': False,
|
||||
'error': f'Maximum cluster limit reached ({plan.max_clusters} clusters). Please upgrade your plan or delete existing clusters.'
|
||||
}
|
||||
|
||||
# All limits removed - always return valid
|
||||
return {'valid': True}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user