from django.db import models
import datetime
from django.utils import timezone
# Create your models here.


class Sport(models.Model):
    name = models.CharField(max_length=200)
    is_team = models.BooleanField(default=True)
    description = models.TextField()

    def __str__(self):
        return self.name


class Location(models.Model):
    name = models.CharField(max_length=200, blank=False)
    address = models.CharField(max_length=200, blank=True)
    latitude = models.DecimalField(max_digits=6, decimal_places=3)
    longitude = models.DecimalField(max_digits=6, decimal_places=3)

    def __str__(self):
        return self.name


def get_default_place():
    return Location.objects.get(id=1)


class Meeting(models.Model):
    name = models.CharField(max_length=200)
    place = models.ForeignKey(Location, default=1)
    sport = models.ForeignKey(Sport, default=1)
    players_count = models.IntegerField(default=0)
    start_time = models.DateTimeField('Start Time', default=datetime.datetime.now)
    finish_time = models.DateTimeField('Finish Time', default=datetime.datetime.now)

    def __str__(self):
        return self.name



