Private
Public Access
1
0

Merge branch 'develop' into feature/restapi2

This commit is contained in:
Sander Roosendaal
2017-01-04 08:05:02 +01:00
10 changed files with 69 additions and 23 deletions

View File

@@ -518,7 +518,7 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
try:
drivespeed = drivelength/rowdatadf[' DriveTime (ms)']*1.0e3
except TypeError:
drivespeed = 0.0*rowdatadf['TimeStam (sec)']
drivespeed = 0.0*rowdatadf['TimeStamp (sec)']
drivespeed = drivespeed.fillna(value=0)
driveenergy = drivelength*averageforce*4.44822

View File

@@ -532,5 +532,11 @@ class SiteAnnouncement(models.Model):
self.expires = timezone.now()+datetime.timedelta(days=10)
self.modified = timezone.now()
if self.dotweet:
status = tweetapi.PostUpdate(self.announcement)
try:
status = tweetapi.PostUpdate(self.announcement)
except:
try:
status = tweetapi.PostUpdate(self.announcement[:135])
except:
pass
return super(SiteAnnouncement,self).save(*args, **kwargs)

View File

@@ -247,13 +247,20 @@ def createstravaworkoutdata(w):
def handle_stravaexport(file,workoutname,stravatoken,description=''):
# w = Workout.objects.get(id=workoutid)
client = stravalib.Client(access_token=stravatoken)
act = client.upload_activity(file,'tcx',name=workoutname)
res = act.wait(poll_interval=5.0)
try:
act = client.upload_activity(file,'tcx',name=workoutname)
res = act.wait(poll_interval=5.0)
# description doesn't work yet. Have to wait for stravalib to update
act = client.update_activity(res.id,activity_type='Rowing',description=description)
# description doesn't work yet. Have to wait for stravalib to update
act = client.update_activity(res.id,activity_type='Rowing',description=description)
except:
with open("media/stravaerrors.log","a") as errorlog:
errorstring = str(sys.exc_info()[0])
timestr = time.strftime("%Y%m%d-%H%M%S")
errorlog.write(timestr+errorstring+"\r\n")
errorlog.write("stravastuff.py line 262\r\n")
# w.uploadedtostrava = res.id

View File

@@ -130,6 +130,10 @@ You will be taken to the secure PayPal payment site.
"instructions to seller".</li>
</ul>
</p>
<p>After you do the payment, we will manually change your membership to
"Pro". Depending on our availability, this may take some time
(typically one working day). Don't hesitate to contact us
if you have any questions at this stage.</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">

View File

@@ -158,7 +158,7 @@
<div class="grid_2 alpha">
<p id="footer"><a href="/rowers/email/">&copy; Sander Roosendaal</a></p>
</div>
<div class="grid_1 prefix_1">
<div class="grid_1">
<p id="footer">
<a href="/rowers/about">About</a></p>
</div>
@@ -170,7 +170,7 @@
<p id="footer">
<a href="/rowers/legal">Legal</a></p>
</div>
<div class="grid_1 prefix_1">
<div class="grid_1">
<p id="footer">
<a href="/rowers/physics">Physics</a></p>
</div>
@@ -178,7 +178,10 @@
<p id="footer">
<a href="/rowers/videos">Videos</a></p>
</div>
<div class="grid_2">
<p id="footer">
<a href="http://analytics.rowsandall.com/">Rowing Analytics BLOG</a></p>
</div>
<div class="grid_1 omega">
<p id="footer">
<a href="/rowers/email">Contact</a></p>

View File

@@ -118,13 +118,22 @@
<p>Standard <a href="https://oauth.net/2/">Oauth2</a> authentication.
Get authorization code by pointing your user to the authorization URL.
Exchange authorization code for an access token. When access token expires,
Exchange authorization code for an access token. When access token
expires,
use the refresh token to refresh it.</p>
<p>The POST call must have content-type: <i>x-www-form-urlencoded</i>.
I set it this way to support the handy testing utility mentioned
belower. However,
I really would like to support <i>application/json</i> but with the
current framework I cannot support both at the same time. Expect
changes. Write to me if you want to be notified of changes.</p>
<ul>
<li>Authorization URL: <b>https://rowsandall.com/rowers/o/authorize</b></li>
<li>Access Token request: <b>https://rowsandall.com/rowers/o/token/</b></li>
<li>Access Token refresh: <b>https://rowsandall.com/rowers/o/token/</b></li>
<li>Handy utility for testing: <b><a href="http://django-oauth-toolkit.herokuapp.com/consumer/">http://django-oauth-toolkit.herokuapp.com/consumer/</a></b></li>
</ul>
<h6>API documentation</h6>

View File

@@ -35,10 +35,14 @@ You will be taken to the secure PayPal payment site.
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
<p>After you do the payment, we will manually change your membership to
"Pro". Depending on our availability, this may take some time
(typically one working day). Don't hesitate to contact us
if you have any questions at this stage.</p>
<p>If, for any reason, you are not happy with your Pro membership, please let me know through the contact form. I will contact you as soon as possible to discuss how we can make things better.</p>
</div>
{% endblock content %}
{% endblock content %}

View File

@@ -58,7 +58,7 @@ from rowingdata import rower as rrower
from rowingdata import main as rmain
from rowingdata import rowingdata as rrdata
from rowingdata import TCXParser,RowProParser,ErgDataParser,TCXParserNoHR
from rowingdata import BoatCoachParser
from rowingdata import BoatCoachParser,RowPerfectParser
from rowingdata import MysteryParser
from rowingdata import painsledDesktopParser,speedcoachParser,ErgStickParser
from rowingdata import SpeedCoach2Parser,FITParser,fitsummarydata
@@ -934,9 +934,17 @@ def workout_strava_upload_view(request,id=0):
try:
with open(tcxfile,'rb') as f:
res = stravastuff.handle_stravaexport(f,w.name,
r.stravatoken,
description=w.notes)
try:
res = stravastuff.handle_stravaexport(f,w.name,
r.stravatoken,
description=w.notes)
except:
with open("media/stravaerrors.log","a") as errorlog:
errorstring = str(sys.exc_info()[0])
timestr = time.strftime("%Y%m%d-%H%M%S")
errorlog.write(timestr+errorstring+"\r\n")
errorlog.write("views.py line 946\r\n")
w.uploadedtostrava = res
w.save()
@@ -3751,6 +3759,13 @@ def workout_upload_view(request,message=""):
args=[str(message)])
response = HttpResponseRedirect(url)
return response
if fileformat == 'rowprolog':
message = "This RowPro logbook summary does not contain stroke data. Please use the Stroke Data CSV file for the individual workout in your log."
url = reverse(workout_upload_view,
args=[str(message)])
response = HttpResponseRedirect(url)
return response
if fileformat == 'unknown':
message = "We couldn't recognize the file type"
@@ -3782,6 +3797,10 @@ def workout_upload_view(request,message=""):
if (fileformat == 'mystery'):
row = MysteryParser(f2)
# handle RowPerfect
if (fileformat == 'rowperfect3'):
row = RowPerfectParser(f2)
# handle TCX no HR
if (fileformat == 'tcxnohr'):
row = TCXParserNoHR(f2)