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)
name = models.CharField(max_length=150)
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,
default='unknown')
boattype = models.CharField(choices=boattypes,max_length=50,
@@ -1508,7 +1509,11 @@ class Workout(models.Model):
max_length=100)
distance = models.IntegerField(default=0,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)')
csvfilename = models.CharField(blank=True,max_length=150)
uploadedtoc2 = models.IntegerField(default=0)
@@ -1794,7 +1799,7 @@ class WorkoutForm(ModelForm):
# duration = forms.TimeInput(format='%H:%M:%S.%f')
class Meta:
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 = {
'date': AdminDateWidget(),
'notes': forms.Textarea,
@@ -1806,7 +1811,7 @@ class WorkoutForm(ModelForm):
# this line to be removed
del self.fields['privacy']
if self.instance.workouttype != 'water':
if self.instance.workouttype not in types.otwtypes:
del self.fields['boattype']
fieldorder = (