more removing of date.today and replacing with timezone.now
This commit is contained in:
@@ -1263,7 +1263,7 @@ def setcp(workout,background=False,recurrance=True):
|
||||
return pd.DataFrame({'delta':[],'cp':[]}),pd.Series(dtype='float'),pd.Series(dtype='float')
|
||||
|
||||
def update_wps(r,types,mode='water',asynchron=True):
|
||||
firstdate = datetime.date.today()-datetime.timedelta(days=r.cprange)
|
||||
firstdate = timezone.now()-datetime.timedelta(days=r.cprange)
|
||||
workouts = Workout.objects.filter(
|
||||
date__gte=firstdate,
|
||||
workouttype__in=types,
|
||||
@@ -1304,7 +1304,7 @@ def update_wps(r,types,mode='water',asynchron=True):
|
||||
|
||||
|
||||
def update_rolling_cp(r,types,mode='water'):
|
||||
firstdate = datetime.date.today()-datetime.timedelta(days=r.cprange)
|
||||
firstdate = timezone.now()-datetime.timedelta(days=r.cprange)
|
||||
workouts = Workout.objects.filter(
|
||||
date__gte=firstdate,
|
||||
workouttype__in=types,
|
||||
|
||||
@@ -1183,7 +1183,6 @@ def check_teams_on_change(sender, **kwargs):
|
||||
action = kwargs.pop('action', None)
|
||||
pk_set = kwargs.pop('pk_set',None)
|
||||
if action == 'pre_add':
|
||||
#if instance.protrialexpires < datetime.date.today() and instance.plantrialexpires < datetime.date.today():
|
||||
for id in pk_set:
|
||||
team = Team.objects.get(id=id)
|
||||
if not can_join_team(instance.user,team):
|
||||
|
||||
@@ -621,7 +621,7 @@ def is_session_complete_ws(ws,ps):
|
||||
ws = ws.order_by("date")
|
||||
if ws.count()==0:
|
||||
today = timezone.now()
|
||||
if today > ps.enddate:
|
||||
if today.date() > ps.enddate:
|
||||
verdict = 'missed'
|
||||
ratio = 0
|
||||
return ratio,verdict,None
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import rules
|
||||
import datetime
|
||||
from django.utils import timezone
|
||||
|
||||
# PERMISSIONS
|
||||
|
||||
@@ -78,7 +79,7 @@ def user_is_not_basic(user):
|
||||
if user.rower.rowerplan != 'basic':
|
||||
return True
|
||||
|
||||
if user.rower.protrialexpires >= datetime.date.today():
|
||||
if user.rower.protrialexpires >= timezone.now().date():
|
||||
return True # pragma: no cover
|
||||
|
||||
return False
|
||||
@@ -143,7 +144,7 @@ def is_protrial(user):
|
||||
return False
|
||||
|
||||
if r.rowerplan == 'basic':
|
||||
return r.protrialexpires >= datetime.date.today()
|
||||
return r.protrialexpires >= timezone.now().date()
|
||||
if r.rowerplan == 'freecoach':
|
||||
if r.mycoachgroup is not None:
|
||||
return len(r.mycoachgroup)>=4
|
||||
@@ -188,7 +189,7 @@ def is_plantrial(user):
|
||||
return False
|
||||
|
||||
if r.rowerplan in ['basic','pro']:
|
||||
return r.plantrialexpires >= datetime.date.today()
|
||||
return r.plantrialexpires >= timezone.now().date()
|
||||
if r.rowerplan == 'freecoach':
|
||||
if r.mycoachgroup is not None:
|
||||
return len(r.mycoachgroup)>=4
|
||||
@@ -211,7 +212,7 @@ def can_plan(user):
|
||||
if user.rower.rowerplan in ['plan','coach']:
|
||||
return True
|
||||
if user.rower.rowerplan in ['basic','pro']:
|
||||
return user.rower.plantrialexpires >= datetime.date.today()
|
||||
return user.rower.plantrialexpires >= timezone.now().date()
|
||||
if user.rower.rowerplan == 'freecoach': # pragma: no cover
|
||||
if user.rower.mycoachgroup is not None:
|
||||
return len(user.rower.mycoachgroup)>=4
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
@@ -3,6 +3,7 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
from datetime import timedelta
|
||||
from django.utils import timezone
|
||||
|
||||
import math
|
||||
import numpy as np
|
||||
|
||||
@@ -362,7 +362,7 @@ def trendflexdata(workouts, options,userid=0):
|
||||
datadf['date'] = datadf['workoutid']
|
||||
datadf['date'].replace(datemapping,inplace=True)
|
||||
|
||||
today = datetime.date.today()
|
||||
today = timezone.now()
|
||||
|
||||
try:
|
||||
datadf['days ago'] = list(map(lambda x : x.days, datadf.date - today))
|
||||
|
||||
@@ -2568,7 +2568,7 @@ def rower_view_instantplan(request,id='',userid=0):
|
||||
|
||||
targets = TrainingTarget.objects.filter(
|
||||
rowers=r,
|
||||
date__gte=datetime.date.today(),
|
||||
date__gte=timezone.now(),
|
||||
).order_by("-date")
|
||||
|
||||
if request.method == 'POST' and not request.user.is_anonymous:
|
||||
@@ -2855,12 +2855,12 @@ def rower_create_trainingplan(request,id=0):
|
||||
|
||||
targets = TrainingTarget.objects.filter(
|
||||
rowers=therower,
|
||||
date__gte=datetime.date.today(),
|
||||
date__gte=timezone.now(),
|
||||
).order_by("date")
|
||||
|
||||
old_targets = TrainingTarget.objects.filter(
|
||||
rowers=therower,
|
||||
date__lt=datetime.date.today(),
|
||||
date__lt=timezone.now(),
|
||||
).order_by("-date")
|
||||
|
||||
targetform = TrainingTargetForm(user=request.user)
|
||||
@@ -2869,7 +2869,7 @@ def rower_create_trainingplan(request,id=0):
|
||||
|
||||
plans_to_deactivate = TrainingPlan.objects.filter(
|
||||
rowers=therower,
|
||||
enddate__lt=datetime.date.today(),
|
||||
enddate__lt=timezone.now(),
|
||||
status=True,
|
||||
).order_by("-startdate")
|
||||
|
||||
|
||||
@@ -841,10 +841,10 @@ def virtualevents_view(request):
|
||||
|
||||
# default races
|
||||
races1 = VirtualRace.objects.filter(
|
||||
startdate__gte=datetime.date.today(),
|
||||
startdate__gte=timezone.now(),
|
||||
)
|
||||
races2 = VirtualRace.objects.filter(
|
||||
startdate__lte=datetime.date.today(),
|
||||
startdate__lte=timezone.now(),
|
||||
evaluation_closure__gte=timezone.now()-datetime.timedelta(days=3),
|
||||
)
|
||||
|
||||
@@ -876,11 +876,11 @@ def virtualevents_view(request):
|
||||
|
||||
if regattatype == 'upcoming':
|
||||
races1 = VirtualRace.objects.filter(
|
||||
startdate__gte=datetime.date.today(),
|
||||
startdate__gte=timezone.now(),
|
||||
country__in=countries
|
||||
)
|
||||
races2 = VirtualRace.objects.filter(
|
||||
startdate__lte=datetime.date.today(),
|
||||
startdate__lte=timezone.now(),
|
||||
evaluation_closure__gte=timezone.now(),
|
||||
country__in=countries
|
||||
)
|
||||
@@ -896,7 +896,7 @@ def virtualevents_view(request):
|
||||
).order_by("-startdate","-start_time")
|
||||
elif regattatype == 'ongoing':
|
||||
races = VirtualRace.objects.filter(
|
||||
startdate__lte=datetime.date.today(),
|
||||
startdate__lte=timezone.now(),
|
||||
evaluation_closure__gte=timezone.now(),
|
||||
country__in=countries
|
||||
).order_by("startdate","start_time")
|
||||
|
||||
@@ -153,7 +153,7 @@ def start_trial_view(request):
|
||||
url = '/rowers/paidplans'
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
r.protrialexpires = datetime.date.today()+datetime.timedelta(13)
|
||||
r.protrialexpires = timezone.now()+datetime.timedelta(13)
|
||||
r.save()
|
||||
|
||||
url = reverse('workouts_view')
|
||||
@@ -187,8 +187,8 @@ def start_plantrial_view(request):
|
||||
url = '/rowers/paidplans'
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
r.plantrialexpires = datetime.date.today()+datetime.timedelta(13)
|
||||
r.protrialexpires = datetime.date.today()+datetime.timedelta(13)
|
||||
r.plantrialexpires = timezone.now()+datetime.timedelta(13)
|
||||
r.protrialexpires = timezone.now()+datetime.timedelta(13)
|
||||
r.save()
|
||||
|
||||
url = reverse('workouts_view')
|
||||
|
||||
@@ -758,7 +758,7 @@ def addmanual_view(request,raceid=0):
|
||||
|
||||
initial = {
|
||||
'workouttype':'rower',
|
||||
'date':datetime.date.today(),
|
||||
'date':timezone.now(),
|
||||
'starttime':timezone.now(),
|
||||
'timezone':r.defaulttimezone,
|
||||
'duration':datetime.timedelta(minutes=2),
|
||||
|
||||
Reference in New Issue
Block a user