You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.3 KiB
31 lines
1.3 KiB
from django.db import models
|
|
import uuid
|
|
|
|
class Club(models.Model):
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
|
|
creator = models.ForeignKey('CustomUser', blank=True, null=True, on_delete=models.CASCADE) # string to avoid circular import
|
|
name = models.CharField(max_length=50)
|
|
acronym = models.CharField(max_length=10)
|
|
phone = models.CharField(max_length=15, null=True, blank=True)
|
|
code = models.CharField(max_length=10, null=True, blank=True)
|
|
federal_club_data = models.JSONField(null=True, blank=True)
|
|
|
|
address = models.CharField(max_length=200, null=True, blank=True)
|
|
city = models.CharField(max_length=100, null=True, blank=True)
|
|
zip_code = models.CharField(max_length=10, null=True, blank=True)
|
|
latitude = models.FloatField(null=True, blank=True)
|
|
longitude = models.FloatField(null=True, blank=True)
|
|
|
|
court_count = models.IntegerField(default=2)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
def events_count(self):
|
|
return len(self.event_set.all())
|
|
|
|
def court_name(self, index):
|
|
for court in self.court_set.all():
|
|
if court.index == index and court.name is not None and len(court.name) > 0:
|
|
return court.name
|
|
return f"Terrain {index + 1}"
|
|
|