Merge branch 'develop' into feature/icu_sessions
This commit is contained in:
@@ -48,6 +48,9 @@ def analysis_new(request,
|
||||
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")
|
||||
#if workout_is_strava(firstworkout):
|
||||
# messages.error(request, "You cannot use Strava workouts for analysis")
|
||||
# raise PermissionDenied("You cannot use Strava workouts for analysis")
|
||||
firstworkoutquery = Workout.objects.filter(id=encoder.decode_hex(id))
|
||||
|
||||
try:
|
||||
@@ -199,14 +202,14 @@ def analysis_new(request,
|
||||
startdatetime__lte=enddate,
|
||||
workouttype__in=modalities,
|
||||
rankingpiece__in=rankingtypes,
|
||||
)
|
||||
)#.exclude(workoutsource='strava')
|
||||
elif theteam is not None and theteam.viewing == 'coachonly': # pragma: no cover
|
||||
workouts = Workout.objects.filter(team=theteam, user=r,
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate,
|
||||
workouttype__in=modalities,
|
||||
rankingpiece__in=rankingtypes,
|
||||
)
|
||||
)#.exclude(workoutsource='strava')
|
||||
elif thesession is not None:
|
||||
workouts = get_workouts_session(r, thesession)
|
||||
else:
|
||||
@@ -218,6 +221,7 @@ def analysis_new(request,
|
||||
)
|
||||
if firstworkout:
|
||||
workouts = firstworkoutquery | workouts
|
||||
|
||||
workouts = workouts.order_by(
|
||||
"-date", "-starttime"
|
||||
).exclude(boattype__in=negtypes)
|
||||
@@ -253,7 +257,7 @@ def analysis_new(request,
|
||||
else:
|
||||
selectedworkouts = Workout.objects.filter(id__in=ids)
|
||||
|
||||
form.fields["workouts"].queryset = workouts | selectedworkouts
|
||||
form.fields["workouts"].queryset = (workouts | selectedworkouts)#.exclude(workoutsource='strava')
|
||||
|
||||
optionsform = AnalysisOptionsForm(initial={
|
||||
'modality': modality,
|
||||
@@ -363,6 +367,10 @@ def trendflexdata(workouts, options, userid=0):
|
||||
|
||||
savedata = options.get('savedata',False)
|
||||
|
||||
#try:
|
||||
# workouts = workouts.exclude(workoutsource='strava')
|
||||
#except AttributeError: # pragma: no cover
|
||||
# workouts = [w for w in workouts if w.workoutsource != 'strava']
|
||||
|
||||
fieldlist, fielddict = dataprep.getstatsfields()
|
||||
fieldlist = [xparam, yparam, groupby,
|
||||
@@ -566,6 +574,11 @@ def flexalldata(workouts, options):
|
||||
trendline = options['trendline']
|
||||
promember = True
|
||||
|
||||
#try:
|
||||
# workouts = workouts.exclude(workoutsource='strava')
|
||||
#except AttributeError: # pragma: no cover
|
||||
# workouts = [w for w in workouts if w.workoutsource != 'strava']
|
||||
|
||||
workstrokesonly = not includereststrokes
|
||||
|
||||
userid = options['userid']
|
||||
@@ -612,6 +625,12 @@ def histodata(workouts, options):
|
||||
workmax = options['workmax']
|
||||
userid = options['userid']
|
||||
|
||||
#try:
|
||||
# workouts = workouts.exclude(workoutsource='strava')
|
||||
#except AttributeError: # pragma: no cover
|
||||
# workouts = [w for w in workouts if w.workoutsource != 'strava']
|
||||
|
||||
|
||||
if userid == 0: # pragma: no cover
|
||||
extratitle = ''
|
||||
else:
|
||||
@@ -645,7 +664,8 @@ def cpdata(workouts, options):
|
||||
|
||||
u = User.objects.get(id=userid)
|
||||
r = u.rower
|
||||
|
||||
|
||||
|
||||
delta, cpvalue, avgpower, workoutnames, urls = dataprep.fetchcp_new(
|
||||
r, workouts)
|
||||
|
||||
@@ -798,6 +818,11 @@ def cpdata(workouts, options):
|
||||
|
||||
|
||||
def statsdata(workouts, options):
|
||||
#try:
|
||||
# workouts = workouts.exclude(workoutsource='strava')
|
||||
#except AttributeError: # pragma: no cover
|
||||
# workouts = [w for w in workouts if w.workoutsource != 'strava']
|
||||
|
||||
includereststrokes = options['includereststrokes']
|
||||
ids = options['ids']
|
||||
|
||||
@@ -872,12 +897,17 @@ def statsdata(workouts, options):
|
||||
|
||||
|
||||
def comparisondata(workouts, options):
|
||||
#try:
|
||||
# workouts = workouts.exclude(workoutsource='strava')
|
||||
#except AttributeError: # pragma: no cover
|
||||
# workouts = [w for w in workouts if w.workoutsource != 'strava']
|
||||
|
||||
includereststrokes = options['includereststrokes']
|
||||
xparam = options['xaxis']
|
||||
yparam1 = options['yaxis1']
|
||||
plottype = options['plottype']
|
||||
promember = True
|
||||
|
||||
|
||||
workstrokesonly = not includereststrokes
|
||||
|
||||
ids = [w.id for w in workouts]
|
||||
@@ -915,6 +945,10 @@ def comparisondata(workouts, options):
|
||||
|
||||
|
||||
def boxplotdata(workouts, options):
|
||||
#try:
|
||||
# workouts = workouts.exclude(workoutsource='strava')
|
||||
#except AttributeError:
|
||||
# workouts = [w for w in workouts if w.workoutsource != 'strava']
|
||||
|
||||
includereststrokes = options['includereststrokes']
|
||||
spmmin = options['spmmin']
|
||||
@@ -926,7 +960,7 @@ def boxplotdata(workouts, options):
|
||||
plotfield = options['plotfield']
|
||||
|
||||
workstrokesonly = not includereststrokes
|
||||
|
||||
|
||||
datemapping = {
|
||||
w.id: w.date for w in workouts
|
||||
}
|
||||
@@ -1020,11 +1054,15 @@ def analysis_view_data(request, userid=0):
|
||||
|
||||
for id in ids:
|
||||
try:
|
||||
workouts.append(Workout.objects.get(id=id))
|
||||
w = Workout.objects.get(id=id)
|
||||
#if w.workoutsource != 'strava':
|
||||
# workouts.append(w)
|
||||
workouts.append(w)
|
||||
except Workout.DoesNotExist: # pragma: no cover
|
||||
pass
|
||||
|
||||
|
||||
|
||||
if function == 'boxplot':
|
||||
script, div = boxplotdata(workouts, options)
|
||||
elif function == 'trendflex': # pragma: no cover
|
||||
@@ -1069,7 +1107,7 @@ def create_marker_workouts_view(request, userid=0,
|
||||
workouts = Workout.objects.filter(user=theuser.rower, date__gte=startdate,
|
||||
date__lte=enddate,
|
||||
workouttype__in=mytypes.rowtypes,
|
||||
duplicate=False).order_by('date')
|
||||
duplicate=False).order_by('date')#.exclude(workoutsource='strava')
|
||||
|
||||
for workout in workouts:
|
||||
_ = dataprep.check_marker(workout)
|
||||
@@ -1113,7 +1151,7 @@ def goldmedalscores_view(request, userid=0,
|
||||
theuser, startdate=startdate, enddate=enddate,
|
||||
)
|
||||
|
||||
bestworkouts = Workout.objects.filter(id__in=ids).order_by('-date')
|
||||
bestworkouts = Workout.objects.filter(id__in=ids).order_by('-date')#.exclude(workoutsource='strava')
|
||||
|
||||
breadcrumbs = [
|
||||
{
|
||||
@@ -1311,7 +1349,7 @@ def performancemanager_view(request, userid=0, mode='rower',
|
||||
user = therower, date__gte=startdate-datetime.timedelta(days=90),
|
||||
date__lte=enddate,
|
||||
duplicate=False,
|
||||
rankingpiece=True, workouttype__in=mytypes.rowtypes).order_by('date')
|
||||
rankingpiece=True, workouttype__in=mytypes.rowtypes).order_by('date')#.exclude(workoutsource='strava')
|
||||
|
||||
ids = [w.id for w in markerworkouts]
|
||||
form = PerformanceManagerForm(initial={
|
||||
@@ -1323,7 +1361,7 @@ def performancemanager_view(request, userid=0, mode='rower',
|
||||
|
||||
ids = pd.Series(ids, dtype='int').dropna().values
|
||||
|
||||
bestworkouts = Workout.objects.filter(id__in=ids).order_by('-date')
|
||||
bestworkouts = Workout.objects.filter(id__in=ids).order_by('-date')#.exclude(workoutsource='strava')
|
||||
|
||||
breadcrumbs = [
|
||||
{
|
||||
@@ -2276,6 +2314,8 @@ def history_view_data(request, userid=0):
|
||||
ddf = ddf.with_columns(pl.col("time").diff().clip(lower_bound=0).alias("deltat"))
|
||||
except KeyError: # pragma: no cover
|
||||
pass
|
||||
except ColumnNotFoundError:
|
||||
pass
|
||||
|
||||
ddf = dataprep.clean_df_stats_pl(ddf, workstrokesonly=False,
|
||||
ignoreadvanced=True)
|
||||
@@ -2288,6 +2328,8 @@ def history_view_data(request, userid=0):
|
||||
ddict['hrmax'] = int(ddf['hr'].max())
|
||||
except (KeyError, ValueError, AttributeError, ColumnNotFoundError): # pragma: no cover
|
||||
ddict['hrmax'] = 0
|
||||
except ColumnNotFoundError:
|
||||
ddict['hrmax'] = 0
|
||||
|
||||
ddict['powermean'] = int(wavg(ddf, 'power', 'deltat'))
|
||||
try:
|
||||
|
||||
@@ -3397,12 +3397,12 @@ def virtualevent_submit_result_view(request, id=0, workoutid=0):
|
||||
startdatetime__gte=startdatetime,
|
||||
startdatetime__lte=enddatetime,
|
||||
distance__gte=race.approximate_distance,
|
||||
).order_by("-date", "-startdatetime", "id")
|
||||
).order_by("-date", "-startdatetime", "id").exclude(workoutsource='strava')
|
||||
|
||||
if not ws: # pragma: no cover
|
||||
messages.info(
|
||||
request,
|
||||
'You have no workouts executed during the race window. Please upload a result or enter it manually.'
|
||||
'You have no eligible workouts executed during the race window. Please upload a result or enter it manually.'
|
||||
)
|
||||
|
||||
url = reverse('virtualevent_view',
|
||||
@@ -3436,6 +3436,7 @@ def virtualevent_submit_result_view(request, id=0, workoutid=0):
|
||||
splitsecond = 0
|
||||
recordid = w_form.cleaned_data['record']
|
||||
else:
|
||||
messages.error(request,"Error in form")
|
||||
selectedworkout = None
|
||||
|
||||
if selectedworkout is not None:
|
||||
@@ -3518,7 +3519,12 @@ def virtualevent_submit_result_view(request, id=0, workoutid=0):
|
||||
|
||||
else:
|
||||
if workoutid:
|
||||
workoutdata['initial'] = encoder.decode_hex(workoutid)
|
||||
try:
|
||||
w = Workout.objects.get(id=workoutid)
|
||||
if w.workoutsource != 'strava':
|
||||
workoutdata['initial'] = encoder.decode_hex(workoutid)
|
||||
except Workout.DoesNotExist:
|
||||
pass
|
||||
w_form = WorkoutRaceSelectForm(workoutdata, entries)
|
||||
|
||||
breadcrumbs = [
|
||||
|
||||
@@ -28,6 +28,7 @@ from rest_framework.response import Response
|
||||
from rq.job import Job
|
||||
from rules.contrib.views import permission_required, objectgetter
|
||||
from django.core.cache import cache
|
||||
from django.db import models
|
||||
from django.utils.crypto import get_random_string
|
||||
from rq.registry import StartedJobRegistry
|
||||
from rq.exceptions import NoSuchJobError
|
||||
@@ -81,7 +82,8 @@ from rowers.rower_rules import (
|
||||
can_add_workout_member, can_plan_user, is_paid_coach,
|
||||
can_start_trial, can_start_plantrial, can_start_coachtrial,
|
||||
can_plan, is_workout_team,
|
||||
is_promember,user_is_basic, is_coachtrial, is_coach
|
||||
is_promember,user_is_basic, is_coachtrial, is_coach,
|
||||
workout_is_strava
|
||||
)
|
||||
|
||||
from django.shortcuts import render
|
||||
@@ -179,7 +181,13 @@ from rowers.models import ( RowerPowerForm, RowerHRZonesForm, SimpleRowerPowerFo
|
||||
IndoorVirtualRaceForm, PlannedSessionCommentForm, Alert,
|
||||
Condition, StaticChartRowerForm, FollowerForm,
|
||||
VirtualRaceAthleteForm, InstantPlanForm, DataRowerForm,
|
||||
StepEditorForm, iDokladToken )
|
||||
StepEditorForm, iDokladToken,
|
||||
RowerExportFormStrava, RowerExportFormPolar,
|
||||
RowerExportFormSportTracks, RowerExportFormTrainingPeaks,
|
||||
RowerExportFormConcept2, RowerExportFormGarmin,
|
||||
RowerExportFormIntervals, RowerExportFormRP3,
|
||||
RowerExportFormNK,
|
||||
)
|
||||
from rowers.models import (
|
||||
FavoriteForm, BaseFavoriteFormSet, SiteAnnouncement, BasePlannedSessionFormSet,
|
||||
get_course_timezone, BaseConditionFormSet,
|
||||
|
||||
@@ -279,7 +279,6 @@ def user_message_delete(request,id=0): # pragma: no cover
|
||||
messages.error(request,'Could not find this message')
|
||||
url = reverse('user_messages')
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
|
||||
if msg.receiver == request.user.rower:
|
||||
msg.delete()
|
||||
@@ -458,19 +457,43 @@ def rower_exportsettings_view(request, userid=0):
|
||||
'polar_auto_import': 'polartoken',
|
||||
'c2_auto_export': 'c2token',
|
||||
'c2_auto_import': 'c2token',
|
||||
'runkeeper_auto_export': 'runkeepertoken',
|
||||
'sporttracks_auto_export': 'sporttrackstoken',
|
||||
'strava_auto_export': 'stravatoken',
|
||||
'strava_auto_import': 'stravatoken',
|
||||
'strava_auto_delete': 'stravatoken',
|
||||
'trainingpeaks_auto_export': 'tptoken',
|
||||
'rp3_auto_import': 'rp3token',
|
||||
'nk_auto_import': 'nktoken'
|
||||
'nk_auto_import': 'nktoken',
|
||||
'intervals_auto_export': 'intervals_token',
|
||||
'intervals_resample_to_1s': 'intervals_token',
|
||||
}
|
||||
r = getrequestrowercoachee(request, userid=userid)
|
||||
|
||||
forms = {
|
||||
'polar': RowerExportFormPolar(instance=r),
|
||||
'c2': RowerExportFormConcept2(instance=r),
|
||||
'sporttracks': RowerExportFormSportTracks(instance=r),
|
||||
'strava': RowerExportFormStrava(instance=r),
|
||||
'trainingpeaks': RowerExportFormTrainingPeaks(instance=r),
|
||||
'rp3': RowerExportFormRP3(instance=r),
|
||||
'intervals': RowerExportFormIntervals(instance=r),
|
||||
'nk': RowerExportFormNK(instance=r),
|
||||
'garmin': RowerExportFormGarmin(instance=r),
|
||||
}
|
||||
|
||||
if request.method == 'POST':
|
||||
form = RowerExportForm(request.POST)
|
||||
forms = {
|
||||
'polar': RowerExportFormPolar(request.POST, instance=r),
|
||||
'c2': RowerExportFormConcept2(request.POST, instance=r),
|
||||
'sporttracks': RowerExportFormSportTracks(request.POST, instance=r),
|
||||
'strava': RowerExportFormStrava(request.POST, instance=r),
|
||||
'trainingpeaks': RowerExportFormTrainingPeaks(request.POST, instance=r),
|
||||
'rp3': RowerExportFormRP3(request.POST, instance=r),
|
||||
'intervals': RowerExportFormIntervals(request.POST, instance=r),
|
||||
'nk': RowerExportFormNK(request.POST, instance=r),
|
||||
'garmin': RowerExportFormGarmin(request.POST, instance=r),
|
||||
}
|
||||
if form.is_valid():
|
||||
cd = form.cleaned_data
|
||||
if r.rowerplan == 'basic': # pragma: no cover
|
||||
@@ -529,6 +552,7 @@ def rower_exportsettings_view(request, userid=0):
|
||||
|
||||
return render(request, 'rower_exportsettings.html',
|
||||
{'form': form,
|
||||
'forms': forms,
|
||||
'rower': r,
|
||||
'breadcrumbs': breadcrumbs,
|
||||
'grants': grants,
|
||||
|
||||
@@ -2204,25 +2204,25 @@ def workouts_view(request, message='', successmessage='',
|
||||
team=theteam,
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate,
|
||||
privacy='visible').order_by("-date", "-starttime")
|
||||
privacy='visible').order_by("-date", "-starttime").exclude(workoutsource='strava')
|
||||
g_workouts = Workout.objects.filter(
|
||||
team=theteam,
|
||||
startdatetime__gte=activity_startdate,
|
||||
startdatetime__lte=activity_enddate,
|
||||
duplicate=False,
|
||||
privacy='visible').order_by("-date", "-starttime")
|
||||
privacy='visible').order_by("-date", "-starttime").exclude(workoutsource='strava')
|
||||
elif theteam.viewing == 'coachonly': # pragma: no cover
|
||||
workouts = Workout.objects.filter(
|
||||
team=theteam, user=r,
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate,
|
||||
privacy='visible').order_by("-startdatetime")
|
||||
privacy='visible').order_by("-startdatetime").exclude(workoutsource='strava')
|
||||
g_workouts = Workout.objects.filter(
|
||||
team=theteam, user=r,
|
||||
startdatetime__gte=activity_startdate,
|
||||
startdatetime__lte=activity_enddate,
|
||||
duplicate=False,
|
||||
privacy='visible').order_by("-startdatetime")
|
||||
privacy='visible').order_by("-startdatetime").exclude(workoutsource='strava')
|
||||
|
||||
elif request.user != r.user:
|
||||
theteam = None
|
||||
@@ -2230,13 +2230,13 @@ def workouts_view(request, message='', successmessage='',
|
||||
user=r,
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate,
|
||||
privacy='visible').order_by("-date", "-starttime")
|
||||
privacy='visible').order_by("-date", "-starttime").exclude(workoutsource='strava')
|
||||
g_workouts = Workout.objects.filter(
|
||||
user=r,
|
||||
startdatetime__gte=activity_startdate,
|
||||
startdatetime__lte=activity_enddate,
|
||||
duplicate=False,
|
||||
privacy='visible').order_by("-startdatetime")
|
||||
privacy='visible').order_by("-startdatetime").exclude(workoutsource='strava')
|
||||
else:
|
||||
theteam = None
|
||||
workouts = Workout.objects.filter(
|
||||
@@ -2252,7 +2252,7 @@ def workouts_view(request, message='', successmessage='',
|
||||
if g_workouts.count() == 0:
|
||||
g_workouts = Workout.objects.filter(
|
||||
user=r,
|
||||
startdatetime__gte=timezone.now()-timedelta(days=15)).order_by("-startdatetime")
|
||||
startdatetime__gte=timezone.now()-timedelta(days=15)).order_by("-startdatetime").exclude(workoutsource='strava')
|
||||
g_enddate = timezone.now()
|
||||
g_startdate = (timezone.now()-timedelta(days=15))
|
||||
|
||||
@@ -2266,7 +2266,8 @@ def workouts_view(request, message='', successmessage='',
|
||||
reduce(operator.and_,
|
||||
(Q(name__icontains=q) for q in query_list)) |
|
||||
reduce(operator.and_,
|
||||
(Q(notes__icontains=q) for q in query_list))
|
||||
(Q(notes__icontains=q) for q in query_list)),
|
||||
exclude_strava=False,
|
||||
)
|
||||
searchform = SearchForm(initial={'q': query})
|
||||
else:
|
||||
@@ -4699,6 +4700,7 @@ def workout_map_view(request, id=0):
|
||||
u = w.user.user
|
||||
r = getrower(u)
|
||||
rowdata = rdata(csvfile=f1)
|
||||
|
||||
hascoordinates = 1
|
||||
if rowdata != 0:
|
||||
try:
|
||||
@@ -4933,7 +4935,7 @@ def workout_upload_api(request):
|
||||
|
||||
# only allow local host
|
||||
hostt = request.get_host().split(':')
|
||||
if hostt[0] not in ['localhost', '127.0.0.1', 'dev.rowsandall.com', 'rowsandall.com']:
|
||||
if hostt[0] not in ['localhost', '127.0.0.1', 'dev.rowsandall.com', 'rowsandall.com','testserver']:
|
||||
message = {'status': 'false',
|
||||
'message': 'permission denied for host '+hostt[0]}
|
||||
return JSONResponse(status=403, data=message)
|
||||
@@ -4986,6 +4988,7 @@ def workout_upload_api(request):
|
||||
boatname = post_data.get('boatName','')
|
||||
portStarboard = post_data.get('portStarboard', 1)
|
||||
empowerside = 'port'
|
||||
stravaid = post_data.get('stravaid','')
|
||||
if portStarboard == 1:
|
||||
empowerside = 'starboard'
|
||||
|
||||
@@ -5609,17 +5612,6 @@ def workout_upload_view(request,
|
||||
return response
|
||||
else:
|
||||
if not is_ajax:
|
||||
if r.c2_auto_export and ispromember(r.user): # pragma: no cover
|
||||
uploadoptions['upload_to_C2'] = True
|
||||
|
||||
if r.strava_auto_export and ispromember(r.user): # pragma: no cover
|
||||
uploadoptions['upload_to_Strava'] = True
|
||||
|
||||
if r.sporttracks_auto_export and ispromember(r.user): # pragma: no cover
|
||||
uploadoptions['upload_to_SportTracks'] = True
|
||||
|
||||
if r.trainingpeaks_auto_export and ispromember(r.user): # pragma: no cover
|
||||
uploadoptions['upload_to_TrainingPeaks'] = True
|
||||
|
||||
form = DocumentsForm(initial=docformoptions)
|
||||
optionsform = UploadOptionsForm(initial=uploadoptions,
|
||||
|
||||
Reference in New Issue
Block a user