bug fixes - loading nonexisting workout
This commit is contained in:
@@ -447,8 +447,12 @@ def get_username(access_token):
|
|||||||
|
|
||||||
me_json = response.json()
|
me_json = response.json()
|
||||||
|
|
||||||
|
try:
|
||||||
|
res = me_json['data']['username']
|
||||||
|
except KeyError:
|
||||||
|
res = None
|
||||||
|
|
||||||
return me_json['data']['username']
|
return res
|
||||||
|
|
||||||
# Get user id, having access token
|
# Get user id, having access token
|
||||||
# Handy for checking if the API access is working
|
# Handy for checking if the API access is working
|
||||||
|
|||||||
@@ -9,12 +9,11 @@
|
|||||||
<div class="grid_12">
|
<div class="grid_12">
|
||||||
<h1>Error 500 Internal Server Error</h1>
|
<h1>Error 500 Internal Server Error</h1>
|
||||||
<p>
|
<p>
|
||||||
The site reported an internal server error. If this behavior repeats, please inform us by using the contact form at the bottom of this page. This allows us to improve the site's behaviour.
|
The site reported an internal server error. The site developer has been
|
||||||
|
notified automatically with a full error report. You can help the developer
|
||||||
|
by reporting an issue on Bitbucket using the button below.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
|
||||||
You can also report an issue on the Rowsandall Bitbucket issue list:
|
|
||||||
</p>
|
|
||||||
<div class="grid_2 alpha">
|
<div class="grid_2 alpha">
|
||||||
<a class="button red small" href="https://bitbucket.org/sanderroosendaal/rowsandall/issues/new">Report an issue</a>
|
<a class="button red small" href="https://bitbucket.org/sanderroosendaal/rowsandall/issues/new">Report an issue</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
1
rowers/testdata/c2strokedatanohr.txt
vendored
Normal file
1
rowers/testdata/c2strokedatanohr.txt
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -64,6 +64,27 @@ class C2Objects(DjangoTestCase):
|
|||||||
|
|
||||||
res = add_workout_from_strokedata(u,1,data,strokedata,source='c2')
|
res = add_workout_from_strokedata(u,1,data,strokedata,source='c2')
|
||||||
|
|
||||||
|
def test_strokedatanohr(self):
|
||||||
|
with open('rowers/testdata/c2strokedatanohr.txt','r') as infile:
|
||||||
|
res = json.load(infile)
|
||||||
|
|
||||||
|
strokedata = pd.DataFrame.from_dict(res['data'])
|
||||||
|
|
||||||
|
with open('rowers/testdata/c2testdata.txt','r') as infile:
|
||||||
|
res = json.load(infile)
|
||||||
|
|
||||||
|
data = res['data']
|
||||||
|
|
||||||
|
from rowers.views import add_workout_from_strokedata
|
||||||
|
|
||||||
|
u = User.objects.create_user('john',
|
||||||
|
'sander@ds.ds',
|
||||||
|
'koeinsloot')
|
||||||
|
r = Rower.objects.create(user=u)
|
||||||
|
|
||||||
|
res = add_workout_from_strokedata(u,1,data,strokedata,source='c2')
|
||||||
|
|
||||||
|
|
||||||
class StravaObjects(DjangoTestCase):
|
class StravaObjects(DjangoTestCase):
|
||||||
def test_strokedata(self):
|
def test_strokedata(self):
|
||||||
timejson = json.load(open('rowers/testdata/stravatimetestdata.txt','r'))
|
timejson = json.load(open('rowers/testdata/stravatimetestdata.txt','r'))
|
||||||
|
|||||||
148
rowers/views.py
148
rowers/views.py
@@ -9,7 +9,7 @@ from django.shortcuts import render
|
|||||||
from django.http import (
|
from django.http import (
|
||||||
HttpResponse, HttpResponseRedirect,
|
HttpResponse, HttpResponseRedirect,
|
||||||
HttpResponseForbidden, HttpResponseNotAllowed,
|
HttpResponseForbidden, HttpResponseNotAllowed,
|
||||||
HttpResponseNotFound,
|
HttpResponseNotFound,Http404
|
||||||
)
|
)
|
||||||
from django.contrib.auth import authenticate, login, logout
|
from django.contrib.auth import authenticate, login, logout
|
||||||
from rowers.forms import LoginForm,DocumentsForm,UploadOptionsForm
|
from rowers.forms import LoginForm,DocumentsForm,UploadOptionsForm
|
||||||
@@ -382,7 +382,10 @@ def add_workout_from_strokedata(user,importid,data,strokedata,
|
|||||||
dist2 = 0.1*strokedata.ix[:,'d']
|
dist2 = 0.1*strokedata.ix[:,'d']
|
||||||
|
|
||||||
spm = strokedata.ix[:,'spm']
|
spm = strokedata.ix[:,'spm']
|
||||||
|
try:
|
||||||
hr = strokedata.ix[:,'hr']
|
hr = strokedata.ix[:,'hr']
|
||||||
|
except KeyError:
|
||||||
|
hr = 0*spm
|
||||||
pace = strokedata.ix[:,'p']/10.
|
pace = strokedata.ix[:,'p']/10.
|
||||||
pace = np.clip(pace,0,1e4)
|
pace = np.clip(pace,0,1e4)
|
||||||
pace = pace.replace(0,300)
|
pace = pace.replace(0,300)
|
||||||
@@ -791,7 +794,10 @@ def workout_tcxemail_view(request,id=0):
|
|||||||
message = ""
|
message = ""
|
||||||
successmessage = ""
|
successmessage = ""
|
||||||
r = Rower.objects.get(user=request.user)
|
r = Rower.objects.get(user=request.user)
|
||||||
|
try:
|
||||||
w = Workout.objects.get(id=id)
|
w = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
if (checkworkoutuser(request.user,w)):
|
if (checkworkoutuser(request.user,w)):
|
||||||
try:
|
try:
|
||||||
tcxfile = stravastuff.createstravaworkoutdata(w)
|
tcxfile = stravastuff.createstravaworkoutdata(w)
|
||||||
@@ -843,7 +849,10 @@ def workout_tcxemail_view(request,id=0):
|
|||||||
def workout_csvemail_view(request,id=0):
|
def workout_csvemail_view(request,id=0):
|
||||||
message = ""
|
message = ""
|
||||||
r = Rower.objects.get(user=request.user)
|
r = Rower.objects.get(user=request.user)
|
||||||
|
try:
|
||||||
w = Workout.objects.get(id=id)
|
w = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
if (checkworkoutuser(request.user,w)):
|
if (checkworkoutuser(request.user,w)):
|
||||||
csvfile = w.csvfilename
|
csvfile = w.csvfilename
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
@@ -887,7 +896,10 @@ def workout_strava_upload_view(request,id=0):
|
|||||||
return HttpResponseRedirect("/rowers/me/stravaauthorize/")
|
return HttpResponseRedirect("/rowers/me/stravaauthorize/")
|
||||||
else:
|
else:
|
||||||
# ready to upload. Hurray
|
# ready to upload. Hurray
|
||||||
|
try:
|
||||||
w = Workout.objects.get(id=id)
|
w = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
if (checkworkoutuser(request.user,w)):
|
if (checkworkoutuser(request.user,w)):
|
||||||
try:
|
try:
|
||||||
tcxfile = stravastuff.createstravaworkoutdata(w)
|
tcxfile = stravastuff.createstravaworkoutdata(w)
|
||||||
@@ -980,9 +992,15 @@ def workout_c2_upload_view(request,id=0):
|
|||||||
return HttpResponseRedirect("/rowers/me/c2authorize/")
|
return HttpResponseRedirect("/rowers/me/c2authorize/")
|
||||||
|
|
||||||
# ready to upload. Hurray
|
# ready to upload. Hurray
|
||||||
|
try:
|
||||||
w = Workout.objects.get(id=id)
|
w = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
if (checkworkoutuser(request.user,w)):
|
if (checkworkoutuser(request.user,w)):
|
||||||
c2userid = c2stuff.get_userid(thetoken)
|
c2userid = c2stuff.get_userid(thetoken)
|
||||||
|
if not c2userid:
|
||||||
|
return HttpResponseRedirect("/rowers/me/c2authorize")
|
||||||
|
|
||||||
data = c2stuff.createc2workoutdata(w)
|
data = c2stuff.createc2workoutdata(w)
|
||||||
authorizationstring = str('Bearer ' + thetoken)
|
authorizationstring = str('Bearer ' + thetoken)
|
||||||
headers = {'Authorization': authorizationstring,
|
headers = {'Authorization': authorizationstring,
|
||||||
@@ -1049,7 +1067,11 @@ def workout_sporttracks_upload_view(request,id=0):
|
|||||||
return HttpResponseRedirect("/rowers/me/sporttracksauthorize/")
|
return HttpResponseRedirect("/rowers/me/sporttracksauthorize/")
|
||||||
|
|
||||||
# ready to upload. Hurray
|
# ready to upload. Hurray
|
||||||
|
try:
|
||||||
w = Workout.objects.get(id=id)
|
w = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,w)):
|
if (checkworkoutuser(request.user,w)):
|
||||||
data = sporttracksstuff.createsporttracksworkoutdata(w)
|
data = sporttracksstuff.createsporttracksworkoutdata(w)
|
||||||
if not data:
|
if not data:
|
||||||
@@ -1473,7 +1495,11 @@ def cum_flex(request,theuser=0,
|
|||||||
# Show the EMpower Oarlock generated Stroke Profile
|
# Show the EMpower Oarlock generated Stroke Profile
|
||||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
def workout_forcecurve_view(request,id=0,workstrokesonly=False):
|
def workout_forcecurve_view(request,id=0,workstrokesonly=False):
|
||||||
|
try:
|
||||||
row = Workout.objects.get(id=id)
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
promember=0
|
promember=0
|
||||||
mayedit=0
|
mayedit=0
|
||||||
if not request.user.is_anonymous():
|
if not request.user.is_anonymous():
|
||||||
@@ -1512,7 +1538,11 @@ def workout_forcecurve_view(request,id=0,workstrokesonly=False):
|
|||||||
# Show Stroke power histogram for a workout
|
# Show Stroke power histogram for a workout
|
||||||
@login_required()
|
@login_required()
|
||||||
def workout_histo_view(request,id=0):
|
def workout_histo_view(request,id=0):
|
||||||
|
try:
|
||||||
row = Workout.objects.get(id=id)
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
promember=0
|
promember=0
|
||||||
mayedit=0
|
mayedit=0
|
||||||
if not request.user.is_anonymous():
|
if not request.user.is_anonymous():
|
||||||
@@ -1948,7 +1978,11 @@ def rankings_view(request,theuser=0,
|
|||||||
# Reload the workout and calculate the summary from the stroke data (lapIDx)
|
# Reload the workout and calculate the summary from the stroke data (lapIDx)
|
||||||
@login_required()
|
@login_required()
|
||||||
def workout_recalcsummary_view(request,id=0):
|
def workout_recalcsummary_view(request,id=0):
|
||||||
|
try:
|
||||||
row = Workout.objects.get(id=id)
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,row)==False):
|
if (checkworkoutuser(request.user,row)==False):
|
||||||
message = "You are not allowed to edit this workout"
|
message = "You are not allowed to edit this workout"
|
||||||
url = reverse(workouts_view,args=[str(message)])
|
url = reverse(workouts_view,args=[str(message)])
|
||||||
@@ -2105,8 +2139,11 @@ def workout_comparison_list(request,id=0,message='',successmessage='',
|
|||||||
workouts = paginator.page(1)
|
workouts = paginator.page(1)
|
||||||
except EmptyPage:
|
except EmptyPage:
|
||||||
workouts = paginator.page(paginator.num_pages)
|
workouts = paginator.page(paginator.num_pages)
|
||||||
|
try:
|
||||||
row = Workout.objects.get(id=id)
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
|
|
||||||
return render(request, 'comparison_list.html',
|
return render(request, 'comparison_list.html',
|
||||||
{'id':id,
|
{'id':id,
|
||||||
@@ -2160,12 +2197,16 @@ def workout_view(request,id=0):
|
|||||||
'the_div':div})
|
'the_div':div})
|
||||||
|
|
||||||
|
|
||||||
except Workout.DoesNotExist:
|
except Workout.DoesNotExist:
|
||||||
raise Http404("Workout doesn't exist")
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
# Resets stroke data to raw data (pace)
|
# Resets stroke data to raw data (pace)
|
||||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
|
def workout_undo_smoothenpace_view(request,id=0,message="",successmessage=""):
|
||||||
try:
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,row)==False):
|
if (checkworkoutuser(request.user,row)==False):
|
||||||
message = "You are not allowed to edit this workout"
|
message = "You are not allowed to edit this workout"
|
||||||
@@ -2192,7 +2233,11 @@ def workout_undo_smoothenpace_view(request,id=0,message="",successmessage=""):
|
|||||||
|
|
||||||
# Data smoothing of pace data
|
# Data smoothing of pace data
|
||||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
|
def workout_smoothenpace_view(request,id=0,message="",successmessage=""):
|
||||||
try:
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,row)==False):
|
if (checkworkoutuser(request.user,row)==False):
|
||||||
message = "You are not allowed to edit this workout"
|
message = "You are not allowed to edit this workout"
|
||||||
@@ -2228,7 +2273,11 @@ def workout_smoothenpace_view(request,id=0,message="",successmessage=""):
|
|||||||
|
|
||||||
# Process CrewNerd Summary CSV and update summary
|
# Process CrewNerd Summary CSV and update summary
|
||||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
|
def workout_crewnerd_summary_view(request,id=0,message="",successmessage=""):
|
||||||
try:
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = CNsummaryForm(request.POST,request.FILES)
|
form = CNsummaryForm(request.POST,request.FILES)
|
||||||
@@ -2273,7 +2322,11 @@ def workout_crewnerd_summary_view(request,id=0,message="",successmessage=""):
|
|||||||
|
|
||||||
# Get weather for given location and date/time
|
# Get weather for given location and date/time
|
||||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
|
def workout_downloadwind_view(request,id=0,message="",successmessage=""):
|
||||||
try:
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
f1 = row.csvfilename
|
f1 = row.csvfilename
|
||||||
if (checkworkoutuser(request.user,row)==False):
|
if (checkworkoutuser(request.user,row)==False):
|
||||||
@@ -2330,7 +2383,11 @@ def workout_downloadwind_view(request,id=0,message="",successmessage=""):
|
|||||||
|
|
||||||
# Show form to update wind data
|
# Show form to update wind data
|
||||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
|
def workout_wind_view(request,id=0,message="",successmessage=""):
|
||||||
try:
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,row)==False):
|
if (checkworkoutuser(request.user,row)==False):
|
||||||
message = "You are not allowed to edit this workout"
|
message = "You are not allowed to edit this workout"
|
||||||
@@ -2430,7 +2487,11 @@ def workout_wind_view(request,id=0,message="",successmessage=""):
|
|||||||
|
|
||||||
# Show form to update River stream data (for river dwellers)
|
# Show form to update River stream data (for river dwellers)
|
||||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
|
def workout_stream_view(request,id=0,message="",successmessage=""):
|
||||||
try:
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,row)==False):
|
if (checkworkoutuser(request.user,row)==False):
|
||||||
message = "You are not allowed to edit this workout"
|
message = "You are not allowed to edit this workout"
|
||||||
@@ -2492,7 +2553,11 @@ def workout_stream_view(request,id=0,message="",successmessage=""):
|
|||||||
|
|
||||||
# Form to set average crew weight and boat type, then run power calcs
|
# Form to set average crew weight and boat type, then run power calcs
|
||||||
@user_passes_test(ispromember, login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember, login_url="/",redirect_field_name=None)
|
||||||
|
def workout_otwsetpower_view(request,id=0,message="",successmessage=""):
|
||||||
try:
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,row)==False):
|
if (checkworkoutuser(request.user,row)==False):
|
||||||
message = "You are not allowed to edit this workout"
|
message = "You are not allowed to edit this workout"
|
||||||
@@ -2578,7 +2643,11 @@ def workout_otwsetpower_view(request,id=0,message="",successmessage=""):
|
|||||||
|
|
||||||
# A special Edit page with all the Geeky functionality for the workout
|
# A special Edit page with all the Geeky functionality for the workout
|
||||||
@login_required()
|
@login_required()
|
||||||
|
def workout_geeky_view(request,id=0,message="",successmessage=""):
|
||||||
try:
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
form = WorkoutForm(instance=row)
|
form = WorkoutForm(instance=row)
|
||||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||||
@@ -2892,7 +2961,10 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
|
|||||||
|
|
||||||
# The Advanced edit page
|
# The Advanced edit page
|
||||||
@login_required()
|
@login_required()
|
||||||
|
def workout_advanced_view(request,id=0,message="",successmessage=""):
|
||||||
try:
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
raise Http404("Workout doesn't exist")
|
raise Http404("Workout doesn't exist")
|
||||||
form = WorkoutForm(instance=row)
|
form = WorkoutForm(instance=row)
|
||||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||||
@@ -3008,8 +3080,11 @@ def workout_flexchart3_view(request,*args,**kwargs):
|
|||||||
except:
|
except:
|
||||||
favoritenr = 0
|
favoritenr = 0
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
promember=0
|
promember=0
|
||||||
mayedit=0
|
mayedit=0
|
||||||
@@ -3156,7 +3231,11 @@ def workout_flexchart3_view(request,*args,**kwargs):
|
|||||||
|
|
||||||
|
|
||||||
# The interactive plot with the colored Heart rate zones
|
# The interactive plot with the colored Heart rate zones
|
||||||
|
def workout_biginteractive_view(request,id=0,message="",successmessage=""):
|
||||||
try:
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
# check if user is owner of this workout
|
# check if user is owner of this workout
|
||||||
|
|
||||||
@@ -3193,7 +3272,11 @@ def workout_biginteractive_view(request,id=0,message="",successmessage=""):
|
|||||||
'mayedit':mayedit})
|
'mayedit':mayedit})
|
||||||
|
|
||||||
# The interactive plot with wind corrected pace for OTW outings
|
# The interactive plot with wind corrected pace for OTW outings
|
||||||
|
def workout_otwpowerplot_view(request,id=0,message="",successmessage=""):
|
||||||
try:
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
# check if user is owner of this workout
|
# check if user is owner of this workout
|
||||||
|
|
||||||
@@ -3231,8 +3314,11 @@ def workout_otwpowerplot_view(request,id=0,message="",successmessage=""):
|
|||||||
# the page where you can chose where to export this workout
|
# the page where you can chose where to export this workout
|
||||||
@login_required()
|
@login_required()
|
||||||
def workout_export_view(request,id=0, message="", successmessage=""):
|
def workout_export_view(request,id=0, message="", successmessage=""):
|
||||||
request.session[translation.LANGUAGE_SESSION_KEY] = USER_LANGUAGE
|
request.session[translation.LANGUAGE_SESSION_KEY] = USER_LANGUAGE
|
||||||
try:
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
form = WorkoutForm(instance=row)
|
form = WorkoutForm(instance=row)
|
||||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||||
@@ -3410,7 +3496,11 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
|
|
||||||
# Create the chart image with wind corrected pace (OTW)
|
# Create the chart image with wind corrected pace (OTW)
|
||||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
|
def workout_add_otw_powerplot_view(request,id):
|
||||||
try:
|
try:
|
||||||
|
w = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,w)==False):
|
if (checkworkoutuser(request.user,w)==False):
|
||||||
return HttpResponse("You are not allowed add plots to this workout")
|
return HttpResponse("You are not allowed add plots to this workout")
|
||||||
@@ -3463,7 +3553,11 @@ def workout_add_otw_powerplot_view(request,id):
|
|||||||
|
|
||||||
# Create the Heart rate zone pie chart
|
# Create the Heart rate zone pie chart
|
||||||
@login_required()
|
@login_required()
|
||||||
|
def workout_add_piechart_view(request,id):
|
||||||
try:
|
try:
|
||||||
|
w = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,w)==False):
|
if (checkworkoutuser(request.user,w)==False):
|
||||||
return HttpResponse("You are not allowed add plots to this workout")
|
return HttpResponse("You are not allowed add plots to this workout")
|
||||||
@@ -3517,7 +3611,11 @@ def workout_add_piechart_view(request,id):
|
|||||||
|
|
||||||
# Create the Power zone pie chart
|
# Create the Power zone pie chart
|
||||||
@login_required()
|
@login_required()
|
||||||
|
def workout_add_power_piechart_view(request,id):
|
||||||
try:
|
try:
|
||||||
|
w = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,w)==False):
|
if (checkworkoutuser(request.user,w)==False):
|
||||||
return HttpResponse("You are not allowed add plots to this workout")
|
return HttpResponse("You are not allowed add plots to this workout")
|
||||||
@@ -3569,7 +3667,11 @@ def workout_add_power_piechart_view(request,id):
|
|||||||
|
|
||||||
# Create the time based summary chart
|
# Create the time based summary chart
|
||||||
@login_required()
|
@login_required()
|
||||||
|
def workout_add_timeplot_view(request,id):
|
||||||
try:
|
try:
|
||||||
|
w = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,w)==False):
|
if (checkworkoutuser(request.user,w)==False):
|
||||||
return HttpResponse("You are not allowed add plots to this workout")
|
return HttpResponse("You are not allowed add plots to this workout")
|
||||||
@@ -3622,7 +3724,11 @@ def workout_add_timeplot_view(request,id):
|
|||||||
|
|
||||||
# Create the distance based summary chart
|
# Create the distance based summary chart
|
||||||
@login_required()
|
@login_required()
|
||||||
|
def workout_add_distanceplot_view(request,id):
|
||||||
try:
|
try:
|
||||||
|
w = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,w)==False):
|
if (checkworkoutuser(request.user,w)==False):
|
||||||
return HttpResponse("You are not allowed add plots to this workout")
|
return HttpResponse("You are not allowed add plots to this workout")
|
||||||
@@ -3673,7 +3779,11 @@ def workout_add_distanceplot_view(request,id):
|
|||||||
|
|
||||||
# Create the advanced parameters distance overview chart
|
# Create the advanced parameters distance overview chart
|
||||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
|
def workout_add_distanceplot2_view(request,id):
|
||||||
try:
|
try:
|
||||||
|
w = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,w)==False):
|
if (checkworkoutuser(request.user,w)==False):
|
||||||
return HttpResponse("You are not allowed add plots to this workout")
|
return HttpResponse("You are not allowed add plots to this workout")
|
||||||
@@ -3726,7 +3836,11 @@ def workout_add_distanceplot2_view(request,id):
|
|||||||
|
|
||||||
# Create the advanced parameters time based overview chart
|
# Create the advanced parameters time based overview chart
|
||||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
|
def workout_add_timeplot2_view(request,id):
|
||||||
try:
|
try:
|
||||||
|
w = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,w)==False):
|
if (checkworkoutuser(request.user,w)==False):
|
||||||
return HttpResponse("You are not allowed add plots to this workout")
|
return HttpResponse("You are not allowed add plots to this workout")
|
||||||
@@ -3935,7 +4049,11 @@ def workout_getstravaworkout_view(request,stravaid):
|
|||||||
strokedata = res[1]
|
strokedata = res[1]
|
||||||
data = res[0]
|
data = res[0]
|
||||||
id = add_workout_from_strokedata(request.user,stravaid,data,strokedata,
|
id = add_workout_from_strokedata(request.user,stravaid,data,strokedata,
|
||||||
|
source='strava')
|
||||||
try:
|
try:
|
||||||
|
w = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
w.uploadedtostrava=stravaid
|
w.uploadedtostrava=stravaid
|
||||||
w.save()
|
w.save()
|
||||||
@@ -4436,7 +4554,7 @@ def workout_delete_confirm_view(request, id=0):
|
|||||||
{'id':id,
|
{'id':id,
|
||||||
'workout':row})
|
'workout':row})
|
||||||
|
|
||||||
except Workout.DoesNotExist:
|
except Workout.DoesNotExist:
|
||||||
raise Http404("Workout doesn't exist")
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
# Really deleting the workout
|
# Really deleting the workout
|
||||||
@@ -4456,7 +4574,7 @@ def workout_delete_view(request,id=0):
|
|||||||
)
|
)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
except Workout.DoesNotExist:
|
except Workout.DoesNotExist:
|
||||||
raise Http404("Workout doesn't exist")
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
# Ask the user to confirm that he wants to delete a chart
|
# Ask the user to confirm that he wants to delete a chart
|
||||||
@@ -4472,7 +4590,9 @@ def graph_delete_confirm_view(request, id=0):
|
|||||||
{'id':id,
|
{'id':id,
|
||||||
'graph':img})
|
'graph':img})
|
||||||
|
|
||||||
except Workout.DoesNotExist:
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
except GraphImage.DoesNotExist:
|
||||||
raise Http404("The image doesn't exist")
|
raise Http404("The image doesn't exist")
|
||||||
|
|
||||||
# Really deleting the chart
|
# Really deleting the chart
|
||||||
@@ -4493,7 +4613,7 @@ def graph_delete_view(request,id=0):
|
|||||||
)
|
)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
except GraphImage.DoesNotExist:
|
except GraphImage.DoesNotExist:
|
||||||
raise Http404("Graph Image doesn't exist")
|
raise Http404("Graph Image doesn't exist")
|
||||||
|
|
||||||
|
|
||||||
@@ -4536,7 +4656,9 @@ def graph_show_view(request,id):
|
|||||||
'workout':w,
|
'workout':w,
|
||||||
'rower':r,})
|
'rower':r,})
|
||||||
|
|
||||||
except GraphImage.DoesNotExist:
|
except GraphImage.DoesNotExist:
|
||||||
|
raise Http404("This graph doesn't exist")
|
||||||
|
except Workout.DoesNotExist:
|
||||||
raise Http404("This workout doesn't exist")
|
raise Http404("This workout doesn't exist")
|
||||||
|
|
||||||
# Restore original stroke data and summary
|
# Restore original stroke data and summary
|
||||||
@@ -4546,7 +4668,7 @@ def workout_summary_restore_view(request,id,message="",successmessage=""):
|
|||||||
row = Workout.objects.get(id=id)
|
row = Workout.objects.get(id=id)
|
||||||
if (checkworkoutuser(request.user,row)==False):
|
if (checkworkoutuser(request.user,row)==False):
|
||||||
return HttpResponse("You are not allowed to edit this workout")
|
return HttpResponse("You are not allowed to edit this workout")
|
||||||
except Workout.DoesNotExist:
|
except Workout.DoesNotExist:
|
||||||
raise Http404("Workout doesn't exist")
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
s = ""
|
s = ""
|
||||||
@@ -4601,7 +4723,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|||||||
row = Workout.objects.get(id=id)
|
row = Workout.objects.get(id=id)
|
||||||
if (checkworkoutuser(request.user,row)==False):
|
if (checkworkoutuser(request.user,row)==False):
|
||||||
return HttpResponse("You are not allowed to edit this workout")
|
return HttpResponse("You are not allowed to edit this workout")
|
||||||
except Workout.DoesNotExist:
|
except Workout.DoesNotExist:
|
||||||
raise Http404("Workout doesn't exist")
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
s = ""
|
s = ""
|
||||||
@@ -5179,7 +5301,7 @@ def strokedatajson(request,id):
|
|||||||
row = Workout.objects.get(id=id)
|
row = Workout.objects.get(id=id)
|
||||||
if (checkworkoutuser(request.user,row)==False):
|
if (checkworkoutuser(request.user,row)==False):
|
||||||
return HttpResponseForbidden("Permission error")
|
return HttpResponseForbidden("Permission error")
|
||||||
except Workout.DoesNotExist:
|
except Workout.DoesNotExist:
|
||||||
raise Http404("Workout doesn't exist")
|
raise Http404("Workout doesn't exist")
|
||||||
try:
|
try:
|
||||||
id = int(id)
|
id = int(id)
|
||||||
|
|||||||
Reference in New Issue
Block a user