Merge branch 'develop' into feature/restapi
This commit is contained in:
@@ -1,10 +1,18 @@
|
|||||||
from rowers.models import Workout, User, Rower
|
from rowers.models import Workout, User, Rower
|
||||||
from rowingdata import rowingdata as rrdata
|
from rowingdata import rowingdata as rrdata
|
||||||
|
|
||||||
|
from rowers.tasks import handle_sendemail_unrecognized
|
||||||
|
|
||||||
from rowingdata import rower as rrower
|
from rowingdata import rower as rrower
|
||||||
from rowingdata import main as rmain
|
from rowingdata import main as rmain
|
||||||
|
|
||||||
|
from rowingdata import get_file_type
|
||||||
|
|
||||||
from pandas import DataFrame,Series
|
from pandas import DataFrame,Series
|
||||||
|
from pytz import timezone as tz,utc
|
||||||
|
|
||||||
|
from django.utils.timezone import get_current_timezone
|
||||||
|
thetimezone = get_current_timezone()
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -80,6 +88,164 @@ def timedeltaconv(x):
|
|||||||
|
|
||||||
return dt
|
return dt
|
||||||
|
|
||||||
|
def new_workout_from_file(r,f2,
|
||||||
|
workouttype='rower',
|
||||||
|
title='Workout',
|
||||||
|
notes=''):
|
||||||
|
|
||||||
|
fileformat = get_file_type(f2)
|
||||||
|
summary = ''
|
||||||
|
# handle non-Painsled
|
||||||
|
if (fileformat != 'csv'):
|
||||||
|
# handle RowPro:
|
||||||
|
if (fileformat == 'rp'):
|
||||||
|
row = RowProParser(f2)
|
||||||
|
# handle TCX
|
||||||
|
if (fileformat == 'tcx'):
|
||||||
|
row = TCXParser(f2)
|
||||||
|
|
||||||
|
# handle Mystery
|
||||||
|
if (fileformat == 'mystery'):
|
||||||
|
row = MysteryParser(f2)
|
||||||
|
|
||||||
|
# handle TCX no HR
|
||||||
|
if (fileformat == 'tcxnohr'):
|
||||||
|
row = TCXParserNoHR(f2)
|
||||||
|
|
||||||
|
# handle ErgData
|
||||||
|
if (fileformat == 'ergdata'):
|
||||||
|
row = ErgDataParser(f2)
|
||||||
|
|
||||||
|
# handle BoatCoach
|
||||||
|
if (fileformat == 'boatcoach'):
|
||||||
|
row = BoatCoachParser(f2)
|
||||||
|
|
||||||
|
# handle painsled desktop
|
||||||
|
if (fileformat == 'painsleddesktop'):
|
||||||
|
row = painsledDesktopParser(f2)
|
||||||
|
|
||||||
|
# handle speed coach GPS
|
||||||
|
if (fileformat == 'speedcoach'):
|
||||||
|
row = speedcoachParser(f2)
|
||||||
|
|
||||||
|
# handle speed coach GPS 2
|
||||||
|
if (fileformat == 'speedcoach2'):
|
||||||
|
row = SpeedCoach2Parser(f2)
|
||||||
|
summary = row.allstats()
|
||||||
|
|
||||||
|
|
||||||
|
# handle ErgStick
|
||||||
|
if (fileformat == 'ergstick'):
|
||||||
|
row = ErgStickParser(f2)
|
||||||
|
|
||||||
|
# handle FIT
|
||||||
|
if (fileformat == 'fit'):
|
||||||
|
row = FITParser(f2)
|
||||||
|
s = fitsummarydata(f2)
|
||||||
|
s.setsummary()
|
||||||
|
summary = s.summarytext
|
||||||
|
|
||||||
|
|
||||||
|
f_to_be_deleted = f2
|
||||||
|
# should delete file
|
||||||
|
f2 = f2[:-4]+'o.csv'
|
||||||
|
row.write_csv(f2,gzip=True)
|
||||||
|
|
||||||
|
#os.remove(f2)
|
||||||
|
try:
|
||||||
|
os.remove(f_to_be_deleted)
|
||||||
|
except:
|
||||||
|
os.remove(f_to_be_deleted+'.gz')
|
||||||
|
|
||||||
|
# make workout and put in database
|
||||||
|
rr = rrower(hrmax=r.max,hrut2=r.ut2,
|
||||||
|
hrut1=r.ut1,hrat=r.at,
|
||||||
|
hrtr=r.tr,hran=r.an,ftp=r.ftp)
|
||||||
|
row = rdata(f2,rower=rr)
|
||||||
|
if row == 0:
|
||||||
|
return HttpResponse("Error: CSV Data File Not Found")
|
||||||
|
|
||||||
|
# auto smoothing
|
||||||
|
pace = row.df[' Stroke500mPace (sec/500m)'].values
|
||||||
|
velo = 500./pace
|
||||||
|
|
||||||
|
f = row.df['TimeStamp (sec)'].diff().mean()
|
||||||
|
windowsize = 2*(int(10./(f)))+1
|
||||||
|
if not 'originalvelo' in row.df:
|
||||||
|
row.df['originalvelo'] = velo
|
||||||
|
|
||||||
|
if windowsize > 3 and windowsize<len(velo):
|
||||||
|
velo2 = savgol_filter(velo,windowsize,3)
|
||||||
|
else:
|
||||||
|
velo2 = velo
|
||||||
|
|
||||||
|
velo3 = pd.Series(velo2)
|
||||||
|
velo3 = velo3.replace([-np.inf,np.inf],np.nan)
|
||||||
|
velo3 = velo3.fillna(method='ffill')
|
||||||
|
|
||||||
|
pace2 = 500./abs(velo3)
|
||||||
|
|
||||||
|
row.df[' Stroke500mPace (sec/500m)'] = pace2
|
||||||
|
|
||||||
|
row.df = row.df.fillna(0)
|
||||||
|
|
||||||
|
row.write_csv(f2,gzip=True)
|
||||||
|
try:
|
||||||
|
os.remove(f2)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# recalculate power data
|
||||||
|
if workouttype == 'rower' or workouttype == 'dynamic' or workouttype == 'slides':
|
||||||
|
try:
|
||||||
|
row.erg_recalculatepower()
|
||||||
|
row.write_csv(f2,gzip=True)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if fileformat != 'fit' and summary == '':
|
||||||
|
summary = row.summary()
|
||||||
|
summary += '\n'
|
||||||
|
summary += row.intervalstats_painsled()
|
||||||
|
|
||||||
|
averagehr = row.df[' HRCur (bpm)'].mean()
|
||||||
|
maxhr = row.df[' HRCur (bpm)'].max()
|
||||||
|
|
||||||
|
totaldist = row.df['cum_dist'].max()
|
||||||
|
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
|
||||||
|
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)']
|
||||||
|
|
||||||
|
hours = int(totaltime/3600.)
|
||||||
|
minutes = int((totaltime - 3600.*hours)/60.)
|
||||||
|
seconds = int(totaltime - 3600.*hours - 60.*minutes)
|
||||||
|
tenths = int(10*(totaltime - 3600.*hours - 60.*minutes - seconds))
|
||||||
|
duration = "%s:%s:%s.%s" % (hours,minutes,seconds,tenths)
|
||||||
|
|
||||||
|
workoutdate = row.rowdatetime.strftime('%Y-%m-%d')
|
||||||
|
workoutstarttime = row.rowdatetime.strftime('%H:%M:%S')
|
||||||
|
workoutstartdatetime = thetimezone.localize(row.rowdatetime).astimezone(utc)
|
||||||
|
|
||||||
|
# check for duplicate start times
|
||||||
|
ws = Workout.objects.filter(starttime=workoutstarttime,
|
||||||
|
user=r)
|
||||||
|
if (len(ws) != 0):
|
||||||
|
message = "Warning: This workout probably already exists in the database"
|
||||||
|
|
||||||
|
w = Workout(user=r,name=title,date=workoutdate,
|
||||||
|
workouttype=workouttype,
|
||||||
|
duration=duration,distance=totaldist,
|
||||||
|
weightcategory=r.weightcategory,
|
||||||
|
starttime=workoutstarttime,
|
||||||
|
csvfilename=f2,notes=notes,summary=summary,
|
||||||
|
maxhr=maxhr,averagehr=averagehr,
|
||||||
|
startdatetime=workoutstartdatetime)
|
||||||
|
|
||||||
|
w.save()
|
||||||
|
# put stroke data in database
|
||||||
|
res = dataprep(row.df,id=w.id,bands=True,barchart=True,otwpower=True,empower=True)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def compare_data(id):
|
def compare_data(id):
|
||||||
row = Workout.objects.get(id=id)
|
row = Workout.objects.get(id=id)
|
||||||
f1 = row.csvfilename
|
f1 = row.csvfilename
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
{% load analytical %}
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
{% analytical_head_top %}
|
||||||
<link rel="stylesheet" href="/static/css/bokeh-0.12.3.min.css" type="text/css" />
|
<link rel="stylesheet" href="/static/css/bokeh-0.12.3.min.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="/static/css/bokeh-widgets-0.12.3.min.css" type="text/css" />
|
<link rel="stylesheet" href="/static/css/bokeh-widgets-0.12.3.min.css" type="text/css" />
|
||||||
|
|
||||||
@@ -15,8 +17,10 @@
|
|||||||
<link rel="stylesheet" href="/static/css/960_12_col.css" />
|
<link rel="stylesheet" href="/static/css/960_12_col.css" />
|
||||||
<link rel="stylesheet" href="/static/css/rowsandall.css" />
|
<link rel="stylesheet" href="/static/css/rowsandall.css" />
|
||||||
{% block meta %} {% endblock %}
|
{% block meta %} {% endblock %}
|
||||||
|
{% analytical_head_bottom %}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
{% analytical_body_top %}
|
||||||
<div class="container_12">
|
<div class="container_12">
|
||||||
<div id="logo" class="grid_2">
|
<div id="logo" class="grid_2">
|
||||||
{% if user.rower.rowerplan == 'pro' %}
|
{% if user.rower.rowerplan == 'pro' %}
|
||||||
@@ -178,5 +182,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- end container -->
|
<!-- end container -->
|
||||||
|
{% analytical_body_bottom %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -3,6 +3,25 @@
|
|||||||
{% block title %}Contact Us - Thank You{% endblock title %}
|
{% block title %}Contact Us - Thank You{% endblock title %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h3>Thank you.</h3>
|
<h3>Thank you.</h3>
|
||||||
<p>Thank you for registering. You can now login using the credential you provided.</p>
|
<p>Thank you for registering. You can now login using the credential you provided. You can also view some of the videos below to get you started.</p>
|
||||||
<p>Return <a href="/">home</a></p>
|
<p>Return <a href="/">home</a></p>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Basic Navigation</h3>
|
||||||
|
<iframe width="560" height="315" src="https://www.youtube.com/embed/-rrTWTS23sM" frameborder="0" allowfullscreen></iframe>
|
||||||
|
|
||||||
|
<h3>Upload Page</h3>
|
||||||
|
<iframe width="560" height="315" src="https://www.youtube.com/embed/IsUtdh30USw" frameborder="0" allowfullscreen></iframe>
|
||||||
|
|
||||||
|
<h3>Integration with Strava, SportTracks or Concept2 logbook</h3>
|
||||||
|
|
||||||
|
<p><iframe width="560" height="315" src="https://www.youtube.com/embed/wF_P6x0uSL4" frameborder="0" allowfullscreen></iframe></p>
|
||||||
|
|
||||||
|
<p><iframe width="560" height="315" src="https://www.youtube.com/embed/rjNwXCh7jKg" frameborder="0" allowfullscreen></iframe></p>
|
||||||
|
|
||||||
|
<p><iframe width="560" height="315" src="https://www.youtube.com/embed/WfccMz3SbAc" frameborder="0" allowfullscreen></iframe></p>
|
||||||
|
|
||||||
|
<p><iframe width="560" height="315" src="https://www.youtube.com/embed/90AXO4dppT4" frameborder="0" allowfullscreen></iframe></p>
|
||||||
|
|
||||||
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
@@ -50,6 +50,8 @@ from rowers.tasks import handle_sendemail_unrecognized
|
|||||||
from scipy.signal import savgol_filter
|
from scipy.signal import savgol_filter
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
|
|
||||||
|
from shutil import copyfile
|
||||||
|
|
||||||
from rowingdata import rower as rrower
|
from rowingdata import rower as rrower
|
||||||
from rowingdata import main as rmain
|
from rowingdata import main as rmain
|
||||||
from rowingdata import rowingdata as rrdata
|
from rowingdata import rowingdata as rrdata
|
||||||
@@ -240,6 +242,17 @@ def rower_register_view(request):
|
|||||||
|
|
||||||
therower.save()
|
therower.save()
|
||||||
|
|
||||||
|
# Create Sample workout
|
||||||
|
f = 'media/testdata.csv.gz'
|
||||||
|
timestr = strftime("%Y%m%d-%H%M%S")
|
||||||
|
f2 = f[:-7]+timestr+'.csv.gz'
|
||||||
|
copyfile(f,f2)
|
||||||
|
|
||||||
|
response = dataprep.new_workout_from_file(therower,f2,
|
||||||
|
title='New User Sample Data',
|
||||||
|
notes='This is an example workout to get you started')
|
||||||
|
|
||||||
|
# Create and send email
|
||||||
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
|
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
|
||||||
subject = "Thank you for registering on rowsandall.com"
|
subject = "Thank you for registering on rowsandall.com"
|
||||||
message = "Thank you for registering on rowsandall.com. You can now login using the credentials you provided.\n"
|
message = "Thank you for registering on rowsandall.com. You can now login using the credentials you provided.\n"
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ INSTALLED_APPS = [
|
|||||||
'rest_framework_swagger',
|
'rest_framework_swagger',
|
||||||
'oauth2_provider',
|
'oauth2_provider',
|
||||||
'corsheaders',
|
'corsheaders',
|
||||||
|
'analytical',
|
||||||
]
|
]
|
||||||
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
AUTHENTICATION_BACKENDS = (
|
||||||
@@ -278,3 +279,7 @@ REST_FRAMEWORK = {
|
|||||||
'PAGE_SIZE': 20,
|
'PAGE_SIZE': 20,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Analytics
|
||||||
|
|
||||||
|
CLICKY_SITE_ID = '101011008'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user