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:
thecyberlearn 2025-09-05 08:40:13 +05:30
parent 9ee78fc770
commit cb638d3b6f
4 changed files with 22 additions and 22 deletions

View File

@ -11,7 +11,7 @@ from rest_framework.pagination import PageNumberPagination
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.utils import timezone from django.utils import timezone
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django_ratelimit.decorators import ratelimit # from django_ratelimit.decorators import ratelimit
from .models import AgentExecution from .models import AgentExecution
from .serializers import AgentExecutionSerializer from .serializers import AgentExecutionSerializer
from .services import AgentFileService from .services import AgentFileService
@ -29,7 +29,7 @@ logger = logging.getLogger('agents.api')
@api_view(['POST']) @api_view(['POST'])
@permission_classes([IsAuthenticated]) @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): def execute_agent(request):
"""Execute an agent with provided input data""" """Execute an agent with provided input data"""
try: try:
@ -264,7 +264,7 @@ def execute_agent(request):
@api_view(['GET']) @api_view(['GET'])
@permission_classes([IsAuthenticated]) @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): def execution_list(request):
"""List user's agent executions with optimized queries""" """List user's agent executions with optimized queries"""
executions = AgentExecution.objects.filter(user=request.user).select_related('user').order_by('-created_at') 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']) @api_view(['GET'])
@permission_classes([IsAuthenticated]) @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): def execution_detail(request, execution_id):
"""Get detailed execution information""" """Get detailed execution information"""
execution = get_object_or_404(AgentExecution, id=execution_id, user=request.user) execution = get_object_or_404(AgentExecution, id=execution_id, user=request.user)

View File

@ -12,7 +12,7 @@ from django.utils import timezone
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.http import HttpResponse from django.http import HttpResponse
from django.core.exceptions import ValidationError 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.pdfgen import canvas
from reportlab.lib.pagesizes import letter from reportlab.lib.pagesizes import letter
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
@ -33,7 +33,7 @@ logger = logging.getLogger('agents.chat')
@api_view(['POST']) @api_view(['POST'])
@permission_classes([IsAuthenticated]) @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): def start_chat_session(request):
"""Start a new chat session""" """Start a new chat session"""
try: try:
@ -139,7 +139,7 @@ Let's discover the root cause together! 💪"""
@api_view(['POST']) @api_view(['POST'])
@permission_classes([IsAuthenticated]) @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): def send_chat_message(request):
"""Send a message in a chat session""" """Send a message in a chat session"""
try: try:

View File

@ -4,8 +4,8 @@ from django.contrib import messages
from django.http import JsonResponse, Http404 from django.http import JsonResponse, Http404
from django.core.mail import send_mail from django.core.mail import send_mail
from django.conf import settings from django.conf import settings
from django_ratelimit.decorators import ratelimit # from django_ratelimit.decorators import ratelimit
from django_ratelimit import UNSAFE # from django_ratelimit import UNSAFE
from agents.services import AgentFileService from agents.services import AgentFileService
from .models import ContactSubmission from .models import ContactSubmission
from django.db import connection from django.db import connection
@ -14,7 +14,7 @@ import re
import time import time
logger = logging.getLogger(__name__) 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): def homepage_view(request):
"""Homepage view with agent system and rate limiting""" """Homepage view with agent system and rate limiting"""
# Check if rate limited # Check if rate limited
@ -38,14 +38,14 @@ def homepage_view(request):
logger.error(f"Homepage view error: {e}") logger.error(f"Homepage view error: {e}")
messages.error(request, 'Unable to load homepage. Please try again.') messages.error(request, 'Unable to load homepage. Please try again.')
return render(request, 'core/homepage.html', {'featured_agents': [], 'user_balance': 0}) 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): def pricing_view(request):
"""Pricing page - redirect to marketplace""" """Pricing page - redirect to marketplace"""
# Redirect all pricing page access to the AI marketplace # Redirect all pricing page access to the AI marketplace
return redirect('agents: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): def digital_branding_view(request):
"""Digital branding services page with rate limiting""" """Digital branding services page with rate limiting"""
# Check if rate limited # Check if rate limited
@ -140,7 +140,7 @@ This is an automated notification from Quantum Tasks AI contact form.
return False 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): def contact_form_view(request):
"""Handle contact form submission with security and rate limiting""" """Handle contact form submission with security and rate limiting"""
if request.method != 'POST': if request.method != 'POST':
@ -215,7 +215,7 @@ def contact_form_view(request):
}, status=500) }, 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): def health_check_view(request):
"""Simplified health check endpoint - no database dependency for startup""" """Simplified health check endpoint - no database dependency for startup"""
start_time = time.time() 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): def external_page_view(request, page_name):
""" """
Simple external service wrapper view. Simple external service wrapper view.

View File

@ -4,8 +4,8 @@ from django.contrib import messages
from django.http import JsonResponse from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_http_methods from django.views.decorators.http import require_http_methods
from django_ratelimit.decorators import ratelimit # from django_ratelimit.decorators import ratelimit
from django_ratelimit import UNSAFE # from django_ratelimit import UNSAFE
from .stripe_handler import StripePaymentHandler from .stripe_handler import StripePaymentHandler
import datetime import datetime
import stripe import stripe
@ -60,7 +60,7 @@ def wallet_view(request):
@login_required @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): def wallet_topup_view(request):
"""Wallet top-up page with rate limiting (5 attempts per minute per user)""" """Wallet top-up page with rate limiting (5 attempts per minute per user)"""
# Check if rate limited # Check if rate limited
@ -98,7 +98,7 @@ def wallet_topup_view(request):
return render(request, 'wallet/wallet_topup.html') 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): def wallet_topup_success_view(request):
"""Payment success page with automatic payment verification""" """Payment success page with automatic payment verification"""
# Check authentication first and clear any messages if redirecting to login # Check authentication first and clear any messages if redirecting to login
@ -161,7 +161,7 @@ def wallet_topup_cancel_view(request):
@login_required @login_required
@user_passes_test(lambda u: u.is_superuser) @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): def stripe_debug_view(request):
"""Secure debug endpoint for superusers only""" """Secure debug endpoint for superusers only"""
if not request.user.is_superuser: if not request.user.is_superuser:
@ -216,7 +216,7 @@ def is_stripe_ip(ip_address):
@csrf_exempt @csrf_exempt
@require_http_methods(["POST"]) @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): def stripe_webhook_view(request):
"""Secure Stripe webhook handler with IP validation and rate limiting""" """Secure Stripe webhook handler with IP validation and rate limiting"""
timestamp = datetime.datetime.now().isoformat() timestamp = datetime.datetime.now().isoformat()
@ -264,7 +264,7 @@ def stripe_webhook_view(request):
@login_required @login_required
@require_http_methods(["POST"]) @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): def wallet_deduct_api(request):
"""API endpoint for wallet balance deduction (for direct N8N integration)""" """API endpoint for wallet balance deduction (for direct N8N integration)"""
# Check if rate limited # Check if rate limited