-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
30 lines (20 loc) · 805 Bytes
/
models.py
File metadata and controls
30 lines (20 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from django.db import models
from django.utils.translation import gettext_lazy as _
from base.models import NamedBase
from species.models import SpeciesBase, Species
class Culture(NamedBase):
species = models.ManyToManyField(Species, through='CultureSpecies')
class CultureBase(models.Model):
""" Abstract base class for elements relating to culture. """
class Meta:
abstract = True
verbose_name = _('culture')
verbose_name_plural = _('cultures')
culture = models.ForeignKey(Culture, on_delete=models.CASCADE)
def __str__(self):
return str(self.culture)
class CultureSpecies(CultureBase, SpeciesBase):
ratio = models.FloatField(
help_text=_('fraction, monoculture equivalent')
# TODO: Validate value > 0.0 and <= 1.0
)