Changeset 55470f9 in OpenWorkouts-current for ow/views/user.py


Ignore:
Timestamp:
Feb 8, 2019, 1:41:41 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
6edc367, 78af3d1
Parents:
c9991fed
Message:

Fixed some tests broken during the last code changes.
Fixed a bug in the calculations of the totals for the profile page
(we weren't taking in account possible None values for distance,
duration and specially elevation/uphill)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/views/user.py

    rc9991fed r55470f9  
    178178
    179179    for workout in workouts:
    180         totals['distance'] += getattr(workout, 'distance', Decimal(0))
    181         totals['time'] += getattr(workout, 'duration', timedelta(0))
    182         totals['elevation'] += getattr(workout, 'uphill', Decimal(0))
     180        totals['distance'] += (
     181            getattr(workout, 'distance', Decimal(0)) or Decimal(0))
     182        totals['time'] += (
     183            getattr(workout, 'duration', timedelta(0)) or timedelta(0))
     184        totals['elevation'] += (
     185            getattr(workout, 'uphill', Decimal(0)) or Decimal(0))
    183186
    184187    return {
Note: See TracChangeset for help on using the changeset viewer.