# -*- coding: utf-8 -*-
from django.db import models
from django.contrib.auth.models import User
from pyuploadcare.dj import ImageField


class Category(models.model):
    """Model for ingredient's category"""
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name


class Ingredient(models.model):
    """Model represents ingredient"""
    name = models.CharField(max_length=100)
    image = ImageField(blank=True, null=True)
    description = models.TextField()
    category = models.ForeignKey(Category)

    def __unicode__(self):
        return self.name

    class Meta:
        ordering = ['name']


class Tool(models.model):
    """Model represents tool for coctailing"""
    name = models.CharField(max_length=100)
    image = ImageField(blank=True, null=True)
    description = models.TextField(blank=True)

    def __unicode__(self):
        return self.name

    class Meta:
        ordering = ['name']


class Recipe(models.model):
    """Model represents Coctail's recipe"""
    name = models.CharField(max_length=100)
    image = ImageField(blank=True, null=True)
    ingredients = models.ManyToManyField(Ingredient)
    tools = models.ManyToManyField(Tool)
    description = models.TextField()
    owner = models.ForeignKey(User)
    shared = models.BooleanField(default=False)

    def __unicode__(self):
        return self.name

    class Meta:
        ordering = ['name']