From 64da35a6f8c03bef8fe72e40f0a24563a6d1ead6 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 19 Apr 2017 08:11:51 +0200 Subject: [PATCH 1/7] Strava uploads now use gzip --- rowers/stravastuff.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rowers/stravastuff.py b/rowers/stravastuff.py index 5fd018c4..1323f03b 100644 --- a/rowers/stravastuff.py +++ b/rowers/stravastuff.py @@ -14,6 +14,7 @@ import time import math from math import sin,cos,atan2,sqrt import os,sys +import gzip # Django from django.shortcuts import render_to_response @@ -230,6 +231,13 @@ def createstravaworkoutdata(w): row = rowingdata(filename) tcxfilename = filename[:-4]+'.tcx' row.exporttotcx(tcxfilename,notes=w.notes) + gzfilename = tcxfilename+'.gz' + with file(tcxfilename,'rb') as inF: + s = inF.read() + with gzip.GzipFile(gzfilename,'wb') as outF: + outF.write(s) + os.remove(tcxfilename) + return gzfilename except: tcxfilename = 0 @@ -241,7 +249,7 @@ def handle_stravaexport(f2,workoutname,stravatoken,description=''): # w = Workout.objects.get(id=workoutid) client = stravalib.Client(access_token=stravatoken) - act = client.upload_activity(f2,'tcx',name=workoutname) + act = client.upload_activity(f2,'tcx.gz',name=workoutname) try: res = act.wait(poll_interval=5.0,timeout=30) message = 'Workout successfully synchronized to Strava' From 1d97b2ee881b114838aaf53fa28e252c9a75d23f Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Fri, 21 Apr 2017 08:52:39 +0200 Subject: [PATCH 2/7] added isnan to f determination --- rowers/dataprep.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rowers/dataprep.py b/rowers/dataprep.py index ea252e89..a03c01ee 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -363,7 +363,7 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower', velo = 500./pace f = row.df['TimeStamp (sec)'].diff().mean() - if f !=0: + if f !=0 and not np.isnan(f): windowsize = 2*(int(10./(f)))+1 else: windowsize = 1 From 77434f5fd6acb1b722dadd9e24e9ce332dacfe7c Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 22 Apr 2017 08:41:55 +0200 Subject: [PATCH 3/7] save favorite user check bug fix --- rowers/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rowers/views.py b/rowers/views.py index 57547fd6..eea09e00 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -4202,7 +4202,7 @@ def workout_flexchart3_view(request,*args,**kwargs): workstrokesonly = False if request.method == 'POST' and 'savefavorite' in request.POST: - if not user.is_anonymous(): + if not request.user.is_anonymous(): workstrokesonly = request.POST['workstrokesonlysave'] reststrokes = not workstrokesonly r = Rower.objects.get(user=request.user) From eae2b8ac4ba0681de21440359c6e126f52e2b5cc Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 22 Apr 2017 12:32:13 +0200 Subject: [PATCH 4/7] extended templates --- rowers/templates/400.html | 2 +- rowers/templates/403.html | 2 +- rowers/templates/404.html | 3 +- rowers/templates/500.html | 3 +- rowers/templates/base.html | 221 ++------------------------ rowers/templates/basebase.html | 219 +++++++++++++++++++++++++ rowers/templates/basefront.html | 238 +++------------------------- rowers/templates/basenofilters.html | 26 +++ 8 files changed, 279 insertions(+), 435 deletions(-) create mode 100644 rowers/templates/basebase.html create mode 100644 rowers/templates/basenofilters.html diff --git a/rowers/templates/400.html b/rowers/templates/400.html index 43d7e090..025dfc60 100644 --- a/rowers/templates/400.html +++ b/rowers/templates/400.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "basenofilters.html" %} {% load staticfiles %} {% load rowerfilters %} diff --git a/rowers/templates/403.html b/rowers/templates/403.html index 316b4872..3a3d7df7 100644 --- a/rowers/templates/403.html +++ b/rowers/templates/403.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "basenofilters.html" %} {% load staticfiles %} {% load rowerfilters %} diff --git a/rowers/templates/404.html b/rowers/templates/404.html index 0116bd84..33fd4812 100644 --- a/rowers/templates/404.html +++ b/rowers/templates/404.html @@ -1,6 +1,5 @@ -{% extends "base.html" %} +{% extends "basenofilters.html" %} {% load staticfiles %} -{% load rowerfilters %} {% block title %}Change Workout {% endblock %} diff --git a/rowers/templates/500.html b/rowers/templates/500.html index 258d606b..d60793eb 100644 --- a/rowers/templates/500.html +++ b/rowers/templates/500.html @@ -1,6 +1,5 @@ -{% extends "base.html" %} +{% extends "basenofilters.html" %} {% load staticfiles %} -{% load rowerfilters %} {% block title %}Change Workout {% endblock %} diff --git a/rowers/templates/base.html b/rowers/templates/base.html index 8e6487a2..77fa6213 100644 --- a/rowers/templates/base.html +++ b/rowers/templates/base.html @@ -1,149 +1,9 @@ -{% load cookielaw_tags %} -{% load analytical %} -{% load rowerfilters %} - - - - - {% analytical_head_top %} - {% if GOOGLE_ANALYTICS_PROPERTY_ID %} - {% include "ga.html" %} - {% endif %} - - +{% extends "basebase.html" %} +{% block filters %} + {% load rowerfilters %} +{% endblock %} - - - - - - - - Rowsandall - - - - - {% block meta %} {% endblock %} - {% analytical_head_bottom %} - - - {% analytical_body_top %} -
-
-   -
-
- -
-
-
- -
- -
- -
-
-

Free Data and Analysis. For Rowers. By Rowers.

-
-
- -
-
- {% if user.is_authenticated %} -

- {{ user.first_name }} -

- Edit user account, e.g. heart rate zones, power zones, email, teams - - {% else %} -

login

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

logout

- {% else %} -

 

- {% endif %} -
-
-
- {% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %} -
Pro Member
- {% 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 %} -
-
+{% block teams %} {% if user.is_authenticated and user|has_teams %} -
+{% endblock %} - -
-
- {% block message %} - {% if message %} -

- {{ message }} -

- {% endif %} - {% if successmessage %} -

- {{ successmessage }} -

- {% endif %} - {% endblock %} -
-
- {% load tz %} - - {% block content %}{% endblock %} -
-
- -
- {% block footer %} - - -
- -
-
- -
-
- -
-
- -
-
- -
- - - {% endblock %} -
- {% cookielaw_banner %} -
- - {% analytical_body_bottom %} - - +{% block content %} + +{% endblock %} diff --git a/rowers/templates/basebase.html b/rowers/templates/basebase.html new file mode 100644 index 00000000..a97bbb60 --- /dev/null +++ b/rowers/templates/basebase.html @@ -0,0 +1,219 @@ +{% load cookielaw_tags %} +{% load analytical %} +{% block filters %} +{% endblock %} + + + + + {% analytical_head_top %} + {% if GOOGLE_ANALYTICS_PROPERTY_ID %} + {% include "ga.html" %} + {% endif %} + + + + + + + + + + + Rowsandall + + + + + {% block meta %} {% endblock %} + {% analytical_head_bottom %} + + + {% analytical_body_top %} + {% block body_top %}{% endblock %} +
+
+   +
+
+ +
+
+
+ +
+ +
+ +
+
+

Free Data and Analysis. For Rowers. By Rowers.

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

+ {{ user.first_name }} +

+ Edit user account, e.g. heart rate zones, power zones, email, teams + + {% else %} +

login

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

logout

+ {% else %} +

 

+ {% endif %} +
+
+
+ {% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %} +
Pro Member
+ {% 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 %} +
+
+ {% block teams %} + {% endblock %} +
+
+ + +
+
+ {% block message %} + {% if message %} +

+ {{ message }} +

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

+ {{ successmessage }} +

+ {% endif %} + {% endblock %} +
+
+ {% load tz %} + + {% block content %}{% endblock %} +
+
+ +
+ {% block footer %} + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + + {% endblock %} +
+ {% cookielaw_banner %} +
+ + {% analytical_body_bottom %} + {% block body_bottom %}{% endblock %} + + diff --git a/rowers/templates/basefront.html b/rowers/templates/basefront.html index 15017318..9bf96b9c 100644 --- a/rowers/templates/basefront.html +++ b/rowers/templates/basefront.html @@ -1,34 +1,12 @@ -{% load cookielaw_tags %} -{% load analytical %} -{% load rowerfilters %} - - - - - {% analytical_head_top %} - {% if GOOGLE_ANALYTICS_PROPERTY_ID %} - {% include "ga.html" %} - {% endif %} - - - - - - - - - - - Rowsandall - - - - - {% block meta %} {% endblock %} - {% analytical_head_bottom %} - - +{% extends "basebase.html" %} +{% block filters %} + {% load rowerfilters %} +{% endblock %} +{% block meta %} +{% endblock %} + +{% block body_top %} - -
- {% analytical_body_top %} -
-
-
-   -
-
- -
-
-
- -
- -
- -
-
-

Free Data and Analysis. For Rowers. By Rowers.

-
-
-
-
- {% if user.is_authenticated %} -

- {{ user.first_name }} -

- Edit user account, e.g. heart rate zones, power zones, email, teams - - {% else %} -

login

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

logout

- {% else %} -

 

- {% endif %} -
-
-
- {% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %} -
Pro Member
- {% 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 and user|user_teams %} +
+ +
+{% endblock %} + +{% block teams %} + {% if user.is_authenticated and user|has_teams %} +{% endblock %} - -
-
- {% block message %} - {% if message %} -

- {{ message }} -

- {% endif %} - {% if successmessage %} -

- {{ successmessage }} -

- {% endif %} - {% endblock %} + +{% block body_bottom %}
-
- {% load tz %} - - {% block content %}{% endblock %} -
-
- -
- {% block footer %} - - -
- -
-
- -
-
- -
-
- -
-
- -
- - - {% endblock %} -
- {% cookielaw_banner %} -
-
- - {% analytical_body_bottom %} - - +{% endblock %} + diff --git a/rowers/templates/basenofilters.html b/rowers/templates/basenofilters.html new file mode 100644 index 00000000..04fad305 --- /dev/null +++ b/rowers/templates/basenofilters.html @@ -0,0 +1,26 @@ +{% extends "basebase.html" %} +{% block filters %} + {% load rowerfilters %} +{% endblock %} + +{% block teams %} + {% if user.is_authenticated and user.rower.team.all %} + + See recent workouts for your team + {% else %} +

 

+ {% endif %} +{% endblock %} + +{% block content %} + +{% endblock %} From 7ad8ffe0aff6995564fce3e16d8eef09c715556d Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 22 Apr 2017 14:45:07 +0200 Subject: [PATCH 5/7] moved error templates --- rowers/urls.py | 1 + rowsandall_app/settings_dev.py | 5 +- rowsandall_app/urls.py | 10 ++ rowsandall_app/views.py | 1 + templates/400.html | 16 +++ templates/403.html | 17 +++ templates/404.html | 15 +++ templates/500.html | 21 ++++ templates/base.html | 42 +++++++ templates/basebase.html | 219 +++++++++++++++++++++++++++++++++ templates/basefront.html | 80 ++++++++++++ templates/basenofilters.html | 26 ++++ 12 files changed, 451 insertions(+), 2 deletions(-) create mode 100644 templates/400.html create mode 100644 templates/403.html create mode 100644 templates/404.html create mode 100644 templates/500.html create mode 100644 templates/base.html create mode 100644 templates/basebase.html create mode 100644 templates/basefront.html create mode 100644 templates/basenofilters.html diff --git a/rowers/urls.py b/rowers/urls.py index 8fe5c55d..190424dc 100644 --- a/rowers/urls.py +++ b/rowers/urls.py @@ -110,6 +110,7 @@ urlpatterns = [ url(r'^api-docs$', views.schema_view), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^api/workouts/(?P\d+)/strokedata$',views.strokedatajson), + url(r'^500v/$',views.error500_view), url(r'^500/$', TemplateView.as_view(template_name='500.html'),name='500'), url(r'^404/$', TemplateView.as_view(template_name='404.html'),name='404'), url(r'^400/$', TemplateView.as_view(template_name='400.html'),name='400'), diff --git a/rowsandall_app/settings_dev.py b/rowsandall_app/settings_dev.py index 8ebb5caf..d507ce09 100644 --- a/rowsandall_app/settings_dev.py +++ b/rowsandall_app/settings_dev.py @@ -44,9 +44,10 @@ CELERY_SEND_TASK_SENT_EVENT = True # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False +TEMPLATE_DEBUG = DEBUG -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['localhost'] # Application definition diff --git a/rowsandall_app/urls.py b/rowsandall_app/urls.py index 26734641..eea73c39 100644 --- a/rowsandall_app/urls.py +++ b/rowsandall_app/urls.py @@ -21,6 +21,16 @@ from rowsandall_app.views import rootview from django.contrib.auth import views as auth_views from rowers import views as rowersviews +from django.conf.urls import ( + handler400, handler403, handler404, handler500 +) + +handler400 = 'rowers.views.error400_view' +handler403 = 'rowers.views.error403_view' +handler404 = 'rowers.views.error404_view' +handler500 = 'rowers.views.error500_view' + + urlpatterns = [ url(r'^password_change_done/$',auth_views.password_change_done,name='password_change_done'), url(r'^password_change/$',auth_views.password_change), diff --git a/rowsandall_app/views.py b/rowsandall_app/views.py index 921e05f6..4bcc1b91 100644 --- a/rowsandall_app/views.py +++ b/rowsandall_app/views.py @@ -1,4 +1,5 @@ from django.shortcuts import render, redirect, render_to_response +from django.template import RequestContext from django.conf import settings from rowingdata import main as rmain diff --git a/templates/400.html b/templates/400.html new file mode 100644 index 00000000..025dfc60 --- /dev/null +++ b/templates/400.html @@ -0,0 +1,16 @@ +{% extends "basenofilters.html" %} +{% load staticfiles %} +{% load rowerfilters %} + +{% block title %}Change Workout {% endblock %} + +{% block content %} + +
+

Bad Request

+

+HTTP Error 400 Bad Request. +

+
+ +{% endblock %} diff --git a/templates/403.html b/templates/403.html new file mode 100644 index 00000000..3a3d7df7 --- /dev/null +++ b/templates/403.html @@ -0,0 +1,17 @@ +{% extends "basenofilters.html" %} +{% load staticfiles %} +{% load rowerfilters %} + +{% block title %}Change Workout {% endblock %} + +{% block content %} + +
+

Forbidden

+

+ Access forbidden. You probably tried to access functionality on a workout + or chart that is not owned by you. +

+
+ +{% endblock %} diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 00000000..33fd4812 --- /dev/null +++ b/templates/404.html @@ -0,0 +1,15 @@ +{% extends "basenofilters.html" %} +{% load staticfiles %} + +{% block title %}Change Workout {% endblock %} + +{% block content %} + +
+

Error 404 Page not found

+

+We could not find the page on our server. +

+
+ +{% endblock %} diff --git a/templates/500.html b/templates/500.html new file mode 100644 index 00000000..d60793eb --- /dev/null +++ b/templates/500.html @@ -0,0 +1,21 @@ +{% extends "basenofilters.html" %} +{% load staticfiles %} + +{% block title %}Change Workout {% endblock %} + +{% block content %} + +
+

Error 500 Internal Server Error

+

+ The site reported an internal server error. The site developer has been + notified automatically with a full error report. You can help the developer + by reporting an issue on Bitbucket using the button below. +

+ + +
+ +{% endblock %} diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 00000000..77fa6213 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,42 @@ +{% extends "basebase.html" %} +{% block filters %} + {% load rowerfilters %} +{% endblock %} + +{% block teams %} + {% if user.is_authenticated and user|has_teams %} + + See recent workouts for your team + {% elif user.is_authenticated and user.rower.team.all %} + + See recent workouts for your team + {% else %} +

 

+ {% endif %} +{% endblock %} + +{% block content %} + +{% endblock %} diff --git a/templates/basebase.html b/templates/basebase.html new file mode 100644 index 00000000..a97bbb60 --- /dev/null +++ b/templates/basebase.html @@ -0,0 +1,219 @@ +{% load cookielaw_tags %} +{% load analytical %} +{% block filters %} +{% endblock %} + + + + + {% analytical_head_top %} + {% if GOOGLE_ANALYTICS_PROPERTY_ID %} + {% include "ga.html" %} + {% endif %} + + + + + + + + + + + Rowsandall + + + + + {% block meta %} {% endblock %} + {% analytical_head_bottom %} + + + {% analytical_body_top %} + {% block body_top %}{% endblock %} +
+
+   +
+
+ +
+
+
+ +
+ +
+ +
+
+

Free Data and Analysis. For Rowers. By Rowers.

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

+ {{ user.first_name }} +

+ Edit user account, e.g. heart rate zones, power zones, email, teams + + {% else %} +

login

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

logout

+ {% else %} +

 

+ {% endif %} +
+
+
+ {% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %} +
Pro Member
+ {% 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 %} +
+
+ {% block teams %} + {% endblock %} +
+
+ + +
+
+ {% block message %} + {% if message %} +

+ {{ message }} +

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

+ {{ successmessage }} +

+ {% endif %} + {% endblock %} +
+
+ {% load tz %} + + {% block content %}{% endblock %} +
+
+ +
+ {% block footer %} + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + + {% endblock %} +
+ {% cookielaw_banner %} +
+ + {% analytical_body_bottom %} + {% block body_bottom %}{% endblock %} + + diff --git a/templates/basefront.html b/templates/basefront.html new file mode 100644 index 00000000..9bf96b9c --- /dev/null +++ b/templates/basefront.html @@ -0,0 +1,80 @@ +{% extends "basebase.html" %} +{% block filters %} + {% load rowerfilters %} +{% endblock %} + +{% block meta %} +{% endblock %} + +{% block body_top %} + + +
+ +
+{% endblock %} + +{% block teams %} + {% if user.is_authenticated and user|has_teams %} + + See recent workouts for your team + {% elif user.is_authenticated and user.rower.team.all %} + + See recent workouts for your team + {% else %} +

 

+ {% endif %} +{% endblock %} + + +{% block body_bottom %} +
+ +{% endblock %} + diff --git a/templates/basenofilters.html b/templates/basenofilters.html new file mode 100644 index 00000000..04fad305 --- /dev/null +++ b/templates/basenofilters.html @@ -0,0 +1,26 @@ +{% extends "basebase.html" %} +{% block filters %} + {% load rowerfilters %} +{% endblock %} + +{% block teams %} + {% if user.is_authenticated and user.rower.team.all %} + + See recent workouts for your team + {% else %} +

 

+ {% endif %} +{% endblock %} + +{% block content %} + +{% endblock %} From 9769685253406dda574aee8ab3c50043b9d40b8e Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 22 Apr 2017 14:47:41 +0200 Subject: [PATCH 6/7] settings_dev --- rowsandall_app/settings_dev.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rowsandall_app/settings_dev.py b/rowsandall_app/settings_dev.py index d507ce09..70354ff5 100644 --- a/rowsandall_app/settings_dev.py +++ b/rowsandall_app/settings_dev.py @@ -44,7 +44,7 @@ CELERY_SEND_TASK_SENT_EVENT = True # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False +DEBUG = True TEMPLATE_DEBUG = DEBUG ALLOWED_HOSTS = ['localhost'] From 04a3595a0bb4f7ef689fb878536af08b26b8cf08 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 22 Apr 2017 15:01:47 +0200 Subject: [PATCH 7/7] some error checking for invalid y metrics --- rowers/dataprep.py | 8 ++++++++ rowers/interactiveplots.py | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/rowers/dataprep.py b/rowers/dataprep.py index a03c01ee..5ff287b3 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -28,6 +28,7 @@ from rowingdata import ( ) from rowers.models import Team +from rowers.metrics import axes import os import zipfile @@ -899,6 +900,13 @@ def prepmultipledata(ids,verbose=False): # Read a set of columns for a set of workout ids, returns data as a # pandas dataframe def read_cols_df_sql(ids,columns): + # drop columns that are not in offical list + axx = [ax[0] for ax in axes] + for c in columns: + if not c in axx: + columns.remove(c) + print c,'aap' + columns = list(columns)+['distance','spm'] columns = [x for x in columns if x != 'None'] columns = list(set(columns)) diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 0fe5bfe6..d3eeefdf 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -82,6 +82,7 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False): 'workoutstate','driveenergy'] rowdata = dataprep.getsmallrowdata_db(columns,ids=ids) + rowdata.dropna(axis=1,how='all',inplace=True) rowdata.dropna(axis=0,how='any',inplace=True) @@ -369,6 +370,8 @@ def interactive_histoall(theworkouts): ids = [int(w.id) for w in theworkouts] rowdata = dataprep.getsmallrowdata_db(['power'],ids=ids,doclean=True) + + rowdata.dropna(axis=0,how='any',inplace=True) if rowdata.empty: @@ -802,6 +805,7 @@ def interactive_chart(id=0,promember=0): columns = ['time','pace','hr','fpace','ftime'] datadf = dataprep.getsmallrowdata_db(columns,ids=[id]) + datadf.dropna(axis=0,how='any',inplace=True) row = Workout.objects.get(id=id) if datadf.empty: @@ -883,6 +887,17 @@ def interactive_cum_flex_chart2(theworkouts,promember=0, columns = [xparam,yparam1,yparam2,'spm','driveenergy','distance'] datadf = dataprep.getsmallrowdata_db(columns,ids=ids,doclean=False) + try: + tests = rowdata[yparam2] + except KeyError: + yparam2 = 'None' + + try: + tests = rowdata[yparam1] + except KeyError: + yparam1 = 'None' + + yparamname1 = axlabels[yparam1] if yparam2 != 'None': yparamname2 = axlabels[yparam2] @@ -1167,6 +1182,16 @@ def interactive_flex_chart2(id=0,promember=0, rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True, workstrokesonly=workstrokesonly) + try: + tests = rowdata[yparam2] + except KeyError: + yparam2 = 'None' + + try: + tests = rowdata[yparam1] + except KeyError: + yparam1 = 'None' + rowdata.dropna(axis=1,how='all',inplace=True) rowdata.dropna(axis=0,how='any',inplace=True)