Private
Public Access
1
0

improved workout edit form

This commit is contained in:
Sander Roosendaal
2018-06-07 20:32:03 +02:00
parent e054b0d1a0
commit a329b8b94e
3 changed files with 11 additions and 5 deletions

View File

@@ -1495,7 +1495,8 @@ class Workout(models.Model):
plannedsession = models.ForeignKey(PlannedSession, blank=True,null=True) plannedsession = models.ForeignKey(PlannedSession, blank=True,null=True)
name = models.CharField(max_length=150) name = models.CharField(max_length=150)
date = models.DateField() date = models.DateField()
workouttype = models.CharField(choices=workouttypes,max_length=50) workouttype = models.CharField(choices=workouttypes,max_length=50,
verbose_name='Exercise/Boat Class')
workoutsource = models.CharField(max_length=100, workoutsource = models.CharField(max_length=100,
default='unknown') default='unknown')
boattype = models.CharField(choices=boattypes,max_length=50, boattype = models.CharField(choices=boattypes,max_length=50,
@@ -1508,7 +1509,11 @@ class Workout(models.Model):
max_length=100) max_length=100)
distance = models.IntegerField(default=0,blank=True) distance = models.IntegerField(default=0,blank=True)
duration = models.TimeField(default=1,blank=True) duration = models.TimeField(default=1,blank=True)
weightcategory = models.CharField(default="hwt",max_length=10,choices=weightcategories) weightcategory = models.CharField(
default="hwt",
max_length=10,
choices=weightcategories,
verbose_name='Weight Category')
weightvalue = models.FloatField(default=80.0,blank=True,verbose_name = 'Average Crew Weight (kg)') weightvalue = models.FloatField(default=80.0,blank=True,verbose_name = 'Average Crew Weight (kg)')
csvfilename = models.CharField(blank=True,max_length=150) csvfilename = models.CharField(blank=True,max_length=150)
uploadedtoc2 = models.IntegerField(default=0) uploadedtoc2 = models.IntegerField(default=0)
@@ -1794,7 +1799,7 @@ 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','timezone','duration','distance','workouttype','weightcategory','notes','privacy','rankingpiece','boattype'] fields = ['name','date','starttime','timezone','duration','distance','workouttype','boattype','weightcategory','notes','privacy','rankingpiece']
widgets = { widgets = {
'date': AdminDateWidget(), 'date': AdminDateWidget(),
'notes': forms.Textarea, 'notes': forms.Textarea,
@@ -1806,7 +1811,7 @@ class WorkoutForm(ModelForm):
# this line to be removed # this line to be removed
del self.fields['privacy'] del self.fields['privacy']
if self.instance.workouttype != 'water': if self.instance.workouttype not in types.otwtypes:
del self.fields['boattype'] del self.fields['boattype']
fieldorder = ( fieldorder = (

View File

@@ -1,5 +1,5 @@
workouttypes = ( workouttypes = (
('water','On-water - Olympic'), ('water','Standard Racing Shell'),
('rower','Indoor Rower'), ('rower','Indoor Rower'),
('skierg','Ski Erg'), ('skierg','Ski Erg'),
('dynamic','Dynamic Indoor Rower'), ('dynamic','Dynamic Indoor Rower'),

View File

@@ -9192,6 +9192,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
distance = form.cleaned_data['distance'] distance = form.cleaned_data['distance']
notes = form.cleaned_data['notes'] notes = form.cleaned_data['notes']
thetimezone = form.cleaned_data['timezone'] thetimezone = form.cleaned_data['timezone']
try: try:
boattype = request.POST['boattype'] boattype = request.POST['boattype']
except KeyError: except KeyError: