import datetime

from django.db import models
from django.utils import timezone
from django.contrib.auth.models import AbstractUser
from django.core.validators import MinValueValidator, MaxValueValidator
# Create your models here.
class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')
    def __str__(self):
        return self.question_text
    def was_published_recently(self):
        now = timezone.now()
        return now - datetime.timedelta(days=1) <= self.pub_date <= now
    was_published_recently.admin_order_field = 'pub_date'
    was_published_recently.boolean = True
    was_published_recently.short_description = 'Published recently?'

class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)
    def __str__(self):
        return self.choice_text




class CustomUser(AbstractUser):
    full_name = models.CharField(error_messages={'required': 'Introdu un nume!'},max_length=100, blank=False)
    phone_number = models.CharField(error_messages={'required': 'Trebuie sa stim cum sa dam de tine!'},max_length=100, blank=False)
    age = models.IntegerField(validators=[MinValueValidator(18),
                                       MaxValueValidator(80)],error_messages={'required': 'Interzis minorilor!'},null=True, blank=True)
    address = models.CharField(error_messages={'required': 'O metoda de precautie!'},max_length=100, blank=False)

class Imprumut(models.Model):
    username = models.CharField(max_length=200,blank=True)
    suma = models.IntegerField(validators=[MinValueValidator(100000),
                                       MaxValueValidator(20000000)],error_messages={'required': 'Suma minima este de 100.000$ / Maxim 20.000.000$'},null=True, blank=True)
    perioada = models.PositiveSmallIntegerField()
    luni = models.IntegerField()
    bifa = models.BooleanField()



import datetime

from django.db import models
from django.utils import timezone
from django.contrib.auth.models import AbstractUser
from django.core.validators import MinValueValidator, MaxValueValidator
# Create your models here.
class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')
    def __str__(self):
        return self.question_text
    def was_published_recently(self):
        now = timezone.now()
        return now - datetime.timedelta(days=1) <= self.pub_date <= now
    was_published_recently.admin_order_field = 'pub_date'
    was_published_recently.boolean = True
    was_published_recently.short_description = 'Published recently?'

class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)
    def __str__(self):
        return self.choice_text




class CustomUser(AbstractUser):
    full_name = models.CharField(error_messages={'required': 'Introdu un nume!'},max_length=100, blank=False)
    phone_number = models.CharField(error_messages={'required': 'Trebuie sa stim cum sa dam de tine!'},max_length=100, blank=False)
    age = models.IntegerField(validators=[MinValueValidator(18),
                                       MaxValueValidator(80)],error_messages={'required': 'Interzis minorilor!'},null=True, blank=True)
    address = models.CharField(error_messages={'required': 'O metoda de precautie!'},max_length=100, blank=False)

class Imprumut(models.Model):
    username = models.CharField(max_length=200,blank=True)
    suma = models.IntegerField(validators=[MinValueValidator(100000),
                                       MaxValueValidator(20000000)],error_messages={'required': 'Suma minima este de 100.000$ / Maxim 20.000.000$'},null=True, blank=True)
    perioada = models.PositiveSmallIntegerField()
    luni = models.IntegerField()
    bifa = models.BooleanField()



# Create your models here.