From d60f24c0404612cc3a2ffc846f3cbeda08aad1cf Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Fri, 23 Dec 2016 09:23:35 +0100
Subject: [PATCH 1/7] changed API to accept forms not json encoding
---
rowers/templates/developers.html | 11 ++++++++++-
rowsandall_app/settings.py | 2 +-
rowsandall_app/urls.py | 6 ------
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/rowers/templates/developers.html b/rowers/templates/developers.html
index f383230a..e2907195 100644
--- a/rowers/templates/developers.html
+++ b/rowers/templates/developers.html
@@ -118,13 +118,22 @@
Standard Oauth2 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.
+ The POST call must have content-type: x-www-form-urlencoded.
+ I set it this way to support the handy testing utility mentioned
+ belower. However,
+ I really would like to support application/json 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.
+
- Authorization URL: https://rowsandall.com/rowers/o/authorize
- Access Token request: https://rowsandall.com/rowers/o/token/
- Access Token refresh: https://rowsandall.com/rowers/o/token/
+ - Handy utility for testing: http://django-oauth-toolkit.herokuapp.com/consumer/
API documentation
diff --git a/rowsandall_app/settings.py b/rowsandall_app/settings.py
index c7af4887..58078fa3 100644
--- a/rowsandall_app/settings.py
+++ b/rowsandall_app/settings.py
@@ -262,7 +262,7 @@ GMAPIKEY = "AIzaSyAgu1w9QSthaGPMLp8y9JedPoMc9sfEgJ8"
OAUTH2_PROVIDER = {
# this is the list of available scopes
'SCOPES': {'read': 'Read scope', 'write': 'Write scope', 'groups': 'Access to your groups'},
- 'OAUTH2_BACKEND_CLASS': 'oauth2_provider.oauth2_backends.JSONOAuthLibCore'
+ # 'OAUTH2_BACKEND_CLASS': 'oauth2_provider.oauth2_backends.JSONOAuthLibCore'
}
diff --git a/rowsandall_app/urls.py b/rowsandall_app/urls.py
index 6db8318d..3415cd36 100644
--- a/rowsandall_app/urls.py
+++ b/rowsandall_app/urls.py
@@ -27,15 +27,9 @@ from rowers import views as rowersviews
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
-# url('^', include('django.contrib.auth.urls')),
url(r'^$',rootview),
url(r'^version/$',version),
-# url(r'^rowingdata/$',rowingdata,{'formloc':'/rowingdata/'}),
-# url(r'^nrowingdata/$',nrowingdata,{'formloc':'/nrowingdata/'}),
-# url(r'^upload/$',uploadfile,{'formloc':'/upload/'}),
url(r'^addresult/(.+.*)/$',wait),
-# url(r'^waitforplot/(.+.*)/$',waitforplot),
-# url(r'^showplot/(.+.*)/$',showplot),
url(r'^login/',auth_views.login, name='login'),
url(r'^logout/',auth_views.logout_then_login,name='logout'),
url(r'^password_change_done/$',auth_views.password_change_done,name='password_change_done'),
From c3dbd71465ec9400dc22f289663b4d064e2d7c12 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Sun, 25 Dec 2016 20:53:59 +0100
Subject: [PATCH 2/7] rowperfect3
---
rowers/models.py | 8 +++++++-
rowers/views.py | 6 +++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/rowers/models.py b/rowers/models.py
index 878929b4..303b4b76 100644
--- a/rowers/models.py
+++ b/rowers/models.py
@@ -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)
diff --git a/rowers/views.py b/rowers/views.py
index 8a7d8cf3..6d480807 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -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
@@ -3782,6 +3782,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)
From 6b20e1c936588edbfe30e8a32d7c3aa8f66b9fca Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Tue, 27 Dec 2016 08:50:57 +0100
Subject: [PATCH 3/7] Code to check Strava behaviour
---
rowers/stravastuff.py | 17 ++++++++++++-----
rowers/views.py | 14 +++++++++++---
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/rowers/stravastuff.py b/rowers/stravastuff.py
index 954f4dee..bc3c354f 100644
--- a/rowers/stravastuff.py
+++ b/rowers/stravastuff.py
@@ -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
diff --git a/rowers/views.py b/rowers/views.py
index 6d480807..01c3116c 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -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()
From 04aa40f19c28bbbc08b1507fdee6aecc6614b6c1 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Tue, 27 Dec 2016 08:52:30 +0100
Subject: [PATCH 4/7] Typo correction in dataprep
---
rowers/dataprep.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rowers/dataprep.py b/rowers/dataprep.py
index 9744b6b9..b6dbad35 100644
--- a/rowers/dataprep.py
+++ b/rowers/dataprep.py
@@ -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
From 0b1aa1677cf4472ce5fc3b76efbc3c37a731dc32 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Mon, 2 Jan 2017 09:51:34 +0100
Subject: [PATCH 5/7] pro membership conversion disclaimer
---
rowers/templates/about_us.html | 4 ++++
rowers/templates/promembership.html | 6 +++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/rowers/templates/about_us.html b/rowers/templates/about_us.html
index e562c356..a57e5e3a 100644
--- a/rowers/templates/about_us.html
+++ b/rowers/templates/about_us.html
@@ -130,6 +130,10 @@ You will be taken to the secure PayPal payment site.
"instructions to seller".
+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.
+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.
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.
- {% endblock content %}
\ No newline at end of file
+ {% endblock content %}
From 145435e5739ea7e81134bea9681ce99a82160bfd Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Mon, 2 Jan 2017 10:21:39 +0100
Subject: [PATCH 6/7] Rowpro log warning message
---
rowers/views.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/rowers/views.py b/rowers/views.py
index 01c3116c..167ecb92 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -3759,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"
From c124cf043c01c06ab1a9af5fe8fe6b31de752c68 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Tue, 3 Jan 2017 22:01:48 +0100
Subject: [PATCH 7/7] add link to blog in footer
---
rowers/templates/base.html | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/rowers/templates/base.html b/rowers/templates/base.html
index 2b209f35..1f583a2f 100644
--- a/rowers/templates/base.html
+++ b/rowers/templates/base.html
@@ -158,7 +158,7 @@
-
-
-
+
+
+