from django.db import models
from django.utils.translation import ugettext_lazy as _

from core.models import WinoseBaseWithTrackingModel


# material a bag is made of
class BagMaterial(WinoseBaseWithTrackingModel):
    class Meta:
        verbose_name = _('bag material')
        verbose_name_plural = _('bag materials')

    name = models.CharField(
        max_length=63,
        verbose_name=_('name'),
        unique=True,
    )

    def __str__(self):
        return self.name

    detail_url = 'bag material_detail'
    overview_url = 'bag materials_list'
    update_url = 'bag material_update'
    create_url = 'bag material_create'


# le wild bag appears
class Bag(WinoseBaseWithTrackingModel):
    class Meta:
        verbose_name = _('bag')
        verbose_name_plural = _('bags')

    name = models.CharField(
        max_length=63,
        verbose_name=_('name'),
        unique=True
    )

    manufactured_at = models.DateField(
        verbose_name=_('manufacturing date')
    )

    # material used for this bag
    material = models.ForeignKey(to=BagMaterial,
                                 related_name='bags',
                                 verbose_name=_('bag material'))

    detail_url = 'bag_detail'
    overview_url = 'bags_list'
    create_url = 'bag_create'
    update_url = 'bag_update'

    def __str__(self):
        return self.name