diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py
index 408f6ab2..71674fbb 100644
--- a/rowers/interactiveplots.py
+++ b/rowers/interactiveplots.py
@@ -729,6 +729,8 @@ def leaflet_chart(lat,lon,name=""):
id: 'mapbox.outdoors'
}});
+
+
var mymap = L.map('map_canvas', {{
center: [{latmean}, {lonmean}],
zoom: 13,
@@ -777,6 +779,111 @@ def leaflet_chart(lat,lon,name=""):
+ return script,div
+
+def leaflet_chart2(lat,lon,name=""):
+ if lat.empty or lon.empty:
+ return [0,"invalid coordinate data"]
+
+ latmean = lat.mean()
+ lonmean = lon.mean()
+ latbegin = lat[lat.index[0]]
+ longbegin = lon[lon.index[0]]
+ latend = lat[lat.index[-1]]
+ longend = lon[lon.index[-1]]
+
+ coordinates = zip(lat,lon)
+
+ scoordinates = "["
+
+ for x,y in coordinates:
+ scoordinates += """[{x},{y}],
+ """.format(
+ x=x,
+ y=y
+ )
+
+ scoordinates += "]"
+
+ script = """
+
+ """.format(
+ latmean=latmean,
+ lonmean=lonmean,
+ latbegin = latbegin,
+ latend=latend,
+ longbegin=longbegin,
+ longend=longend,
+ scoordinates=scoordinates,
+ )
+
+ div = """
+
+ """
+
+
+
return script,div
def googlemap_chart(lat,lon,name=""):
diff --git a/rowers/templates/basebase.html b/rowers/templates/basebase.html
index 1e3cdb3a..9b2d9e79 100644
--- a/rowers/templates/basebase.html
+++ b/rowers/templates/basebase.html
@@ -17,6 +17,9 @@
+
+
+
diff --git a/rowers/urls.py b/rowers/urls.py
index 3f6f005d..0bc81cb6 100644
--- a/rowers/urls.py
+++ b/rowers/urls.py
@@ -187,6 +187,7 @@ urlpatterns = [
url(r'^workout/compare2/(?P\d+)/(?P\d+)/(?P\w+.*)/(?P\w+.*)/$',views.workout_comparison_view),
url(r'^workout/compare/(?P\d+)/(?P\d+-\d+-\d+)/(?P\w+.*)$',views.workout_comparison_list),
url(r'^workout/(?P\d+)/edit$',views.workout_edit_view),
+ url(r'^workout/(?P\d+)/navionics$',views.workout_edit_view_navionics),
url(r'^workout/(?P\d+)/setprivate$',views.workout_setprivate_view),
url(r'^workout/(?P\d+)/updatecp$',views.workout_update_cp_view),
url(r'^workout/(?P\d+)/makepublic$',views.workout_makepublic_view),
diff --git a/rowers/views.py b/rowers/views.py
index 709e6d54..fe3635c0 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -6405,6 +6405,175 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
return HttpResponseRedirect(url)
+# The basic edit page
+@login_required()
+def workout_edit_view_navionics(request,id=0,message="",successmessage=""):
+ request.session[translation.LANGUAGE_SESSION_KEY] = USER_LANGUAGE
+ request.session['referer'] = absolute(request)['PATH']
+
+
+ try:
+ # check if valid ID exists (workout exists)
+ row = Workout.objects.get(id=id)
+ form = WorkoutForm(instance=row)
+ except Workout.DoesNotExist:
+ raise Http404("Workout doesn't exist")
+
+ if request.method == 'POST':
+ # Form was submitted
+ form = WorkoutForm(request.POST)
+ if form.is_valid():
+ # Get values from form
+ name = form.cleaned_data['name']
+ date = form.cleaned_data['date']
+ starttime = form.cleaned_data['starttime']
+ workouttype = form.cleaned_data['workouttype']
+ duration = form.cleaned_data['duration']
+ distance = form.cleaned_data['distance']
+ notes = form.cleaned_data['notes']
+ thetimezone = form.cleaned_data['timezone']
+ try:
+ boattype = request.POST['boattype']
+ except KeyError:
+ boattype = Workout.objects.get(id=id).boattype
+ try:
+ privacy = request.POST['privacy']
+ except KeyError:
+ privacy = Workout.objects.get(id=id).privacy
+ try:
+ rankingpiece = form.cleaned_data['rankingpiece']
+ except KeyError:
+ rankingpiece =- Workout.objects.get(id=id).rankingpiece
+
+ startdatetime = (str(date) + ' ' + str(starttime))
+ startdatetime = datetime.datetime.strptime(startdatetime,
+ "%Y-%m-%d %H:%M:%S")
+ startdatetime = timezone.make_aware(startdatetime)
+ startdatetime = startdatetime.astimezone(pytz.timezone(thetimezone))
+
+
+ # check if user is owner of this workout
+ if checkworkoutuser(request.user,row):
+ row.name = name
+ row.date = date
+ row.starttime = starttime
+ row.startdatetime = startdatetime
+ row.workouttype = workouttype
+ row.notes = notes
+ row.duration = duration
+ row.distance = distance
+ row.boattype = boattype
+ row.privacy = privacy
+ row.rankingpiece = rankingpiece
+ row.timezone = thetimezone
+ try:
+ row.save()
+ except IntegrityError:
+ pass
+ # change data in csv file
+
+ r = rdata(row.csvfilename)
+ if r == 0:
+ return HttpResponse("Error: CSV Data File Not Found")
+ r.rowdatetime = startdatetime
+ r.write_csv(row.csvfilename,gzip=True)
+ dataprep.update_strokedata(id,r.df)
+ successmessage = "Changes saved"
+ messages.info(request,successmessage)
+ url = reverse(workout_edit_view,
+ kwargs = {
+ 'id':str(row.id),
+ })
+ response = HttpResponseRedirect(url)
+ else:
+ message = "You are not allowed to change this workout"
+ messages.error(request,message)
+ url = reverse(workouts_view)
+
+ response = HttpResponseRedirect(url)
+
+ #else: # form not POSTed
+ form = WorkoutForm(instance=row)
+
+
+ try:
+ row = Workout.objects.get(id=id)
+ except Workout.DoesNotExist:
+ raise Http404("Workout doesn't exist")
+
+ g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
+ # check if user is owner of this workout
+
+ comments = WorkoutComment.objects.filter(workout=row)
+
+ aantalcomments = len(comments)
+
+ if (checkworkoutuser(request.user,row)==False):
+ raise Http404("You are not allowed to edit this workout")
+
+ # create interactive plot
+ 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_chart2(rowdata.df[' latitude'],
+ rowdata.df[' longitude'],
+ row.name)
+
+ #res = googlemap_chart(rowdata.df[' latitude'],
+ # rowdata.df[' longitude'],
+ # row.name)
+ #gmscript = res[0]
+ #gmdiv = res[1]
+
+ else:
+ mapscript = ""
+ mapdiv = ""
+
+
+ # render page
+ if (len(g)<=3):
+ return render(request, 'workout_form.html',
+ {'form':form,
+ 'workout':row,
+ 'teams':get_my_teams(request.user),
+ 'graphs1':g[0:3],
+ 'mapscript':mapscript,
+ 'aantalcomments':aantalcomments,
+ 'mapdiv':mapdiv,
+ })
+
+ else:
+ return render(request, 'workout_form.html',
+ {'form':form,
+ 'teams':get_my_teams(request.user),
+ 'workout':row,
+ 'graphs1':g[0:3],
+ 'graphs2':g[3:6],
+ 'mapscript':mapscript,
+ 'aantalcomments':aantalcomments,
+ 'mapdiv':mapdiv,
+ })
+
+
+ return HttpResponseRedirect(url)
+
+
+
# Create the chart image with wind corrected pace (OTW)
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
def workout_add_otw_powerplot_view(request,id):
diff --git a/templates/basebase.html b/templates/basebase.html
index 65d611f9..a627ad15 100644
--- a/templates/basebase.html
+++ b/templates/basebase.html
@@ -32,9 +32,11 @@
{% block meta %} {% endblock %}
{% leaflet_js %}
{% leaflet_css %}
+
+
{% analytical_head_bottom %}
-
+
{% analytical_body_top %}
{% block body_top %}{% endblock %}