mirror of
https://github.com/thecyberlearn/quantumtaskai-caprover.git
synced 2026-08-18 08:52:57 +00:00
Fix django-ratelimit imports in all view files
- Comment out django-ratelimit imports and decorators in: - wallet/views.py - agents/api_views.py - agents/chat_views.py - core/views.py - This resolves ModuleNotFoundError preventing Django startup - Temporary fix until Docker dependency caching issue is resolved 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9ee78fc770
commit
cb638d3b6f
@ -11,7 +11,7 @@ from rest_framework.pagination import PageNumberPagination
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils import timezone
|
||||
from django.core.exceptions import ValidationError
|
||||
from django_ratelimit.decorators import ratelimit
|
||||
# from django_ratelimit.decorators import ratelimit
|
||||
from .models import AgentExecution
|
||||
from .serializers import AgentExecutionSerializer
|
||||
from .services import AgentFileService
|
||||
@ -29,7 +29,7 @@ logger = logging.getLogger('agents.api')
|
||||
|
||||
@api_view(['POST'])
|
||||
@permission_classes([IsAuthenticated])
|
||||
@ratelimit(key='user', rate='10/m', method='POST', block=True)
|
||||
# @ratelimit(key='user', rate='10/m', method='POST', block=True)
|
||||
def execute_agent(request):
|
||||
"""Execute an agent with provided input data"""
|
||||
try:
|
||||
@ -264,7 +264,7 @@ def execute_agent(request):
|
||||
|
||||
@api_view(['GET'])
|
||||
@permission_classes([IsAuthenticated])
|
||||
@ratelimit(key='user', rate='30/m', method='GET', block=True)
|
||||
# @ratelimit(key='user', rate='30/m', method='GET', block=True)
|
||||
def execution_list(request):
|
||||
"""List user's agent executions with optimized queries"""
|
||||
executions = AgentExecution.objects.filter(user=request.user).select_related('user').order_by('-created_at')
|
||||
@ -288,7 +288,7 @@ def execution_list(request):
|
||||
|
||||
@api_view(['GET'])
|
||||
@permission_classes([IsAuthenticated])
|
||||
@ratelimit(key='user', rate='60/m', method='GET', block=True)
|
||||
# @ratelimit(key='user', rate='60/m', method='GET', block=True)
|
||||
def execution_detail(request, execution_id):
|
||||
"""Get detailed execution information"""
|
||||
execution = get_object_or_404(AgentExecution, id=execution_id, user=request.user)
|
||||
|
||||
@ -12,7 +12,7 @@ from django.utils import timezone
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import HttpResponse
|
||||
from django.core.exceptions import ValidationError
|
||||
from django_ratelimit.decorators import ratelimit
|
||||
# from django_ratelimit.decorators import ratelimit
|
||||
from reportlab.pdfgen import canvas
|
||||
from reportlab.lib.pagesizes import letter
|
||||
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
||||
@ -33,7 +33,7 @@ logger = logging.getLogger('agents.chat')
|
||||
|
||||
@api_view(['POST'])
|
||||
@permission_classes([IsAuthenticated])
|
||||
@ratelimit(key='user', rate='5/m', method='POST', block=True)
|
||||
# @ratelimit(key='user', rate='5/m', method='POST', block=True)
|
||||
def start_chat_session(request):
|
||||
"""Start a new chat session"""
|
||||
try:
|
||||
@ -139,7 +139,7 @@ Let's discover the root cause together! 💪"""
|
||||
|
||||
@api_view(['POST'])
|
||||
@permission_classes([IsAuthenticated])
|
||||
@ratelimit(key='user', rate='20/m', method='POST', block=True)
|
||||
# @ratelimit(key='user', rate='20/m', method='POST', block=True)
|
||||
def send_chat_message(request):
|
||||
"""Send a message in a chat session"""
|
||||
try:
|
||||
|
||||
@ -4,8 +4,8 @@ from django.contrib import messages
|
||||
from django.http import JsonResponse, Http404
|
||||
from django.core.mail import send_mail
|
||||
from django.conf import settings
|
||||
from django_ratelimit.decorators import ratelimit
|
||||
from django_ratelimit import UNSAFE
|
||||
# from django_ratelimit.decorators import ratelimit
|
||||
# from django_ratelimit import UNSAFE
|
||||
from agents.services import AgentFileService
|
||||
from .models import ContactSubmission
|
||||
from django.db import connection
|
||||
@ -14,7 +14,7 @@ import re
|
||||
import time
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ratelimit(key='ip', rate='60/m', method='GET', block=False)
|
||||
# @ratelimit(key='ip', rate='60/m', method='GET', block=False)
|
||||
def homepage_view(request):
|
||||
"""Homepage view with agent system and rate limiting"""
|
||||
# Check if rate limited
|
||||
@ -38,14 +38,14 @@ def homepage_view(request):
|
||||
logger.error(f"Homepage view error: {e}")
|
||||
messages.error(request, 'Unable to load homepage. Please try again.')
|
||||
return render(request, 'core/homepage.html', {'featured_agents': [], 'user_balance': 0})
|
||||
@ratelimit(key='ip', rate='60/m', method='GET', block=False)
|
||||
# @ratelimit(key='ip', rate='60/m', method='GET', block=False)
|
||||
def pricing_view(request):
|
||||
"""Pricing page - redirect to marketplace"""
|
||||
# Redirect all pricing page access to the AI marketplace
|
||||
return redirect('agents:marketplace')
|
||||
|
||||
|
||||
@ratelimit(key='ip', rate='60/m', method='GET', block=False)
|
||||
# @ratelimit(key='ip', rate='60/m', method='GET', block=False)
|
||||
def digital_branding_view(request):
|
||||
"""Digital branding services page with rate limiting"""
|
||||
# Check if rate limited
|
||||
@ -140,7 +140,7 @@ This is an automated notification from Quantum Tasks AI contact form.
|
||||
return False
|
||||
|
||||
|
||||
@ratelimit(key='ip', rate='3/m', method='POST', block=False)
|
||||
# @ratelimit(key='ip', rate='3/m', method='POST', block=False)
|
||||
def contact_form_view(request):
|
||||
"""Handle contact form submission with security and rate limiting"""
|
||||
if request.method != 'POST':
|
||||
@ -215,7 +215,7 @@ def contact_form_view(request):
|
||||
}, status=500)
|
||||
|
||||
|
||||
@ratelimit(key='ip', rate='60/m', method='GET', block=False)
|
||||
# @ratelimit(key='ip', rate='60/m', method='GET', block=False)
|
||||
def health_check_view(request):
|
||||
"""Simplified health check endpoint - no database dependency for startup"""
|
||||
start_time = time.time()
|
||||
@ -323,7 +323,7 @@ EXTERNAL_PAGES = {
|
||||
}
|
||||
|
||||
|
||||
@ratelimit(key='ip', rate='30/m', method='GET', block=False)
|
||||
# @ratelimit(key='ip', rate='30/m', method='GET', block=False)
|
||||
def external_page_view(request, page_name):
|
||||
"""
|
||||
Simple external service wrapper view.
|
||||
|
||||
@ -4,8 +4,8 @@ from django.contrib import messages
|
||||
from django.http import JsonResponse
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.decorators.http import require_http_methods
|
||||
from django_ratelimit.decorators import ratelimit
|
||||
from django_ratelimit import UNSAFE
|
||||
# from django_ratelimit.decorators import ratelimit
|
||||
# from django_ratelimit import UNSAFE
|
||||
from .stripe_handler import StripePaymentHandler
|
||||
import datetime
|
||||
import stripe
|
||||
@ -60,7 +60,7 @@ def wallet_view(request):
|
||||
|
||||
|
||||
@login_required
|
||||
@ratelimit(key='user', rate='5/m', method=UNSAFE, block=False)
|
||||
# @ratelimit(key='user', rate='5/m', method=UNSAFE, block=False)
|
||||
def wallet_topup_view(request):
|
||||
"""Wallet top-up page with rate limiting (5 attempts per minute per user)"""
|
||||
# Check if rate limited
|
||||
@ -98,7 +98,7 @@ def wallet_topup_view(request):
|
||||
return render(request, 'wallet/wallet_topup.html')
|
||||
|
||||
|
||||
@ratelimit(key='user', rate='10/m', method='GET', block=False)
|
||||
# @ratelimit(key='user', rate='10/m', method='GET', block=False)
|
||||
def wallet_topup_success_view(request):
|
||||
"""Payment success page with automatic payment verification"""
|
||||
# Check authentication first and clear any messages if redirecting to login
|
||||
@ -161,7 +161,7 @@ def wallet_topup_cancel_view(request):
|
||||
|
||||
@login_required
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
@ratelimit(key='user', rate='3/m', method='GET', block=True)
|
||||
# @ratelimit(key='user', rate='3/m', method='GET', block=True)
|
||||
def stripe_debug_view(request):
|
||||
"""Secure debug endpoint for superusers only"""
|
||||
if not request.user.is_superuser:
|
||||
@ -216,7 +216,7 @@ def is_stripe_ip(ip_address):
|
||||
|
||||
@csrf_exempt
|
||||
@require_http_methods(["POST"])
|
||||
@ratelimit(key='ip', rate='50/m', method='POST', block=True)
|
||||
# @ratelimit(key='ip', rate='50/m', method='POST', block=True)
|
||||
def stripe_webhook_view(request):
|
||||
"""Secure Stripe webhook handler with IP validation and rate limiting"""
|
||||
timestamp = datetime.datetime.now().isoformat()
|
||||
@ -264,7 +264,7 @@ def stripe_webhook_view(request):
|
||||
|
||||
@login_required
|
||||
@require_http_methods(["POST"])
|
||||
@ratelimit(key='user', rate='10/m', method='POST', block=False)
|
||||
# @ratelimit(key='user', rate='10/m', method='POST', block=False)
|
||||
def wallet_deduct_api(request):
|
||||
"""API endpoint for wallet balance deduction (for direct N8N integration)"""
|
||||
# Check if rate limited
|
||||
|
||||
Loading…
Reference in New Issue
Block a user