from django.db import models from django.utils import timezone from django.contrib.auth.models import User class Brand(models.Model): name = models.CharField(max_length=255) website = models.URLField(max_length=200, blank=True) logo_url = models.URLField(max_length=200, blank=True, verbose_name="Logo URL") created_at = models.DateTimeField(auto_now_add=True) users = models.ManyToManyField(User, related_name='brands') def __str__(self): return self.name class Meta: ordering = ['name'] class Incident(models.Model): STATUS_CHOICES = [ ('new', 'New'), ('in_review', 'In Review'), ('resolved', 'Resolved'), ('dismissed', 'Dismissed'), ] INCIDENT_TYPE_CHOICES = [ ('social_impersonation', 'Social Media Impersonation'), ('negative_review', 'Negative Review'), ('domain_squatting', 'Domain Squatting'), ('phishing_attack', 'Phishing Attack'), ('other', 'Other'), ] brand = models.ForeignKey(Brand, on_delete=models.CASCADE, related_name='incidents') incident_type = models.CharField(max_length=50, choices=INCIDENT_TYPE_CHOICES) source_url = models.URLField(max_length=500) content = models.TextField(help_text="Detailed description or content of the incident (e.g., text of the post, screenshot description).") status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='new') reported_at = models.DateTimeField(default=timezone.now) def __str__(self): return f"{self.get_incident_type_display()} for {self.brand.name} at {self.reported_at.strftime('%Y-%m-%d')}" class Meta: ordering = ['-reported_at']