from django.db import models
from django.contrib.auth.models import User
from django.utils import timezone

# Create your models here.
class Task(models.Model):
    # Category choices (like dropdown options)
    CATEGORY_CHOICES = [
        ('work', 'Work'),
        ('personal', 'Personal'),
        ('study', 'Study'),
    ]
    
    # Priority choices
    PRIORITY_CHOICES = [
        ('high', 'High 🔴'),
        ('medium', 'Medium 🟡'),
        ('low', 'Low 🟢'),
    ]
    
    # Task fields (columns in database)
    user = models.ForeignKey(User, on_delete=models.CASCADE)  # Which user owns this task
    title = models.CharField(max_length=200)  # Task title (short text)
    description = models.TextField(blank=True)  # Task details (long text, can be empty)
    category = models.CharField(max_length=20, choices=CATEGORY_CHOICES, default='personal')
    priority = models.CharField(max_length=10, choices=PRIORITY_CHOICES, default='medium')
    due_date = models.DateField()
    is_completed = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)  # Auto-set when created
    
    def __str__(self):
        return self.title