From 0ca922f5a22f4de55c8bd3432364d35a17ada91b Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 4 Jan 2017 22:30:59 +0100 Subject: [PATCH] more error tracing around Strava --- rowers/templates/400.html | 4 +- rowers/templates/403.html | 4 +- rowers/templates/404.html | 4 +- rowers/templates/500.html | 4 +- rowers/templates/bases.html | 189 ++++++++++++++++++++++++++++++++++++ rowers/views.py | 12 ++- rowsandall_app/settings.py | 1 + 7 files changed, 207 insertions(+), 11 deletions(-) create mode 100644 rowers/templates/bases.html diff --git a/rowers/templates/400.html b/rowers/templates/400.html index 735edfd4..caf15419 100644 --- a/rowers/templates/400.html +++ b/rowers/templates/400.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "bases.html" %} {% load staticfiles %} {% load rowerfilters %} @@ -13,4 +13,4 @@ HTTP Error 400 Bad Request.

-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/rowers/templates/403.html b/rowers/templates/403.html index 71faf1fd..65394b28 100644 --- a/rowers/templates/403.html +++ b/rowers/templates/403.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "bases.html" %} {% load staticfiles %} {% load rowerfilters %} @@ -13,4 +13,4 @@ Access forbidden

-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/rowers/templates/404.html b/rowers/templates/404.html index 5330441a..69d2b396 100644 --- a/rowers/templates/404.html +++ b/rowers/templates/404.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "bases.html" %} {% load staticfiles %} {% load rowerfilters %} @@ -13,4 +13,4 @@ We could not find the page on our server.

-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/rowers/templates/500.html b/rowers/templates/500.html index dbb58908..a64a6d92 100644 --- a/rowers/templates/500.html +++ b/rowers/templates/500.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "bases.html" %} {% load staticfiles %} {% load rowerfilters %} @@ -13,4 +13,4 @@ The site reported an internal server error. If this behavior repeats, please inf

-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/rowers/templates/bases.html b/rowers/templates/bases.html new file mode 100644 index 00000000..57e283b6 --- /dev/null +++ b/rowers/templates/bases.html @@ -0,0 +1,189 @@ + + + + + + + + + + + + Rowsandall + + + + + {% block meta %} {% endblock %} + + +
+ +
+

 

+
+ {% if user.is_authenticated %} +

Password Change

+ {% else %} +

Forgotten Password?

+ {% endif %} +
+
+ + +
+
+

Free Data and Analysis. For Rowers. By Rowers.

+
+
+ {% if user.rower.rowerplan == 'pro' %} +
Pro Member
+ {% else %} +

 

+ {% endif %} +
+
+ {% if user.is_authenticated %} +

logout

+ + {% else %} +

 

+ {% endif %} + +
+
+ +
+
+ {% if user.is_authenticated %} +

Upload

+ Upload CSV, TCX, FIT data files to rowsandall.com + {% else %} +

Register (free)

+ {% endif %} +
+
+ {% if user.is_authenticated %} +

+ Import +

+ Import workouts from Strava, SportTracks, and C2 logbook + {% else %} +

 

+ {% endif %} +
+
+ {% if user.is_authenticated %} +

+ Workouts +

+ See your list of workouts + {% else %} +

 

+ {% endif %} +
+
+ {% if user.is_authenticated %} +

+ Graphs +

+ See your most recent charts + {% else %} +

 

+ {% endif %} +
+
+ {% if user.is_authenticated %} +

+ Analysis +

+ Analysis of workouts over a period of time + {% else %} +

 

+ {% endif %} +
+
+ {% if user.is_authenticated %} +

+ {{ user.first_name }} +

+ Edit user data, e.g. heart rate zones + + {% else %} +

login

+ {% endif %} +
+
+ + +
+
+ {% block message %} + {% if message %} +

+ {{ message }} +

+ {% endif %} + {% if successmessage %} +

+ {{ successmessage }} +

+ {% endif %} + {% endblock %} +
+
+ {% load tz %} + + {% block content %}{% endblock %} +
+
+ +
+ {% block footer %} + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+ {% endblock %} +
+
+ + + diff --git a/rowers/views.py b/rowers/views.py index 01c3116c..b4e7b65a 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -922,6 +922,7 @@ def workout_csvemail_view(request,id=0): def workout_strava_upload_view(request,id=0): message = "" r = Rower.objects.get(user=request.user) + res = -1 if (r.stravatoken == '') or (r.stravatoken is None): s = "Token doesn't exist. Need to authorize" return HttpResponseRedirect("/rowers/me/stravaauthorize/") @@ -929,9 +930,14 @@ def workout_strava_upload_view(request,id=0): # ready to upload. Hurray w = Workout.objects.get(id=id) if (checkworkoutuser(request.user,w)): - tcxfile = stravastuff.createstravaworkoutdata(w) - - + try: + tcxfile = stravastuff.createstravaworkoutdata(w) + 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") try: with open(tcxfile,'rb') as f: try: diff --git a/rowsandall_app/settings.py b/rowsandall_app/settings.py index 58078fa3..60229f32 100644 --- a/rowsandall_app/settings.py +++ b/rowsandall_app/settings.py @@ -97,6 +97,7 @@ TEMPLATES = [ 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', + 'django.core.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'django.template.context_processors.i18n',