Private
Public Access
1
0

anonymous user cannot save favorite

This commit is contained in:
Sander Roosendaal
2017-04-18 09:00:13 +02:00
parent 16ecb0ffa1
commit ee162437b0

View File

@@ -260,8 +260,12 @@ from utils import geo_distance,serialize_list,deserialize_list
# Check if a user is a Coach member # Check if a user is a Coach member
def iscoachmember(user): def iscoachmember(user):
r = Rower.objects.get(user=user) if not user.is_anonymous():
result = user.is_authenticated() and (r.rowerplan=='coach') r = Rower.objects.get(user=user)
result = user.is_authenticated() and (r.rowerplan=='coach')
else:
result = False
return result return result
# Check if a user is a Pro member # Check if a user is a Pro member
@@ -4198,14 +4202,15 @@ def workout_flexchart3_view(request,*args,**kwargs):
workstrokesonly = False workstrokesonly = False
if request.method == 'POST' and 'savefavorite' in request.POST: if request.method == 'POST' and 'savefavorite' in request.POST:
workstrokesonly = request.POST['workstrokesonlysave'] if not user.is_anonymous():
reststrokes = not workstrokesonly workstrokesonly = request.POST['workstrokesonlysave']
r = Rower.objects.get(user=request.user) reststrokes = not workstrokesonly
f = FavoriteChart(user=r,xparam=xparam, r = Rower.objects.get(user=request.user)
yparam1=yparam1,yparam2=yparam2, f = FavoriteChart(user=r,xparam=xparam,
plottype=plottype,workouttype=workouttype, yparam1=yparam1,yparam2=yparam2,
reststrokes=reststrokes) plottype=plottype,workouttype=workouttype,
f.save() reststrokes=reststrokes)
f.save()
if request.method == 'POST' and 'workstrokesonly' in request.POST: if request.method == 'POST' and 'workstrokesonly' in request.POST:
workstrokesonly = request.POST['workstrokesonly'] workstrokesonly = request.POST['workstrokesonly']