removed obsolete code
This commit is contained in:
@@ -1244,214 +1244,7 @@ def remove_power_view(request,id=0):
|
|||||||
@user_passes_test(ispromember,login_url='/rowers/paidplans/',
|
@user_passes_test(ispromember,login_url='/rowers/paidplans/',
|
||||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality. If you are already a Pro user, please log in to access this functionality",
|
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality. If you are already a Pro user, please log in to access this functionality",
|
||||||
redirect_field_name=None)
|
redirect_field_name=None)
|
||||||
def team_comparison_select(request,
|
|
||||||
startdatestring="",
|
|
||||||
enddatestring="",
|
|
||||||
message='',
|
|
||||||
successmessage='',
|
|
||||||
userid=0,
|
|
||||||
startdate=timezone.now()-datetime.timedelta(days=30),
|
|
||||||
enddate=timezone.now(),
|
|
||||||
id=0,
|
|
||||||
teamid=0):
|
|
||||||
|
|
||||||
r = getrequestrower(request,userid=userid)
|
|
||||||
requestrower = getrower(request.user)
|
|
||||||
|
|
||||||
|
|
||||||
request.session.pop('ps',None)
|
|
||||||
|
|
||||||
if 'waterboattype' in request.session:
|
|
||||||
waterboattype = request.session['waterboattype']
|
|
||||||
else:
|
|
||||||
waterboattype = mytypes.waterboattype
|
|
||||||
|
|
||||||
if 'modalities' in request.session:
|
|
||||||
modalities = request.session['modalities']
|
|
||||||
if len(modalities) > 1: # pragma: no cover
|
|
||||||
modality = 'all'
|
|
||||||
else:
|
|
||||||
modality = modalities[0]
|
|
||||||
else:
|
|
||||||
modalities = [m[0] for m in mytypes.workouttypes]
|
|
||||||
modality = 'all'
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
|
||||||
dateform = DateRangeForm(request.POST)
|
|
||||||
if dateform.is_valid():
|
|
||||||
startdate = dateform.cleaned_data['startdate']
|
|
||||||
enddate = dateform.cleaned_data['enddate']
|
|
||||||
startdatestring = startdate.strftime('%Y-%m-%d')
|
|
||||||
enddatestring = enddate.strftime('%Y-%m-%d')
|
|
||||||
request.session['startdate'] = startdatestring
|
|
||||||
request.session['enddate'] = enddatestring
|
|
||||||
|
|
||||||
modalityform = TrendFlexModalForm(request.POST)
|
|
||||||
if modalityform.is_valid():
|
|
||||||
modality = modalityform.cleaned_data['modality']
|
|
||||||
waterboattype = modalityform.cleaned_data['waterboattype']
|
|
||||||
if modality == 'all': # pragma: no cover
|
|
||||||
modalities = [m[0] for m in mytypes.workouttypes]
|
|
||||||
else:
|
|
||||||
modalities = [modality]
|
|
||||||
|
|
||||||
if modality != 'water': # pragma: no cover
|
|
||||||
waterboattype = [b[0] for b in mytypes.boattypes]
|
|
||||||
|
|
||||||
|
|
||||||
request.session['modalities'] = modalities
|
|
||||||
request.session['waterboattype'] = waterboattype
|
|
||||||
else:
|
|
||||||
dateform = DateRangeForm(initial={
|
|
||||||
'startdate':startdate,
|
|
||||||
'enddate':enddate,
|
|
||||||
})
|
|
||||||
modalityform = TrendFlexModalForm(initial={
|
|
||||||
'modality':modality,
|
|
||||||
'waterboattype':waterboattype,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
negtypes = []
|
|
||||||
for b in mytypes.boattypes:
|
|
||||||
if b[0] not in waterboattype:
|
|
||||||
negtypes.append(b[0])
|
|
||||||
|
|
||||||
startdate = datetime.datetime.combine(startdate,datetime.time())
|
|
||||||
enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59))
|
|
||||||
#enddate = enddate+datetime.timedelta(days=1)
|
|
||||||
|
|
||||||
if startdatestring:
|
|
||||||
startdate = iso8601.parse_date(startdatestring)
|
|
||||||
if enddatestring:
|
|
||||||
enddate = iso8601.parse_date(enddatestring)
|
|
||||||
|
|
||||||
if enddate < startdate: # pragma: no cover
|
|
||||||
s = enddate
|
|
||||||
enddate = startdate
|
|
||||||
startdate = s
|
|
||||||
|
|
||||||
try:
|
|
||||||
theteam = Team.objects.get(id=teamid)
|
|
||||||
except Team.DoesNotExist:
|
|
||||||
theteam = 0
|
|
||||||
|
|
||||||
# make sure the dates are not naive
|
|
||||||
try:
|
|
||||||
startdate = pytz.utc.localize(startdate)
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
enddate = pytz.utc.localize(enddate)
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if theteam and (theteam.viewing == 'allmembers' or theteam.manager == request.user):
|
|
||||||
workouts = Workout.objects.filter(team=theteam,
|
|
||||||
startdatetime__gte=startdate,
|
|
||||||
startdatetime__lte=enddate,
|
|
||||||
workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes)
|
|
||||||
elif theteam and theteam.viewing == 'coachonly': # pragma: no cover
|
|
||||||
workouts = Workout.objects.filter(team=theteam,user=r,
|
|
||||||
startdatetime__gte=startdate,
|
|
||||||
startdatetime__lte=enddate,
|
|
||||||
workouttype__in=modalities).order_by("-date","-starttime").exclude(boattype__in=negtypes)
|
|
||||||
|
|
||||||
|
|
||||||
else:
|
|
||||||
theteam = None
|
|
||||||
workouts = Workout.objects.filter(user=r,
|
|
||||||
startdatetime__gte=startdate,
|
|
||||||
startdatetime__lte=enddate,
|
|
||||||
workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes)
|
|
||||||
|
|
||||||
|
|
||||||
query = request.GET.get('q')
|
|
||||||
if query: # pragma: no cover
|
|
||||||
query_list = query.split()
|
|
||||||
workouts = workouts.filter(
|
|
||||||
reduce(operator.and_,
|
|
||||||
(Q(name__icontains=q) for q in query_list)) |
|
|
||||||
reduce(operator.and_,
|
|
||||||
(Q(notes__icontains=q) for q in query_list))
|
|
||||||
)
|
|
||||||
searchform = SearchForm(initial={'q':query})
|
|
||||||
else:
|
|
||||||
searchform = SearchForm()
|
|
||||||
|
|
||||||
if id:
|
|
||||||
firstworkout = get_workout(id)
|
|
||||||
if not is_workout_team(request.user,firstworkout): # pragma: no cover
|
|
||||||
raise PermissionDenied("You are not allowed to use this workout")
|
|
||||||
|
|
||||||
firstworkoutquery = Workout.objects.filter(id=encoder.decode_hex(id))
|
|
||||||
workouts = firstworkoutquery | workouts
|
|
||||||
else:
|
|
||||||
firstworkout = None
|
|
||||||
|
|
||||||
form = WorkoutMultipleCompareForm()
|
|
||||||
form.fields["workouts"].queryset = workouts
|
|
||||||
if id:
|
|
||||||
form.fields["workouts"].initial = [firstworkout]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if theteam:
|
|
||||||
theid = theteam.id
|
|
||||||
else:
|
|
||||||
theid = 0
|
|
||||||
|
|
||||||
chartform = ChartParamChoiceForm(initial={'teamid':0})
|
|
||||||
|
|
||||||
messages.info(request,successmessage)
|
|
||||||
messages.error(request,message)
|
|
||||||
|
|
||||||
if id:
|
|
||||||
breadcrumbs = [
|
|
||||||
{
|
|
||||||
'url':'/rowers/list-workouts/',
|
|
||||||
'name':'Workouts'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'url':get_workout_default_page(request,id),
|
|
||||||
'name': firstworkout.name
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'url':reverse('team_comparison_select',kwargs={'id':id,'teamid':teamid}),
|
|
||||||
'name':'Compare Select'
|
|
||||||
},
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
breadcrumbs = [
|
|
||||||
{
|
|
||||||
'url':'/rowers/list-workouts/',
|
|
||||||
'name':'Workouts'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'url':reverse('team_comparison_select',kwargs={'teamid':teamid}),
|
|
||||||
'name': 'Compare Select'
|
|
||||||
},
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
||||||
return render(request, 'team_compare_select.html',
|
|
||||||
{'workouts': workouts,
|
|
||||||
'workout':firstworkout,
|
|
||||||
'dateform':dateform,
|
|
||||||
'startdate':startdate,
|
|
||||||
'enddate':enddate,
|
|
||||||
'team':theteam,
|
|
||||||
'searchform':searchform,
|
|
||||||
'form':form,
|
|
||||||
'rower':r,
|
|
||||||
'breadcrumbs':breadcrumbs,
|
|
||||||
'active':'nav-workouts',
|
|
||||||
'chartform':chartform,
|
|
||||||
'modalityform':modalityform,
|
|
||||||
'teams':get_my_teams(request.user),
|
|
||||||
})
|
|
||||||
|
|
||||||
def course_mapcompare_view(request,id=0):
|
def course_mapcompare_view(request,id=0):
|
||||||
results = []
|
results = []
|
||||||
@@ -6190,7 +5983,7 @@ def workout_course_view(request, id):
|
|||||||
)
|
)
|
||||||
if records:
|
if records:
|
||||||
record = records[0]
|
record = records[0]
|
||||||
else:
|
else: # pragma: no cover
|
||||||
# create record
|
# create record
|
||||||
record = VirtualRaceResult(
|
record = VirtualRaceResult(
|
||||||
userid = r.id,
|
userid = r.id,
|
||||||
@@ -6222,7 +6015,7 @@ def workout_course_view(request, id):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
request.session['async_tasks'] += [(job.id,'check_race_course')]
|
request.session['async_tasks'] += [(job.id,'check_race_course')]
|
||||||
except KeyError:
|
except KeyError: # pragma: no cover
|
||||||
request.session['async_tasks'] = [(job.id,'check_race_course')]
|
request.session['async_tasks'] = [(job.id,'check_race_course')]
|
||||||
|
|
||||||
messages.info(request,'We are checking your time on the course in the background. You will receive an email when the check is complete. You can check the status <a href="/rowers/jobs-status/" target="_blank">here</a>')
|
messages.info(request,'We are checking your time on the course in the background. You will receive an email when the check is complete. You can check the status <a href="/rowers/jobs-status/" target="_blank">here</a>')
|
||||||
|
|||||||
Reference in New Issue
Block a user