2018-03-02 12:01:51 +01:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
|
|
|
class Room(models.Model):
|
|
|
|
class Meta:
|
|
|
|
verbose_name = 'salle'
|
|
|
|
verbose_name_plural = 'salles'
|
|
|
|
|
|
|
|
name = models.CharField('nom', max_length=300)
|
2018-03-04 10:27:06 +01:00
|
|
|
latitude = models.DecimalField('latitude', max_digits=11, decimal_places=8, blank=True, null=True)
|
|
|
|
longitude = models.DecimalField('longitude', max_digits=11, decimal_places=8, blank=True, null=True)
|
2018-03-03 14:24:57 +01:00
|
|
|
notes = models.TextField('notes', blank=True)
|
2018-03-02 12:01:51 +01:00
|
|
|
|
2018-03-03 18:16:27 +01:00
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
2018-03-02 12:01:51 +01:00
|
|
|
|
|
|
|
class Equipment(models.Model):
|
|
|
|
class Meta:
|
|
|
|
verbose_name = 'machine'
|
|
|
|
verbose_name_plural = 'machines'
|
|
|
|
|
|
|
|
name = models.CharField('nom', max_length=300)
|
|
|
|
room = models.ForeignKey(
|
|
|
|
verbose_name='salle',
|
|
|
|
to=Room,
|
|
|
|
on_delete=models.SET_NULL,
|
|
|
|
related_name='equipments',
|
|
|
|
null=True
|
|
|
|
)
|
|
|
|
|
2018-03-03 18:16:27 +01:00
|
|
|
@property
|
|
|
|
def last_theoretical_max(self):
|
2018-03-04 09:23:35 +01:00
|
|
|
return self.theoretical_maxs.order_by('-date', '-pk').first()
|
2018-03-03 18:16:27 +01:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f'{self.name} ({self.room.name})'
|
|
|
|
|
2018-03-02 12:01:51 +01:00
|
|
|
|
|
|
|
class Setting(models.Model):
|
|
|
|
class Meta:
|
|
|
|
verbose_name = 'réglage'
|
|
|
|
verbose_name_plural = 'réglages'
|
|
|
|
|
|
|
|
equipment = models.ForeignKey(
|
|
|
|
verbose_name='machine',
|
|
|
|
to=Equipment,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
related_name='settings'
|
|
|
|
)
|
|
|
|
name = models.CharField('nom', max_length=200)
|
|
|
|
value = models.CharField('valeur', max_length=200)
|
|
|
|
|
2018-03-03 18:16:27 +01:00
|
|
|
def __str__(self):
|
|
|
|
return f'{self.name}={self.value}'
|
|
|
|
|
2018-03-02 12:01:51 +01:00
|
|
|
|
2018-03-04 20:39:48 +01:00
|
|
|
class Unit(models.Model):
|
|
|
|
class Meta:
|
|
|
|
verbose_name = 'unité'
|
|
|
|
verbose_name_plural = 'unités'
|
|
|
|
|
|
|
|
name = models.CharField('nom', max_length=50)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
2018-03-02 12:01:51 +01:00
|
|
|
class TheoreticalMax(models.Model):
|
|
|
|
class Meta:
|
|
|
|
verbose_name = 'maximum théorique'
|
|
|
|
verbose_name_plural = 'maximums théoriques'
|
|
|
|
|
|
|
|
equipment = models.ForeignKey(
|
|
|
|
verbose_name='machine',
|
|
|
|
to=Equipment,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
related_name='theoretical_maxs'
|
|
|
|
)
|
|
|
|
date = models.DateField('date')
|
|
|
|
value = models.FloatField('valeur')
|
2018-03-04 20:39:48 +01:00
|
|
|
unit = models.ForeignKey(
|
|
|
|
verbose_name='unité',
|
|
|
|
to=Unit,
|
|
|
|
on_delete=models.PROTECT,
|
|
|
|
null=True
|
|
|
|
)
|
2018-03-02 12:01:51 +01:00
|
|
|
|
2018-03-03 18:16:27 +01:00
|
|
|
def __str__(self):
|
2018-03-04 20:39:48 +01:00
|
|
|
return f'{self.value} {self.unit.name} le {self.date}'
|
2018-03-03 18:16:27 +01:00
|
|
|
|
2018-03-02 12:01:51 +01:00
|
|
|
|
|
|
|
class Session(models.Model):
|
|
|
|
class Meta:
|
|
|
|
verbose_name = 'séance'
|
|
|
|
verbose_name_plural = 'séances'
|
|
|
|
|
2018-03-03 18:16:27 +01:00
|
|
|
start = models.DateTimeField('date et heure de début')
|
2018-03-02 12:01:51 +01:00
|
|
|
room = models.ForeignKey(
|
|
|
|
verbose_name='salle',
|
|
|
|
to=Room,
|
|
|
|
on_delete=models.SET_NULL,
|
|
|
|
related_name='sessions',
|
|
|
|
null=True
|
|
|
|
)
|
2018-03-03 14:24:57 +01:00
|
|
|
notes = models.TextField('notes', blank=True)
|
2018-03-02 12:01:51 +01:00
|
|
|
|
2018-03-04 09:23:35 +01:00
|
|
|
def __str__(self):
|
|
|
|
return f'{self.room} {self.start:%d/%m/%Y %H:%M}'
|
|
|
|
|
2018-03-02 12:01:51 +01:00
|
|
|
|
|
|
|
class Round(models.Model):
|
|
|
|
class Meta:
|
|
|
|
verbose_name = 'série'
|
|
|
|
verbose_name_plural = 'séries'
|
|
|
|
|
|
|
|
repetition_number = models.PositiveIntegerField('nombre de répétitions')
|
|
|
|
equipment = models.ForeignKey(
|
|
|
|
verbose_name='machine',
|
|
|
|
to=Equipment,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
related_name='rounds'
|
|
|
|
)
|
|
|
|
theoretical_max_percentage = models.PositiveIntegerField('pourcentage')
|
|
|
|
chosen_weight = models.FloatField('charge choisie')
|
|
|
|
session = models.ForeignKey(
|
|
|
|
verbose_name='séance',
|
|
|
|
to=Session,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
related_name='rounds'
|
|
|
|
)
|
2018-03-03 14:24:57 +01:00
|
|
|
notes = models.TextField('notes', blank=True)
|