from datetime import date
from uuid import uuid4

from django.db import models


class Author(models.Model):
    """
    Model for book authors.

    """

    uuid = models.UUIDField(default=uuid4, db_index=True, verbose_name="UUID")
    first_name = models.CharField(max_length=64, blank=False, verbose_name="first name")
    last_name = models.CharField(max_length=64, blank=False, verbose_name="last name")
    description = models.TextField(blank=True, verbose_name="description")
    birth_date = models.DateField(default=date(2000, 1, 1), verbose_name="birth date")
    registration_date = models.DateTimeField(auto_now_add=True, verbose_name="registration date")

    class Meta:
        verbose_name = "book author"
        verbose_name_plural = "book authors"

    def __str__(self):
        return f"{self.get_full_name()} ({self.uuid})"

    def get_full_name(self):
        return f"{self.first_name} {self.last_name}"
