from django.db import models
from . import SideStoreModel
import uuid

class DrawLog(SideStoreModel):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
    tournament = models.ForeignKey('Tournament', on_delete=models.SET_NULL, related_name='draw_logs', null=True)
    draw_date = models.DateTimeField()
    draw_seed = models.IntegerField()
    draw_match_index = models.IntegerField()
    draw_team_position = models.IntegerField()
    draw_type = models.IntegerField(default=0)

    def delete_dependencies(self):
        pass

    def __str__(self):
        return f'{self.draw_date}'

    def save(self, *args, **kwargs):
        self.store_id = str(self.get_tournament_id())
        super().save(*args, **kwargs)

    def get_tournament_id(self):
        return self.tournament.id
