from django.db import models
from .user import CustomUser
from .tag import Tag

class Source(models.Model):
    title = models.CharField(max_length=200)
    url = models.URLField()
    archived_url = models.URLField()
    description = models.TextField()
    category = models.CharField(max_length=50)
    tags = models.ManyToManyField(Tag, related_name='sources')
    added_by = models.ForeignKey(CustomUser, on_delete=models.SET_NULL, null=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __str__(self):
        return self.title