Private
Public Access
1
0
This commit is contained in:
2024-05-22 11:02:24 +02:00
parent 38b2a71e25
commit c1a027db6b
5 changed files with 65 additions and 43 deletions

View File

@@ -3697,25 +3697,38 @@ class Workout(models.Model):
def __str__(self):
date = self.date
name = self.name
distance = str(self.distance)
ownerfirst = self.user.user.first_name
ownerlast = self.user.user.last_name
duration = self.duration
boattype = self.boattype
workouttype = self.workouttype
elements = dict(
date = self.date.strftime('%Y-%m-%d'),
name = self.name,
distance = str(self.distance),
ownerfirst = self.user.user.first_name,
ownerlast = self.user.user.last_name,
duration = self.duration.strftime("%H:%M:%S"),
boattype = self.boattype,
workouttype = self.workouttype,
seatnumber = 'seat '+str(self.seatnumber),
boatname = 'boat '+str(self.boatname),
empowerside = self.empowerside,
inboard = self.inboard,
oarlength = self.oarlength
)
if workouttype not in ['water','rower']:
if len(self.user.workoutnametemplate):
try:
stri = u'{d} {n} {dist}m {duration} {workouttype} {ownerfirst} {ownerlast}'.format(
d=date.strftime('%Y-%m-%d'),
n=name,
dist=distance,
duration=duration.strftime("%H:%M:%S"),
workouttype=workouttype,
ownerfirst=ownerfirst,
ownerlast=ownerlast,
stri = u''
for element in self.user.workoutnametemplate:
stri += u'{'+u'{element}'.format(element=element)+u'} '
stri = stri[:-1]
return stri.format(**elements)
except ValueError:
return self.name
except AttributeError:
return "No workout"
if self.workouttype not in ['water','rower']:
try:
stri = u'{date} {name} {distance}m {duration} {workouttype} {ownerfirst} {ownerlast}'.format(
**elements
)
except ValueError:
stri = self.name
@@ -3723,15 +3736,8 @@ class Workout(models.Model):
return "No workout"
else:
try:
stri = u'{d} {n} {dist}m {duration} {workouttype} {boattype} {ownerfirst} {ownerlast}'.format(
d=date.strftime('%Y-%m-%d'),
n=name,
dist=distance,
duration=duration.strftime("%H:%M:%S"),
workouttype=workouttype,
boattype=boattype,
ownerfirst=ownerfirst,
ownerlast=ownerlast,
stri = u'{date} {name} {distance}m {duration} {workouttype} {boattype} {ownerfirst} {ownerlast}'.format(
**elements
)
except (ValueError, AttributeError):
stri = self.name