from django.db import models


class Category(models.Model):
    name = models.CharField(max_length=100)

    class Meta:
        verbose_name = "Category"
        verbose_name_plural = "Categories"

    def __unicode__(self):
        return '{0}'.format(self.name, )


class Author(models.Model):
    name = models.CharField(max_length=100, null=False, default="Unknow")
    birthdate = models.DateField(blank=True, null=True)

    class Meta:
        verbose_name = "Author"
        verbose_name_plural = "Authors"

    def __unicode__(self):
        return '{0}'.format(self.name, )


class Book(models.Model):
    name = models.CharField(max_length=100)
    category = models.ForeignKey(Category, null=False)
    abstract = models.CharField(max_length=1000, null=True)
    publication_date = models.DateField(format("Publication date"), blank=True, null=True)
    author = models.ForeignKey(Author, null=False)

    class Meta:
        verbose_name = "Book"
        verbose_name_plural = "Books"

    def __unicode__(self):
        return '{0}'.format(self.name, )


class Member(models.Model):
    firstName = models.CharField(max_length=50)
    lastName = models.CharField(max_length=50)
    book = models.ForeignKey(Book, null=False)

    class Meta:
        verbose_name = "Member"
        verbose_name_plural = "Members"

    def __unicode__(self):
        return '{0}'.format(self.firstName, )