From d0a8abc85b332c4013457e84f088f7dae4371719 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 7 Aug 2019 11:51:46 +0200 Subject: [PATCH] models for alerts and conditions --- rowers/models.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/rowers/models.py b/rowers/models.py index 7b42bf24..d10dfa8e 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -1011,6 +1011,36 @@ class BaseFavoriteFormSet(BaseFormSet): if not yparam2: yparam2 = 'None' + + +class Condition(models.Model): + conditionchoices = ( + ('<','<'), + ('>','>'), + ('=','='), + ) + metric = models.CharField(max_length=50,choices=parchoicesy1,verbose_name='Metric') + value = models.FloatField(default=0) + condition = models.CharField(max_length=2,choices=conditionchoices,null=True) + alert = models.ForeignKey('Alert',on_delete=models.CASCADE,null=True) + +rowchoices = [] +for key,value in mytypes.workouttypes: + if key in mytypes.rowtypes: + rowchoices.append((key,value)) + + +class Alert(models.Model): + measured = models.OneToOneField(Condition,verbose_name='Measuring',on_delete=models.CASCADE, + related_name='measured') + reststrokes = models.BooleanField(default=False,null=True,verbose_name='Include Rest Strokes') + period = models.IntegerField(default=7,verbose_name='Reporting Period') + emailalert = models.BooleanField(default=True,verbose_name='Send email alerts') + workouttype = models.CharField(choices=rowchoices,max_length=50, + verbose_name='Exercise/Boat Class',default='water') + + + class BasePlannedSessionFormSet(BaseFormSet): def clean(self): if any(self.serrors):