Merge branch 'release/v1.1'
This commit is contained in:
@@ -891,7 +891,8 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
|
|||||||
|
|
||||||
|
|
||||||
yparamname1 = axlabels[yparam1]
|
yparamname1 = axlabels[yparam1]
|
||||||
yparamname2 = axlabels[yparam2]
|
if yparam2 != 'None':
|
||||||
|
yparamname2 = axlabels[yparam2]
|
||||||
|
|
||||||
|
|
||||||
datadf = datadf[datadf[yparam1] > 0]
|
datadf = datadf[datadf[yparam1] > 0]
|
||||||
@@ -1668,8 +1669,6 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line',
|
|||||||
if yparam != 'time' and yparam != 'pace':
|
if yparam != 'time' and yparam != 'pace':
|
||||||
plot.add_layout(ylabel)
|
plot.add_layout(ylabel)
|
||||||
|
|
||||||
print cntr,id,len(group),ymean
|
|
||||||
|
|
||||||
source = ColumnDataSource(
|
source = ColumnDataSource(
|
||||||
group
|
group
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -393,7 +393,7 @@ class Workout(models.Model):
|
|||||||
maxhr = models.IntegerField(blank=True,null=True)
|
maxhr = models.IntegerField(blank=True,null=True)
|
||||||
uploadedtostrava = models.IntegerField(default=0)
|
uploadedtostrava = models.IntegerField(default=0)
|
||||||
uploadedtosporttracks = models.IntegerField(default=0)
|
uploadedtosporttracks = models.IntegerField(default=0)
|
||||||
notes = models.CharField(blank=True,null=True,max_length=200)
|
notes = models.CharField(blank=True,null=True,max_length=1000)
|
||||||
summary = models.TextField(blank=True)
|
summary = models.TextField(blank=True)
|
||||||
privacy = models.CharField(default='visible',max_length=30,
|
privacy = models.CharField(default='visible',max_length=30,
|
||||||
choices=privacychoices)
|
choices=privacychoices)
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
<div id="workouts_table" class="grid_8 alpha">
|
<div id="workouts_table" class="grid_8 alpha">
|
||||||
{% if team %}
|
{% if team %}
|
||||||
|
{% include "teambuttons.html" with teamid=team.id %}
|
||||||
<h3>{{ team.name }} Team Workouts</h3>
|
<h3>{{ team.name }} Team Workouts</h3>
|
||||||
{% else %}
|
{% else %}
|
||||||
<h3>My Workouts</h3>
|
<h3>My Workouts</h3>
|
||||||
|
|||||||
@@ -34,25 +34,33 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<div id="workouts" class="grid_12 alpha">
|
<div id="workouts" class="grid_8 alpha">
|
||||||
<h1>Interactive Comparison</h1>
|
<h1>Interactive Comparison</h1>
|
||||||
<div class="grid_2 alpha">
|
<div class="grid_8 alpha">
|
||||||
<a class="button gray small" href="/rowers/list-workouts/team/{{ teamid }}/">Team Workouts</a>
|
{% include "teambuttons.html" with teamid=teamid%}
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_2">
|
</div>
|
||||||
<a class="button gray small" href="/rowers/team-compare-select/team/{{ teamid }}/">Multi Compare</a>
|
<div class="grid_4 omega">
|
||||||
</div>
|
<form enctype="multipart/form-data" action="/rowers/multi-compare" method="post">
|
||||||
<div class="grid_2 suffix_6 omega">
|
{% csrf_token %}
|
||||||
<a class="button gray small" href="/rowers/team/{{ teamid }}/">Team Page</a>
|
<table>
|
||||||
</div>
|
{{ chartform.as_table }}
|
||||||
<div class="grid_12 alpha">
|
</table>
|
||||||
|
<div class="grid_1 prefix_2 suffix_1">
|
||||||
|
<p>
|
||||||
|
<input name='workoutselectform' class="button green" type="submit" value="Submit">
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="grid_12 alpha">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div id="theplot" class="grid_12 alpha flexplot">
|
<div id="theplot" class="grid_12 alpha flexplot">
|
||||||
{{ the_div|safe }}
|
{{ the_div|safe }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
+41
-31
@@ -5,30 +5,40 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="grid_12 alpha">
|
<div class="grid_12 alpha">
|
||||||
<h1>{{ team.name }}</h1>
|
<h1>{{ team.name }}</h1>
|
||||||
<p>{{ team.notes }}</p>
|
<div class="grid_8 alpha">
|
||||||
<p><b>Manager:</b> {{ team.manager.first_name }} {{ team.manager.last_name }}</p>
|
{% include "teambuttons.html" with teamid=team.id %}
|
||||||
|
</div>
|
||||||
|
<div class="grid_4 omega">
|
||||||
|
<p>{{ team.notes }}</p>
|
||||||
|
<p><b>Manager:</b> {{ team.manager.first_name }} {{ team.manager.last_name }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid_12 alpha">
|
||||||
{% if ismember %}
|
{% if ismember %}
|
||||||
<div class="grid_2 alpha">
|
<div class="grid_2 alpha">
|
||||||
<a class="button red small" href="/rowers/team/{{ team.id }}/leaveconfirm">Leave this team</a>
|
<a class="button red small" href="/rowers/team/{{ team.id }}/leaveconfirm">Leave this team</a>
|
||||||
</div>
|
</div>
|
||||||
{% if team.manager == user %}
|
{% if team.manager == user %}
|
||||||
<div class="grid_2 suffix_8 omega">
|
<div class="grid_2 suffix_8 omega">
|
||||||
<a class="button blue small" href="/rowers/team/{{ team.id }}/edit">Edit Team</a>
|
<a class="button blue small" href="/rowers/team/{{ team.id }}/edit">Edit Team</a>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="grid_2 suffix_8 omega">
|
<div class="grid_2 suffix_8 omega">
|
||||||
<p>
|
<p>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif hasrequested %}
|
{% elif hasrequested %}
|
||||||
<p>You have requested access to this team</p>
|
<p>You have requested access to this team</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="grid_2 suffix_10 alpha tooltip">
|
<div class="grid_2 suffix_10 alpha tooltip">
|
||||||
<a class="button green small" href="/rowers/team/{{ team.id }}/requestmembership/{{ user.id }}">Join</a>
|
<a class="button green small" href="/rowers/team/{{ team.id }}/requestmembership/{{ user.id }}">Join</a>
|
||||||
<span class="tooltiptext">A request will be sent to the team manager</span>
|
<span class="tooltiptext">A request will be sent to the team manager</span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
<div class="grid_12 alpha">
|
||||||
{% endif %}
|
|
||||||
<div class="grid_6 alpha">
|
<div class="grid_6 alpha">
|
||||||
<p>
|
<p>
|
||||||
<h2>Members</h2>
|
<h2>Members</h2>
|
||||||
@@ -59,19 +69,19 @@
|
|||||||
<div class="grid_6 omega">
|
<div class="grid_6 omega">
|
||||||
{% if team.manager == user %}
|
{% if team.manager == user %}
|
||||||
<p>Use the form to add a new user. You can either select a user from the list of your existing club members who are not on this team yet, or you can type the user's email address, which also works for users who have not registered to the site yet.</p>
|
<p>Use the form to add a new user. You can either select a user from the list of your existing club members who are not on this team yet, or you can type the user's email address, which also works for users who have not registered to the site yet.</p>
|
||||||
{% if inviteform.errors %}
|
{% if inviteform.errors %}
|
||||||
<p style="color: red;">
|
<p style="color: red;">
|
||||||
Please correct the error{{ inviteform.errors|pluralize }} below.
|
Please correct the error{{ inviteform.errors|pluralize }} below.
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
|
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
|
||||||
<table>
|
<table>
|
||||||
{{ inviteform.as_table }}
|
{{ inviteform.as_table }}
|
||||||
</table>
|
</table>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div id="formbutton" class="grid_1 prefix_4 suffix_1">
|
<div id="formbutton" class="grid_1 prefix_4 suffix_1">
|
||||||
<input class="button green" type="submit" value="Submit">
|
<input class="button green" type="submit" value="Submit">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -8,8 +8,15 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="grid_12">
|
<div class="grid_12">
|
||||||
|
<div class="grid_8 suffix_4">
|
||||||
<div class="grid_4 alpha">
|
{% include "teambuttons.html" with teamid=teamid%}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid_12 alpha">
|
||||||
|
<h3>{{ team.name }} Team Workouts</h3>
|
||||||
|
</div>
|
||||||
|
<div class="grid_12 alpha">
|
||||||
|
<div class="grid_4 alpha">
|
||||||
|
|
||||||
{% if team %}
|
{% if team %}
|
||||||
<form enctype="multipart/form-data" action="/rowers/team-compare-select/team/{{ team.id }}/" method="post">
|
<form enctype="multipart/form-data" action="/rowers/team-compare-select/team/{{ team.id }}/" method="post">
|
||||||
@@ -46,9 +53,6 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid_12 alpha">
|
|
||||||
<h3>{{ team.name }} Team Workouts</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form enctype="multipart/form-data" action="/rowers/multi-compare" method="post">
|
<form enctype="multipart/form-data" action="/rowers/multi-compare" method="post">
|
||||||
<div id="workouts_table" class="grid_8 alpha">
|
<div id="workouts_table" class="grid_8 alpha">
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<div class="grid_2 alpha">
|
||||||
|
<a class="button gray small" href="/rowers/list-workouts/team/{{ teamid }}/">Team Workouts</a>
|
||||||
|
</div>
|
||||||
|
<div class="grid_2">
|
||||||
|
<a class="button gray small" href="/rowers/team-compare-select/team/{{ teamid }}/">Multi Compare</a>
|
||||||
|
</div>
|
||||||
|
<div class="grid_2 suffix_2 omega">
|
||||||
|
<a class="button gray small" href="/rowers/team/{{ teamid }}/">Team Page</a>
|
||||||
|
</div>
|
||||||
+1
-3
@@ -580,9 +580,7 @@ class ViewTest(TestCase):
|
|||||||
form = WorkoutForm(data=form_data)
|
form = WorkoutForm(data=form_data)
|
||||||
self.assertTrue(form.is_valid())
|
self.assertTrue(form.is_valid())
|
||||||
response = self.c.post('/rowers/workout/1/edit', form_data, follow=True)
|
response = self.c.post('/rowers/workout/1/edit', form_data, follow=True)
|
||||||
self.assertRedirects(response,
|
self.assertEqual(response.status_code, 200)
|
||||||
expected_url='/rowers/workout/1/edit/s/Changes%20saved',
|
|
||||||
status_code=302,target_status_code=200)
|
|
||||||
|
|
||||||
|
|
||||||
w = Workout.objects.get(id=1)
|
w = Workout.objects.get(id=1)
|
||||||
|
|||||||
+148
-132
@@ -357,7 +357,7 @@ def add_workout_from_strokedata(user,importid,data,strokedata,
|
|||||||
except:
|
except:
|
||||||
title = 'Imported'
|
title = 'Imported'
|
||||||
|
|
||||||
starttimeunix = mktime(rowdatetime.timetuple())
|
starttimeunix = mktime(rowdatetime.utctimetuple())
|
||||||
|
|
||||||
res = make_cumvalues(0.1*strokedata['t'])
|
res = make_cumvalues(0.1*strokedata['t'])
|
||||||
cum_time = res[0]
|
cum_time = res[0]
|
||||||
@@ -521,7 +521,7 @@ def add_workout_from_stdata(user,importid,data):
|
|||||||
except:
|
except:
|
||||||
title = "Imported data"
|
title = "Imported data"
|
||||||
|
|
||||||
starttimeunix = mktime(rowdatetime.timetuple())
|
starttimeunix = mktime(rowdatetime.utctimetuple())
|
||||||
|
|
||||||
res = splitstdata(data['distance'])
|
res = splitstdata(data['distance'])
|
||||||
|
|
||||||
@@ -2057,9 +2057,14 @@ def multi_compare_view(request):
|
|||||||
r = Rower.objects.get(user=request.user)
|
r = Rower.objects.get(user=request.user)
|
||||||
result = request.user.is_authenticated() and ispromember(request.user)
|
result = request.user.is_authenticated() and ispromember(request.user)
|
||||||
if result:
|
if result:
|
||||||
promember=1
|
promember=1
|
||||||
|
|
||||||
if request.method == 'POST':
|
if 'ids' in request.session:
|
||||||
|
print request.session['ids']
|
||||||
|
|
||||||
|
print request.POST
|
||||||
|
|
||||||
|
if request.method == 'POST' and 'workouts' in request.POST:
|
||||||
form = WorkoutMultipleCompareForm(request.POST)
|
form = WorkoutMultipleCompareForm(request.POST)
|
||||||
chartform = ChartParamChoiceForm(request.POST)
|
chartform = ChartParamChoiceForm(request.POST)
|
||||||
if form.is_valid() and chartform.is_valid():
|
if form.is_valid() and chartform.is_valid():
|
||||||
@@ -2070,6 +2075,8 @@ def multi_compare_view(request):
|
|||||||
plottype = chartform.cleaned_data['plottype']
|
plottype = chartform.cleaned_data['plottype']
|
||||||
teamid = chartform.cleaned_data['teamid']
|
teamid = chartform.cleaned_data['teamid']
|
||||||
ids = [int(w.id) for w in workouts]
|
ids = [int(w.id) for w in workouts]
|
||||||
|
request.session['ids'] = ids
|
||||||
|
|
||||||
labeldict = {
|
labeldict = {
|
||||||
int(w.id): w.__unicode__() for w in workouts
|
int(w.id): w.__unicode__() for w in workouts
|
||||||
}
|
}
|
||||||
@@ -2086,9 +2093,40 @@ def multi_compare_view(request):
|
|||||||
'the_div':div,
|
'the_div':div,
|
||||||
'promember':promember,
|
'promember':promember,
|
||||||
'teamid':teamid,
|
'teamid':teamid,
|
||||||
|
'chartform':chartform,
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
return HttpResponse("Form is not valid")
|
return HttpResponse("Form is not valid")
|
||||||
|
if request.method == 'POST' and 'ids' in request.session:
|
||||||
|
chartform = ChartParamChoiceForm(request.POST)
|
||||||
|
if chartform.is_valid():
|
||||||
|
xparam = chartform.cleaned_data['xparam']
|
||||||
|
yparam = chartform.cleaned_data['yparam']
|
||||||
|
plottype = chartform.cleaned_data['plottype']
|
||||||
|
teamid = chartform.cleaned_data['teamid']
|
||||||
|
ids = request.session['ids']
|
||||||
|
request.session['ids'] = ids
|
||||||
|
workouts = [Workout.objects.get(id=id) for id in ids]
|
||||||
|
|
||||||
|
labeldict = {
|
||||||
|
int(w.id): w.__unicode__() for w in workouts
|
||||||
|
}
|
||||||
|
|
||||||
|
res = interactive_multiple_compare_chart(ids,xparam,yparam,
|
||||||
|
promember=promember,
|
||||||
|
plottype=plottype,
|
||||||
|
labeldict=labeldict)
|
||||||
|
script = res[0]
|
||||||
|
div = res[1]
|
||||||
|
|
||||||
|
return render(request,'multicompare.html',
|
||||||
|
{'interactiveplot':script,
|
||||||
|
'the_div':div,
|
||||||
|
'promember':promember,
|
||||||
|
'teamid':teamid,
|
||||||
|
'chartform':chartform,
|
||||||
|
})
|
||||||
|
|
||||||
else:
|
else:
|
||||||
url = reverse(workouts_view)
|
url = reverse(workouts_view)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
@@ -2469,7 +2507,7 @@ def workout_downloadwind_view(request,id=0,
|
|||||||
startdatetime = dateutil.parser.parse("{}, {}".format(row.date,
|
startdatetime = dateutil.parser.parse("{}, {}".format(row.date,
|
||||||
row.starttime))
|
row.starttime))
|
||||||
|
|
||||||
starttimeunix = int(mktime(startdatetime.timetuple()))
|
starttimeunix = int(mktime(startdatetime.utctimetuple()))
|
||||||
avgtime = starttimeunix+avgtime
|
avgtime = starttimeunix+avgtime
|
||||||
winddata = get_wind_data(avglat,avglon,avgtime)
|
winddata = get_wind_data(avglat,avglon,avgtime)
|
||||||
windspeed = winddata[0]
|
windspeed = winddata[0]
|
||||||
@@ -2533,7 +2571,7 @@ def workout_downloadmetar_view(request,id=0,
|
|||||||
startdatetime = dateutil.parser.parse("{}, {}".format(row.date,
|
startdatetime = dateutil.parser.parse("{}, {}".format(row.date,
|
||||||
row.starttime))
|
row.starttime))
|
||||||
|
|
||||||
starttimeunix = int(mktime(startdatetime.timetuple()))
|
starttimeunix = int(mktime(startdatetime.utctimetuple()))
|
||||||
avgtime = starttimeunix+avgtime
|
avgtime = starttimeunix+avgtime
|
||||||
winddata = get_metar_data(airportcode,avgtime)
|
winddata = get_metar_data(airportcode,avgtime)
|
||||||
windspeed = winddata[0]
|
windspeed = winddata[0]
|
||||||
@@ -3597,6 +3635,12 @@ def workout_comment_view(request,id=0):
|
|||||||
def workout_edit_view(request,id=0,message="",successmessage=""):
|
def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||||
request.session[translation.LANGUAGE_SESSION_KEY] = USER_LANGUAGE
|
request.session[translation.LANGUAGE_SESSION_KEY] = USER_LANGUAGE
|
||||||
|
|
||||||
|
try:
|
||||||
|
# check if valid ID exists (workout exists)
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
# Form was submitted
|
# Form was submitted
|
||||||
form = WorkoutForm(request.POST)
|
form = WorkoutForm(request.POST)
|
||||||
@@ -3621,137 +3665,111 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
startdatetime = datetime.datetime.strptime(startdatetime,
|
startdatetime = datetime.datetime.strptime(startdatetime,
|
||||||
"%Y-%m-%d %H:%M:%S")
|
"%Y-%m-%d %H:%M:%S")
|
||||||
startdatetime = timezone.make_aware(startdatetime)
|
startdatetime = timezone.make_aware(startdatetime)
|
||||||
try:
|
# check if user is owner of this workout
|
||||||
# check if valid ID exists (workout exists)
|
if checkworkoutuser(request.user,row):
|
||||||
row = Workout.objects.get(id=id)
|
row.name = name
|
||||||
# check if user is owner of this workout
|
row.date = date
|
||||||
if checkworkoutuser(request.user,row):
|
row.starttime = starttime
|
||||||
row.name = name
|
row.startdatetime = startdatetime
|
||||||
row.date = date
|
row.workouttype = workouttype
|
||||||
row.starttime = starttime
|
row.notes = notes
|
||||||
row.startdatetime = startdatetime
|
row.duration = duration
|
||||||
row.workouttype = workouttype
|
row.distance = distance
|
||||||
row.notes = notes
|
row.boattype = boattype
|
||||||
row.duration = duration
|
row.privacy = privacy
|
||||||
row.distance = distance
|
row.save()
|
||||||
row.boattype = boattype
|
# change data in csv file
|
||||||
row.privacy = privacy
|
|
||||||
row.save()
|
|
||||||
# change data in csv file
|
|
||||||
|
|
||||||
r = rdata(row.csvfilename)
|
r = rdata(row.csvfilename)
|
||||||
if r == 0:
|
if r == 0:
|
||||||
return HttpResponse("Error: CSV Data File Not Found")
|
return HttpResponse("Error: CSV Data File Not Found")
|
||||||
r.rowdatetime = startdatetime
|
r.rowdatetime = startdatetime
|
||||||
r.write_csv(row.csvfilename,gzip=True)
|
r.write_csv(row.csvfilename,gzip=True)
|
||||||
dataprep.update_strokedata(id,r.df)
|
dataprep.update_strokedata(id,r.df)
|
||||||
successmessage = "Changes saved"
|
successmessage = "Changes saved"
|
||||||
url = "/rowers/workout/"+str(row.id)+"/edit"
|
url = "/rowers/workout/"+str(row.id)+"/edit"
|
||||||
url = reverse(workout_edit_view,
|
url = reverse(workout_edit_view,
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'id':str(row.id),
|
'id':str(row.id),
|
||||||
'successmessage':str(successmessage),
|
'successmessage':str(successmessage),
|
||||||
})
|
})
|
||||||
response = HttpResponseRedirect(url)
|
response = HttpResponseRedirect(url)
|
||||||
else:
|
else:
|
||||||
message = "You are not allowed to change this workout"
|
message = "You are not allowed to change this workout"
|
||||||
url = reverse(workouts_view,args=[str(message)])
|
url = reverse(workouts_view,args=[str(message)])
|
||||||
|
|
||||||
response = HttpResponseRedirect(url)
|
response = HttpResponseRedirect(url)
|
||||||
except Workout.DoesNotExist:
|
|
||||||
# create new workout
|
|
||||||
r = Rower.objects.get(user=request.user)
|
|
||||||
w = Workout(name=name,date=date,workouttype=workouttype,
|
|
||||||
user=r)
|
|
||||||
w.save()
|
|
||||||
successmessage = "New Workout Created"
|
|
||||||
url = reverse(workouts_view,
|
|
||||||
kwargs = {
|
|
||||||
'successmessage':str(successmessage),
|
|
||||||
})
|
|
||||||
|
|
||||||
response = HttpResponseRedirect(url)
|
else: # form not POSTed
|
||||||
else:
|
form = WorkoutForm(instance=row)
|
||||||
message = "Invalid Form"
|
|
||||||
url = reverse(workouts_view,args=[str(message)])
|
|
||||||
response = HttpResponseRedirect(url)
|
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
|
||||||
|
|
||||||
|
if (checkworkoutuser(request.user,row)==False):
|
||||||
|
raise Http404("You are not allowed to edit this workout")
|
||||||
|
|
||||||
|
# create interactive plot
|
||||||
|
f1 = row.csvfilename
|
||||||
|
u = request.user
|
||||||
|
r = Rower.objects.get(user=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
|
||||||
|
|
||||||
return response
|
|
||||||
else:
|
else:
|
||||||
try:
|
hascoordinates = 0
|
||||||
row = Workout.objects.get(id=id)
|
|
||||||
form = WorkoutForm(instance=row)
|
|
||||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
|
||||||
# check if user is owner of this workout
|
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,row)==False):
|
|
||||||
message = "You are not allowed to edit this workout"
|
|
||||||
url = reverse(workouts_view,args=[str(message)])
|
|
||||||
|
|
||||||
return HttpResponseRedirect(url)
|
|
||||||
|
|
||||||
else:
|
|
||||||
# create interactive plot
|
|
||||||
f1 = row.csvfilename
|
|
||||||
u = request.user
|
|
||||||
r = Rower.objects.get(user=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:
|
|
||||||
res = googlemap_chart(rowdata.df[' latitude'],
|
|
||||||
rowdata.df[' longitude'],
|
|
||||||
row.name)
|
|
||||||
gmscript = res[0]
|
|
||||||
gmdiv = res[1]
|
|
||||||
else:
|
|
||||||
gmscript = ""
|
|
||||||
gmdiv = ""
|
|
||||||
|
|
||||||
|
|
||||||
# render page
|
|
||||||
if (len(g)<=3):
|
|
||||||
return render(request, 'workout_form.html',
|
|
||||||
{'form':form,
|
|
||||||
'workout':row,
|
|
||||||
'graphs1':g[0:3],
|
|
||||||
'message': message,
|
|
||||||
'successmessage': successmessage,
|
|
||||||
'gmscript': gmscript,
|
|
||||||
'gmdiv': gmdiv,
|
|
||||||
})
|
|
||||||
|
|
||||||
else:
|
|
||||||
return render(request, 'workout_form.html',
|
|
||||||
{'form':form,
|
|
||||||
'workout':row,
|
|
||||||
'graphs1':g[0:3],
|
|
||||||
'graphs2':g[3:6],
|
|
||||||
'message': message,
|
|
||||||
'successmessage': successmessage,
|
|
||||||
'gmscript': gmscript,
|
|
||||||
'gmdiv': gmdiv,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
except Workout.DoesNotExist:
|
if hascoordinates:
|
||||||
message = "workout doesn't exist"
|
res = googlemap_chart(rowdata.df[' latitude'],
|
||||||
url = reverse(workouts_view,
|
rowdata.df[' longitude'],
|
||||||
kwargs = {
|
row.name)
|
||||||
'message': str(message)
|
gmscript = res[0]
|
||||||
})
|
gmdiv = res[1]
|
||||||
return HttpResponseRedirect(url)
|
else:
|
||||||
|
gmscript = ""
|
||||||
|
gmdiv = ""
|
||||||
|
|
||||||
|
|
||||||
|
# render page
|
||||||
|
if (len(g)<=3):
|
||||||
|
return render(request, 'workout_form.html',
|
||||||
|
{'form':form,
|
||||||
|
'workout':row,
|
||||||
|
'graphs1':g[0:3],
|
||||||
|
'message': message,
|
||||||
|
'successmessage': successmessage,
|
||||||
|
'gmscript': gmscript,
|
||||||
|
'gmdiv': gmdiv,
|
||||||
|
})
|
||||||
|
|
||||||
|
else:
|
||||||
|
return render(request, 'workout_form.html',
|
||||||
|
{'form':form,
|
||||||
|
'workout':row,
|
||||||
|
'graphs1':g[0:3],
|
||||||
|
'graphs2':g[3:6],
|
||||||
|
'message': message,
|
||||||
|
'successmessage': successmessage,
|
||||||
|
'gmscript': gmscript,
|
||||||
|
'gmdiv': gmdiv,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
# Create the chart image with wind corrected pace (OTW)
|
# Create the chart image with wind corrected pace (OTW)
|
||||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
@@ -5645,8 +5663,6 @@ def rower_teams_view(request,message='',successmessage=''):
|
|||||||
myrequests = TeamRequest.objects.filter(team__in=myteams)
|
myrequests = TeamRequest.objects.filter(team__in=myteams)
|
||||||
myinvites = TeamInvite.objects.filter(team__in=myteams)
|
myinvites = TeamInvite.objects.filter(team__in=myteams)
|
||||||
|
|
||||||
print form
|
|
||||||
|
|
||||||
return render(request, 'teams.html',
|
return render(request, 'teams.html',
|
||||||
{
|
{
|
||||||
'teams':ts,
|
'teams':ts,
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ def get_metar_data(airportcode,unixtime):
|
|||||||
return [0,0,message,'',timestamp]
|
return [0,0,message,'',timestamp]
|
||||||
|
|
||||||
|
|
||||||
print temp_c,wind_dir,wind_speed
|
|
||||||
|
|
||||||
windbearing = float(wind_dir)
|
windbearing = float(wind_dir)
|
||||||
wind_knots = float(wind_speed)
|
wind_knots = float(wind_speed)
|
||||||
wind_ms = 0.514444*wind_knots
|
wind_ms = 0.514444*wind_knots
|
||||||
|
|||||||
Reference in New Issue
Block a user