This repository has been archived on 2025-02-01. You can view files and clone it, but cannot push or open issues or pull requests.
django-stock/tea/models.py

53 lines
1.7 KiB
Python

from django.db import models
class Company(models.Model):
name = models.CharField(max_length=200)
website = models.CharField(max_length=200)
def __str__(self):
return self.name
class Tea(models.Model):
TEA_CONDITIONING = [
('loose', 'En vrac'),
('bag', 'En sachet'),
]
TEA_TYPE = [
('infusion', 'Infusion'),
('black-tea', 'Thé noir'),
('green-tea', 'Thé vert'),
('white-tea', 'Thé blanc'),
('rooibos', 'Rooibos'),
('fruit', 'Tisane aux fruits'),
('mate', 'Maté'),
]
QUANTITY_UNITS = [
('cs-l', 'cs/lt'),
('cc-dl', 'cc/dl'),
('cc-l', 'cc/lt'),
('pc-l', 'pc/lt'),
]
TIME_UNITS = [
('min', 'min'),
]
name = models.CharField(max_length=200)
company = models.ForeignKey(Company, on_delete=models.PROTECT, null=True)
tea_type = models.CharField(max_length=20, choices=TEA_TYPE)
conditioning = models.CharField(max_length=20, choices=TEA_CONDITIONING)
ingredients = models.TextField(max_length=1024)
tea_quantity = models.DecimalField(max_digits=5, decimal_places=1, null=True, blank=True)
tea_quantity_type = models.CharField(max_length=20, choices=QUANTITY_UNITS, default='cc-l')
tea_time_from = models.PositiveSmallIntegerField()
tea_time_to = models.PositiveSmallIntegerField()
tea_time_type = models.CharField(max_length=20, choices=TIME_UNITS, default='min')
url = models.URLField(max_length=1024, null=True, blank=True)
available = models.BooleanField()
comment = models.TextField(null=True, blank=True)
def __str__(self):
return self.company.name + " - " + self.name