netcop-ai/workflows/models.py
thecyberlearn 060c3a9c78 Initial commit: Django web app with user auth, Stripe payments, and n8n workflow integration
Features:
- Email-based user authentication with token auth
- Stripe Checkout integration for wallet top-ups
- n8n workflow triggering with automatic fee deduction ($0.10)
- Comprehensive transaction and usage logging
- Django Admin interface for monitoring
- Rate limiting and security middleware
- Production-ready deployment configuration
- Modular settings (dev/prod environments)
- UUID primary keys for enhanced security
- Comprehensive test coverage

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-30 13:34:19 +05:30

31 lines
1.2 KiB
Python

import uuid
from django.db import models
from django.conf import settings
from decimal import Decimal
class WorkflowUsage(models.Model):
STATUS_CHOICES = [
('pending', 'Pending'),
('success', 'Success'),
('failed', 'Failed'),
]
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='workflow_usage')
workflow_name = models.CharField(max_length=255)
workflow_url = models.URLField()
fee_charged = models.DecimalField(max_digits=10, decimal_places=2, default=Decimal('0.10'))
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
request_data = models.JSONField(null=True, blank=True)
response_data = models.JSONField(null=True, blank=True)
error_message = models.TextField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
ordering = ['-created_at']
def __str__(self):
return f"{self.user.email} - {self.workflow_name} - ${self.fee_charged}"