from django.db import models
from django.core.validators import MinValueValidator, MaxValueValidator
import uuid

class Task(models.Model):
    title = models.CharField(max_length=255)
    description = models.TextField()
    price_from = models.IntegerField(validators=[MinValueValidator(0)])
    price_to = models.IntegerField(validators=[MinValueValidator(0)])
    needed_information = models.JSONField()

    def __str__(self):
        return self.title

class Request(models.Model):
    task = models.ForeignKey(Task, related_name='requests', on_delete=models.CASCADE)
    title = models.CharField(max_length=255)
    description = models.TextField()
    price_from = models.IntegerField(validators=[MinValueValidator(0)])
    price_to = models.IntegerField(validators=[MinValueValidator(0)])
    needed_information = models.JSONField()
    start_in_days = models.IntegerField()
    email = models.EmailField()
    email_confirmation = models.EmailField()
    external_id = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
    comment = models.TextField(null=True, blank=True)

