import uuid
from django.db import models

class QuestionConfiguration(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    function_ref_id = models.CharField(max_length=100)
    label = models.CharField(max_length=255)
    required = models.BooleanField(default=False)
    question_type = models.CharField(max_length=50)
    question_options = models.JSONField(null=True, blank=True, default=list)
    question_id = models.CharField(max_length=100)
    border_color = models.CharField(max_length=50, default='')
    read_only = models.BooleanField(default=False)
    custom_sql = models.TextField(blank=True, null=True)
    dependency_id = models.CharField(max_length=100, blank=True, null=True, help_text='question_id of the question this depends on (for :dependencyId replacement in custom_sql)')
    order = models.IntegerField(default=0, help_text='Order in which questions should be displayed')
    question_category = models.CharField(max_length=50, blank=True, null=True, choices=[('None', 'None'), ('Work', 'Work')], default='None', help_text='Category of the question (None or Work)')
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = 'question_configurations'
        ordering = ['order', 'created_at']

    def __str__(self):
        return f"{self.label} - {self.function_ref_id}"
