from django.db import models
from django.utils import timezone

class Achievement(models.Model):
    title = models.CharField(max_length=200)
    student_name = models.CharField(max_length=100)
    event_name = models.CharField(max_length=200)
    achievement_level = models.CharField(max_length=100) # e.g., "Juara 1 Nasional"
    date = models.DateField()

    def __str__(self):
        return self.title

class Proposal(models.Model):
    STATUS_CHOICES = [
        ('pending', 'Pending'),
        ('approved_dosen', 'Approved by Dosen'),
        ('approved_fakultas', 'Approved by Fakultas'),
        ('approved_universitas', 'Approved by Universitas'),
        ('rejected', 'Rejected'),
        ('completed', 'Completed'),
    ]

    PROPOSAL_TYPE_CHOICES = [
        ('lomba', 'Lomba'),
        ('non_lomba', 'Non-Lomba'),
    ]

    title = models.CharField(max_length=200)
    proposer_name = models.CharField(max_length=100, help_text="Nama perorangan, kelompok, atau lembaga")
    description = models.TextField()
    proposal_type = models.CharField(max_length=20, choices=PROPOSAL_TYPE_CHOICES, default='lomba')
    status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
    submitted_at = models.DateTimeField(default=timezone.now)
    attachment = models.FileField(upload_to='proposals/', blank=True, null=True, help_text="Dokumen proposal (PDF, DOCX)")

    def __str__(self):
        return f"{self.title} by {self.proposer_name}"
