small bug fixes
This commit is contained in:
@@ -93,13 +93,17 @@ class Race(models.Model):
|
||||
return self.name
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
results = self.results.all()
|
||||
crews = []
|
||||
athletes = []
|
||||
for result in results:
|
||||
crews.append(result.crew.id)
|
||||
for athlete in result.crew.athletes.all():
|
||||
athletes.append(athlete.id)
|
||||
|
||||
try:
|
||||
results = self.results.all()
|
||||
for result in results:
|
||||
crews.append(result.crew.id)
|
||||
for athlete in result.crew.athletes.all():
|
||||
athletes.append(athlete.id)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if len(crews) != len(set(crews)):
|
||||
raise ValidationError(
|
||||
|
||||
@@ -740,7 +740,10 @@ def join_workouts(r, ids, title='Joined Workout',
|
||||
while len(files):
|
||||
row2 = rdata(files[0])
|
||||
if row2 != 0 and row2 is not None:
|
||||
row = row+row2
|
||||
try:
|
||||
row = row+row2
|
||||
except TypeError: # pragma: no cover
|
||||
pass
|
||||
files = files[1:]
|
||||
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
|
||||
@@ -2963,7 +2963,10 @@ class PlannedSession(models.Model):
|
||||
if self.fitfile:
|
||||
steps = steps_read_fit(settings.MEDIA_ROOT+'/'+self.fitfile.name)
|
||||
self.steps = steps
|
||||
self.steps['workoutName'] = self.name
|
||||
try:
|
||||
self.steps['workoutName'] = self.name
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
self.save()
|
||||
|
||||
@@ -4696,6 +4699,8 @@ class WorkoutForm(ModelForm):
|
||||
cd = self.cleaned_data
|
||||
if cd['duration'] is None or cd['duration'] == '':
|
||||
raise forms.ValidationError('Duration cannot be empty')
|
||||
if cd['date'] is None or cd['date'] == '':
|
||||
raise forms.ValidationError('Date cannot be empty')
|
||||
|
||||
# Used for the rowing physics calculations
|
||||
|
||||
|
||||
@@ -329,7 +329,7 @@ def get_indoorraces(workout):
|
||||
if workout.duration is None:
|
||||
workout.duration = timedelta(0)
|
||||
|
||||
if workout.duration.second == 0 and workout.duration.microsecond == 0:
|
||||
if workout.duration.seconds == 0 and workout.duration.microseconds == 0:
|
||||
duration = 60*workout.duration.hour+workout.duration.minute
|
||||
|
||||
races2 = VirtualRace.objects.filter(
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
Reference in New Issue
Block a user