mirror of
https://github.com/thecyberlearn/quantum-ai-v2.git
synced 2026-08-18 13:12:58 +00:00
BREAKING CHANGES: - Move marketplace and agent discovery views from core to agent_base app - Transfer all wallet functionality from core to dedicated wallet app - Move Stripe webhook handling to wallet app for better organization - Consolidate payment system logic under single responsibility NEW STRUCTURE: - core app: Platform pages only (homepage, pricing) - agent_base app: Complete agent marketplace and catalog system - wallet app: Full payment system with Stripe integration - Individual agent apps: Unchanged, self-contained IMPROVEMENTS: - Clean URL namespacing (agent_base:marketplace, wallet:wallet) - Template organization by app responsibility - Removed deprecated CSS files (header.css) - Added utility classes (.hidden) - Updated all template references to new URL structure - Comprehensive CLAUDE.md documentation updates TECHNICAL CHANGES: - Templates moved: marketplace.html, agent_detail.html → agent_base/ - Templates moved: wallet*.html → wallet/ - New files: agent_base/views.py, agent_base/urls.py, wallet/urls.py - Updated main urls.py routing configuration - Fixed Django system checks and namespace conflicts - Verified all functionality with test suite This reorganization follows Django best practices with single responsibility principle, making the codebase more maintainable and scalable. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
75 lines
2.6 KiB
Python
75 lines
2.6 KiB
Python
from django.shortcuts import render, redirect, get_object_or_404
|
|
from django.contrib import messages
|
|
from django.http import JsonResponse
|
|
from django.db.models import Q
|
|
from .models import BaseAgent
|
|
|
|
|
|
def marketplace_view(request):
|
|
"""Professional marketplace view with agent system"""
|
|
# Get all agents for marketplace with optimized query
|
|
agents_queryset = BaseAgent.objects.filter(is_active=True).select_related().order_by('category', 'name')
|
|
|
|
# Filter by category if specified
|
|
category = request.GET.get('category')
|
|
if category:
|
|
agents_queryset = agents_queryset.filter(category=category)
|
|
|
|
# Get agents and categories in single query
|
|
agents = list(agents_queryset)
|
|
categories = BaseAgent.objects.filter(is_active=True).values_list('category', 'category').distinct()
|
|
|
|
context = {
|
|
'user_balance': request.user.wallet_balance if request.user.is_authenticated else 0,
|
|
'agents': agents,
|
|
'categories': categories,
|
|
'selected_category': category,
|
|
}
|
|
|
|
return render(request, 'agent_base/marketplace.html', context)
|
|
|
|
|
|
def agent_detail_view(request, agent_slug):
|
|
"""Agent detail view - redirect to specific agent app"""
|
|
try:
|
|
agent = BaseAgent.objects.get(slug=agent_slug, is_active=True)
|
|
# Redirect to the specific agent app URL
|
|
if agent_slug == 'weather-reporter':
|
|
return redirect('/agents/weather-reporter/')
|
|
else:
|
|
# For other agents, redirect to marketplace for now
|
|
messages.info(request, f'Agent "{agent.name}" page not yet available.')
|
|
return redirect('agent_base:marketplace')
|
|
except BaseAgent.DoesNotExist:
|
|
messages.error(request, 'Agent not found')
|
|
return redirect('agent_base:marketplace')
|
|
|
|
|
|
def agents_api_view(request):
|
|
"""API endpoint for agents list"""
|
|
agents = BaseAgent.objects.filter(is_active=True)
|
|
|
|
# Filter by category if specified
|
|
category = request.GET.get('category')
|
|
if category:
|
|
agents = agents.filter(category=category)
|
|
|
|
agents_data = []
|
|
for agent in agents:
|
|
agents_data.append({
|
|
'id': str(agent.id),
|
|
'name': agent.name,
|
|
'slug': agent.slug,
|
|
'description': agent.description,
|
|
'category': agent.category,
|
|
'price': float(agent.price),
|
|
'icon': agent.icon,
|
|
'rating': float(agent.rating),
|
|
'review_count': agent.review_count,
|
|
'agent_type': agent.agent_type,
|
|
})
|
|
|
|
return JsonResponse({
|
|
'agents': agents_data,
|
|
'total_count': len(agents_data),
|
|
}) |