diff --git a/rowers/models.py b/rowers/models.py index c70e9c66..c0542bf4 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -4193,6 +4193,13 @@ class WorkoutForm(ModelForm): else: del self.fields['plannedsession'] + def clean(self): + if any(self.errors): + return + cd = self.cleaned_data + if cd['duration'] is None or cd['duration'] == '': + raise forms.ValidationError('Duration cannot be empty') + # Used for the rowing physics calculations diff --git a/rowers/rp3stuff.py b/rowers/rp3stuff.py index d3e5aea2..147d851a 100644 --- a/rowers/rp3stuff.py +++ b/rowers/rp3stuff.py @@ -51,7 +51,9 @@ graphql_url = "https://rp3rowing-app.com/graphql" # Checks if user has UnderArmour token, renews them if they are expired def rp3_open(user): tokenexpirydate = user.rower.rp3tokenexpirydate - if timezone.now()-timedelta(days=120)>tokenexpirydate: + if tokenexpirydate is None: + raise NoTokenError + if tokenexpirydate is not None and timezone.now()-timedelta(days=120)>tokenexpirydate: user.rower.rp3tokenexpirydate = timezone.now()-timedelta(days=1) user.rower.save() raise NoTokenError