From 739f0889f66f76967fe284e9804a896379456560 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sun, 8 Oct 2017 12:45:37 +0200 Subject: [PATCH] share a graph facebook --- rowers/templates/show_graph.html | 12 +++++++++-- rowers/templates/workout_view.html | 6 ++++++ rowers/views.py | 34 +++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/rowers/templates/show_graph.html b/rowers/templates/show_graph.html index 0b9897b0..3ac636e9 100644 --- a/rowers/templates/show_graph.html +++ b/rowers/templates/show_graph.html @@ -1,8 +1,16 @@ {% extends "base.html" %} {% load staticfiles %} - +{% load rowerfilters %} + {% block title %}{{ workout.name }}{% endblock %} - +{% block og_title %}{{ workout.name }} {% endblock %} +{% block description %}{{ workout.name }} +{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %} +{% block og_description %}{{ workout.name }} +{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %} +{% block og_image %} + +{% endblock %} {% block content %}

{{ workout.name }}

diff --git a/rowers/templates/workout_view.html b/rowers/templates/workout_view.html index 1096461f..9e5c8d3c 100644 --- a/rowers/templates/workout_view.html +++ b/rowers/templates/workout_view.html @@ -66,6 +66,12 @@

+ + {{ mapdiv|safe }} + + + {{ mapscript|safe }} +
diff --git a/rowers/views.py b/rowers/views.py index 3d9da8cb..18240b21 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -4598,7 +4598,35 @@ def workout_view(request,id=0): res = interactive_chart(id) script = res[0] div = res[1] - + + # create map + f1 = row.csvfilename + u = row.user.user + r = getrower(u) + rowdata = rdata(f1) + hascoordinates = 1 + if rowdata != 0: + try: + latitude = rowdata.df[' latitude'] + if not latitude.std(): + hascoordinates = 0 + except KeyError,AttributeError: + hascoordinates = 0 + + else: + hascoordinates = 0 + + + if hascoordinates: + mapscript,mapdiv = leaflet_chart(rowdata.df[' latitude'], + rowdata.df[' longitude'], + row.name) + + + else: + mapscript = "" + mapdiv = "" + # render page if (len(g)<=3): @@ -4609,6 +4637,8 @@ def workout_view(request,id=0): 'first_name':u.first_name, 'interactiveplot':script, 'aantalcomments':aantalcomments, + 'mapscript':mapscript, + 'mapdiv':mapdiv, 'teams':get_my_teams(request.user), 'the_div':div}) else: @@ -4620,6 +4650,8 @@ def workout_view(request,id=0): 'first_name':u.first_name, 'teams':get_my_teams(request.user), 'aantalcomments':aantalcomments, + 'mapscript':mapscript, + 'mapdiv':mapdiv, 'interactiveplot':script, 'the_div':div})