Private
Public Access
1
0

improved braintree transactions report

This commit is contained in:
Sander Roosendaal
2019-01-17 22:24:36 +01:00
parent 1b06a9eb46
commit 0dbb668f70
4 changed files with 82 additions and 267 deletions

View File

@@ -13081,6 +13081,10 @@ def rower_prefs_view(request,userid=0,message=""):
}
]
form = RowerForm(instance=r)
powerform = RowerPowerForm(instance=r)
powerzonesform = RowerPowerZonesForm(instance=r)
if request.method == 'POST' and "ut2" in request.POST:
form = RowerForm(request.POST)
if form.is_valid():
@@ -13093,58 +13097,17 @@ def rower_prefs_view(request,userid=0,message=""):
tr = cd['tr']
an = cd['an']
rest = cd['rest']
try:
r.max = max(min(hrmax,250),10)
r.ut2 = max(min(ut2,250),10)
r.ut1 = max(min(ut1,250),10)
r.at = max(min(at,250),10)
r.tr = max(min(tr,250),10)
r.an = max(min(an,250),10)
r.rest = max(min(rest,250),10)
r.save()
successmessage = "Your Heart Rate data were changed"
messages.info(request,successmessage)
form = RowerForm(instance=r)
powerform = RowerPowerForm(instance=r)
powerzonesform = RowerPowerZonesForm(instance=r)
accountform = AccountRowerForm(instance=r)
userform = UserForm(instance=r.user)
return render(request, 'rower_preferences.html',
{'form':form,
'powerzonesform':powerzonesform,
'teams':get_my_teams(request.user),
'breadcrumbs':breadcrumbs,
'powerform':powerform,
'rower':r,
'accountform':accountform,
'userform':userform,
})
except Rower.DoesNotExist:
message = "Funny. This user doesn't exist."
messages.error(request,message)
url = reverse(workouts_view)
response = HttpResponseRedirect(url)
else:
message = HttpResponse("invalid form")
#form = RowerForm(instance=r)
powerform = RowerPowerForm(instance=r)
powerzonesform = RowerPowerZonesForm(instance=r)
userform = UserForm(instance=r.user)
accountform = AccountRowerForm(instance=r)
return render(request, 'rower_preferences.html',
{'form':form,
'teams':get_my_teams(request.user),
'powerzonesform':powerzonesform,
'breadcrumbs':breadcrumbs,
'userform':userform,
'accountform':accountform,
'powerform':powerform,
'rower':r,
})
return response
r.max = max(min(hrmax,250),10)
r.ut2 = max(min(ut2,250),10)
r.ut1 = max(min(ut1,250),10)
r.at = max(min(at,250),10)
r.tr = max(min(tr,250),10)
r.an = max(min(an,250),10)
r.rest = max(min(rest,250),10)
r.save()
successmessage = "Your Heart Rate data were changed"
messages.info(request,successmessage)
elif request.method == 'POST' and "ftp" in request.POST:
powerform = RowerPowerForm(request.POST)
if powerform.is_valid():
@@ -13154,52 +13117,24 @@ def rower_prefs_view(request,userid=0,message=""):
hrftp = int((r.an+r.tr)/2.)
ftp = cd['ftp']
otwslack = cd['otwslack']
try:
powerfrac = 100*np.array([r.pw_ut2,
r.pw_ut1,
r.pw_at,
r.pw_tr,r.pw_an])/r.ftp
r.ftp = max(min(ftp,650),50)
r.otwslack = max(min(otwslack,50),0)
ut2,ut1,at,tr,an = (r.ftp*powerfrac/100.).astype(int)
r.pw_ut2 = ut2
r.pw_ut1 = ut1
r.pw_at = at
r.pw_tr = tr
r.pw_an = an
r.hrftp = hrftp
r.save()
message = "FTP and/or OTW slack values changed."
messages.info(request,message)
url = reverse(rower_prefs_view,
kwargs = {
'userid':r.user.id,
})
response = HttpResponseRedirect(url)
except Rower.DoesNotExist:
message = "Funny. This user doesn't exist."
messages.error(request,message)
url = reverse(rower_edit_view)
response = HttpResponseRedirect(url)
else:
message = HttpResponse("invalid form")
form = RowerForm(instance=r)
#powerform = RowerPowerForm(instance=r)
powerzonesform = RowerPowerZonesForm(instance=r)
userform = UserForm(instance=r.user)
accountform = AccountRowerForm(instance=r)
return render(request, 'rower_preferences.html',
{'form':form,
'teams':get_my_teams(request.user),
'breadcrumbs':breadcrumbs,
'powerform':powerform,
'rower':r,
'userform':userform,
'accountform':accountform,
})
return response
powerfrac = 100*np.array([r.pw_ut2,
r.pw_ut1,
r.pw_at,
r.pw_tr,r.pw_an])/r.ftp
r.ftp = max(min(ftp,650),50)
r.otwslack = max(min(otwslack,50),0)
ut2,ut1,at,tr,an = (r.ftp*powerfrac/100.).astype(int)
r.pw_ut2 = ut2
r.pw_ut1 = ut1
r.pw_at = at
r.pw_tr = tr
r.pw_an = an
r.hrftp = hrftp
r.save()
message = "FTP and/or OTW slack values changed."
messages.info(request,message)
elif request.method == 'POST' and "ut3name" in request.POST:
powerzonesform = RowerPowerZonesForm(request.POST)
if powerzonesform.is_valid():
@@ -13216,154 +13151,27 @@ def rower_prefs_view(request,userid=0,message=""):
trname = cd['trname']
anname = cd['anname']
powerzones = [ut3name,ut2name,ut1name,atname,trname,anname]
try:
r.pw_ut2 = pw_ut2
r.pw_ut1 = pw_ut1
r.pw_at = pw_at
r.pw_tr = pw_tr
r.pw_an = pw_an
r.powerzones = powerzones
r.save()
successmessage = "Your Power Zone data were changed"
messages.info(request,successmessage)
form = RowerForm(instance=r)
accountform = AccountRowerForm(instance=r)
userform = UserForm(instance=r.user)
powerform = RowerPowerForm(instance=r)
powerzonesform = RowerPowerZonesForm(instance=r)
return render(request, 'rower_preferences.html',
{'form':form,
'teams':get_my_teams(request.user),
'powerzonesform':powerzonesform,
'powerform':powerform,
'userform':userform,
'breadcrumbs':breadcrumbs,
'accountform':accountform,
'rower':r,
})
except Rower.DoesNotExist:
message = "Funny. This user doesn't exist."
messages.error(request,message)
url = reverse(workouts_view)
response = HttpResponseRedirect(url)
return response
else:
form = RowerForm(instance=r)
powerform = RowerPowerForm(instance=r)
accountform = AccountRowerForm(instance=r)
userform = UserForm(instance=r.user)
#powerzonesform = RowerPowerZonesForm(instance=r)
message = HttpResponse("invalid form")
return render(request, 'rower_preferences.html',
{'form':form,
'teams':get_my_teams(request.user),
'powerform':powerform,
'breadcrumbs':breadcrumbs,
'powerzonesform':powerzonesform,
'accountform':accountform,
'userform':userform,
'rower':r,
})
elif request.method == 'POST' and "weightcategory" in request.POST:
accountform = AccountRowerForm(request.POST)
userform = UserForm(request.POST,instance=r.user)
if accountform.is_valid() and userform.is_valid():
# process
cd = accountform.cleaned_data
ucd = userform.cleaned_data
first_name = ucd['first_name']
last_name = ucd['last_name']
email = ucd['email']
sex = cd['sex']
defaultlandingpage = cd['defaultlandingpage']
weightcategory = cd['weightcategory']
adaptiveclass = cd['adaptiveclass']
birthdate = cd['birthdate']
showfavoritechartnotes = cd['showfavoritechartnotes']
getemailnotifications = cd['getemailnotifications']
getimportantemails = cd['getimportantemails']
defaulttimezone=cd['defaulttimezone']
u = r.user
if u.email != email and len(email):
resetbounce = True
else:
resetbounce = False
if len(first_name):
u.first_name = first_name
u.last_name = last_name
if len(email): ## and check_email_freeforuse(u,email):
u.email = email
resetbounce = True
u.save()
r.defaulttimezone=defaulttimezone
r.weightcategory = weightcategory
r.adaptiveclass = adaptiveclass
r.getemailnotifications = getemailnotifications
r.getimportantemails = getimportantemails
r.defaultlandingpage = defaultlandingpage
r.showfavoritechartnotes = showfavoritechartnotes
r.sex = sex
r.birthdate = birthdate
if resetbounce and r.emailbounced:
r.emailbounced = False
r.pw_ut2 = pw_ut2
r.pw_ut1 = pw_ut1
r.pw_at = pw_at
r.pw_tr = pw_tr
r.pw_an = pw_an
r.powerzones = powerzones
r.save()
form = RowerForm(instance=r)
powerform = RowerPowerForm(instance=r)
powerzonesform = RowerPowerZonesForm(instance=r)
accountform = AccountRowerForm(instance=r)
userform = UserForm(instance=u)
successmessage = 'Account Information changed'
successmessage = "Your Power Zone data were changed"
messages.info(request,successmessage)
return render(request, 'rower_preferences.html',
{'form':form,
'teams':get_my_teams(request.user),
'powerzonesform':powerzonesform,
'breadcrumbs':breadcrumbs,
'powerform':powerform,
'accountform':accountform,
'userform':userform,
'rower':r,
})
else:
form = RowerForm(instance=r)
powerform = RowerPowerForm(instance=r)
powerzonesform = RowerPowerZonesForm(instance=r)
return render(request, 'rower_preferences.html',
{'form':form,
'teams':get_my_teams(request.user),
'powerzonesform':powerzonesform,
'powerform':powerform,
'breadcrumbs':breadcrumbs,
'accountform':accountform,
'userform':userform,
'rower':r,
})
else:
try:
form = RowerForm(instance=r)
powerform = RowerPowerForm(instance=r)
powerzonesform = RowerPowerZonesForm(instance=r)
accountform = AccountRowerForm(instance=r)
userform = UserForm(instance=r.user)
grants = AccessToken.objects.filter(user=request.user)
return render(request, 'rower_preferences.html',
{
'form':form,
'teams':get_my_teams(request.user),
'powerform':powerform,
'powerzonesform':powerzonesform,
'breadcrumbs':breadcrumbs,
'userform':userform,
'accountform':accountform,
'grants':grants,
'rower':r,
})
except Rower.DoesNotExist:
raise Http404("This user doesn't exist")
return render(request, 'rower_preferences.html',
{
'form':form,
'teams':get_my_teams(request.user),
'powerform':powerform,
'powerzonesform':powerzonesform,
'breadcrumbs':breadcrumbs,
'rower':r,
})
# Revoke an app that you granted access through the API.
# this views is called when you press a button on the User edit page