join works
This commit is contained in:
@@ -188,8 +188,11 @@ def join_workouts(r,ids,title='Joined Workout',
|
|||||||
makeprivate = False
|
makeprivate = False
|
||||||
startdatetime = timezone.now()
|
startdatetime = timezone.now()
|
||||||
|
|
||||||
if setprivate:
|
if setprivate == True and makeprivate == False:
|
||||||
makeprivate = True
|
makeprivate = True
|
||||||
|
elif setprivate == False and makeprivate == True:
|
||||||
|
makeprivate = False
|
||||||
|
|
||||||
|
|
||||||
# reorder in chronological order
|
# reorder in chronological order
|
||||||
ws = Workout.objects.filter(id__in=ids).order_by("date", "starttime")
|
ws = Workout.objects.filter(id__in=ids).order_by("date", "starttime")
|
||||||
@@ -864,6 +867,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
|||||||
pytz.timezone(timezone_str)
|
pytz.timezone(timezone_str)
|
||||||
).strftime('%H:%M:%S')
|
).strftime('%H:%M:%S')
|
||||||
|
|
||||||
|
|
||||||
if makeprivate:
|
if makeprivate:
|
||||||
privacy = 'hidden'
|
privacy = 'hidden'
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -522,6 +522,10 @@ class ChartParamChoiceForm(forms.Form):
|
|||||||
formaxlabels.pop('time')
|
formaxlabels.pop('time')
|
||||||
metricchoices = list(sorted(formaxlabels.items(), key = lambda x:x[1]))
|
metricchoices = list(sorted(formaxlabels.items(), key = lambda x:x[1]))
|
||||||
|
|
||||||
|
class WorkoutJoinParamForm(forms.Form):
|
||||||
|
workout_name = forms.CharField(required = True, initial = 'Joined Workout')
|
||||||
|
set_private = forms.BooleanField(initial=False, required = False)
|
||||||
|
|
||||||
class FusionMetricChoiceForm(ModelForm):
|
class FusionMetricChoiceForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Workout
|
model = Workout
|
||||||
|
|||||||
@@ -147,6 +147,9 @@
|
|||||||
<p><b>Warning: You are on an experimental part of the site. Use at your own risk.</b></p>
|
<p><b>Warning: You are on an experimental part of the site. Use at your own risk.</b></p>
|
||||||
<p>Select two or more workouts on the left,
|
<p>Select two or more workouts on the left,
|
||||||
and press submit</p>
|
and press submit</p>
|
||||||
|
<table>
|
||||||
|
{{ joinparamform.as_table }}
|
||||||
|
</table>
|
||||||
<div class="grid_1 prefix_2 suffix_1">
|
<div class="grid_1 prefix_2 suffix_1">
|
||||||
<p>
|
<p>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ from rowers.forms import (
|
|||||||
RegistrationFormUniqueEmail,CNsummaryForm,UpdateWindForm,
|
RegistrationFormUniqueEmail,CNsummaryForm,UpdateWindForm,
|
||||||
UpdateStreamForm,WorkoutMultipleCompareForm,ChartParamChoiceForm,
|
UpdateStreamForm,WorkoutMultipleCompareForm,ChartParamChoiceForm,
|
||||||
FusionMetricChoiceForm,BoxPlotChoiceForm,MultiFlexChoiceForm,
|
FusionMetricChoiceForm,BoxPlotChoiceForm,MultiFlexChoiceForm,
|
||||||
TrendFlexModalForm,WorkoutSplitForm,
|
TrendFlexModalForm,WorkoutSplitForm,WorkoutJoinParamForm,
|
||||||
)
|
)
|
||||||
from rowers.models import Workout, User, Rower, WorkoutForm,FavoriteChart
|
from rowers.models import Workout, User, Rower, WorkoutForm,FavoriteChart
|
||||||
from rowers.models import (
|
from rowers.models import (
|
||||||
@@ -4207,14 +4207,20 @@ def workouts_join_view(request):
|
|||||||
|
|
||||||
if request.method == 'POST' and 'workouts' in request.POST:
|
if request.method == 'POST' and 'workouts' in request.POST:
|
||||||
form = WorkoutMultipleCompareForm(request.POST)
|
form = WorkoutMultipleCompareForm(request.POST)
|
||||||
if form.is_valid():
|
paramform = WorkoutJoinParamForm(request.POST)
|
||||||
|
if form.is_valid() and paramform.is_valid():
|
||||||
|
workout_name = paramform.cleaned_data['workout_name']
|
||||||
|
set_private = paramform.cleaned_data['set_private']
|
||||||
|
|
||||||
cd = form.cleaned_data
|
cd = form.cleaned_data
|
||||||
workouts = cd['workouts']
|
workouts = cd['workouts']
|
||||||
ids = [int(w.id) for w in workouts]
|
ids = [int(w.id) for w in workouts]
|
||||||
request.session['ids'] = ids
|
request.session['ids'] = ids
|
||||||
|
|
||||||
|
|
||||||
id,message = dataprep.join_workouts(r,ids)
|
id,message = dataprep.join_workouts(r,ids,
|
||||||
|
title=workout_name,
|
||||||
|
setprivate=set_private)
|
||||||
|
|
||||||
if message:
|
if message:
|
||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
@@ -4227,7 +4233,8 @@ def workouts_join_view(request):
|
|||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return HttpResponse("Form is not valid")
|
return HttpResponse("form is not valid")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
url = reverse(workouts_join_select)
|
url = reverse(workouts_join_select)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
@@ -4368,7 +4375,7 @@ def workouts_join_select(request,
|
|||||||
else:
|
else:
|
||||||
theid = 0
|
theid = 0
|
||||||
|
|
||||||
chartform = ChartParamChoiceForm(initial={'teamid':0})
|
joinparamform = WorkoutJoinParamForm()
|
||||||
modalityform = TrendFlexModalForm(initial={
|
modalityform = TrendFlexModalForm(initial={
|
||||||
'modality':modality,
|
'modality':modality,
|
||||||
'waterboattype':waterboattype
|
'waterboattype':waterboattype
|
||||||
@@ -4385,7 +4392,7 @@ def workouts_join_select(request,
|
|||||||
'enddate':enddate,
|
'enddate':enddate,
|
||||||
'team':theteam,
|
'team':theteam,
|
||||||
'form':form,
|
'form':form,
|
||||||
'chartform':chartform,
|
'joinparamform':joinparamform,
|
||||||
'modalityform':modalityform,
|
'modalityform':modalityform,
|
||||||
'teams':get_my_teams(request.user),
|
'teams':get_my_teams(request.user),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user