from django.db import models
import uuid
from . import BaseModel, Club

class Court(BaseModel):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
    index = models.IntegerField(default=0)
    club = models.ForeignKey(Club, on_delete=models.SET_NULL, related_name='courts', null=True)
    name = models.CharField(max_length=50, null=True, blank=True)
    exit_allowed = models.BooleanField(default=False)
    indoor = models.BooleanField(default=False)

    def delete_dependencies(self):
        pass

    def __str__(self):
        if self.name:
            return self.name
        else:
            return f"Terrain {self.index + 1}"
