Workout edit field has boat type for OTW
This commit is contained in:
@@ -344,12 +344,17 @@ class WorkoutForm(ModelForm):
|
|||||||
duration = forms.TimeInput(format='%H:%M:%S.%f')
|
duration = forms.TimeInput(format='%H:%M:%S.%f')
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Workout
|
model = Workout
|
||||||
fields = ['name','date','starttime','duration','distance','workouttype','notes']
|
fields = ['name','date','starttime','duration','distance','workouttype','boattype','notes']
|
||||||
widgets = {
|
widgets = {
|
||||||
'date': DateInput(),
|
'date': DateInput(),
|
||||||
'notes': forms.Textarea,
|
'notes': forms.Textarea,
|
||||||
'duration': forms.TimeInput(format='%H:%M:%S.%f'),
|
'duration': forms.TimeInput(format='%H:%M:%S.%f'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(WorkoutForm, self).__init__(*args, **kwargs)
|
||||||
|
if self.instance.workouttype != 'water':
|
||||||
|
del self.fields['boattype']
|
||||||
|
|
||||||
class AdvancedWorkoutForm(ModelForm):
|
class AdvancedWorkoutForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
@@ -3037,6 +3037,10 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
duration = form.cleaned_data['duration']
|
duration = form.cleaned_data['duration']
|
||||||
distance = form.cleaned_data['distance']
|
distance = form.cleaned_data['distance']
|
||||||
notes = form.cleaned_data['notes']
|
notes = form.cleaned_data['notes']
|
||||||
|
try:
|
||||||
|
boattype = request.POST['boattype']
|
||||||
|
except KeyError:
|
||||||
|
boattype = Workout.objects.get(id=id).boattype
|
||||||
startdatetime = (str(date) + ' ' + str(starttime))
|
startdatetime = (str(date) + ' ' + str(starttime))
|
||||||
startdatetime = datetime.datetime.strptime(startdatetime,
|
startdatetime = datetime.datetime.strptime(startdatetime,
|
||||||
"%Y-%m-%d %H:%M:%S")
|
"%Y-%m-%d %H:%M:%S")
|
||||||
@@ -3054,6 +3058,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
row.notes = notes
|
row.notes = notes
|
||||||
row.duration = duration
|
row.duration = duration
|
||||||
row.distance = distance
|
row.distance = distance
|
||||||
|
row.boattype = boattype
|
||||||
row.save()
|
row.save()
|
||||||
# change data in csv file
|
# change data in csv file
|
||||||
# startdatetime = dateutil.parser.parse("{}, {}".format(date,starttime))
|
# startdatetime = dateutil.parser.parse("{}, {}".format(date,starttime))
|
||||||
|
|||||||
Reference in New Issue
Block a user