Changeset 2f8a48f in OpenWorkouts-current for ow/models/workout.py


Ignore:
Timestamp:
Jan 25, 2019, 12:38:55 AM (5 years ago)
Author:
borja <borja@…>
Branches:
current, feature/docs, master
Children:
421f05f
Parents:
6d1b54b
Message:

(#7) Added several methods to the User model to gather some stats (yearly,

monthly, weekly).

Added two new utilities:

  • timedelta_to_hms (so we can print timedelta objects properly in template code)
  • get_week_days (returns a list of datetime objects for the days in the same week as a given day)

Added a template_helpers module, containing code that affects template
rendering.

Added timedelta_to_hms as a global to the default template rendering context

Refactored some code in the Workout model so it uses timedelta_to_hms instead
of running the same code twice.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/models/workout.py

    r6d1b54b r2f8a48f  
    1313    create_blob,
    1414    mps_to_kmph,
    15     save_map_screenshot
     15    save_map_screenshot,
     16    timedelta_to_hms
    1617)
    1718
     
    110111
    111112    def split_duration(self):
    112         hours, remainder = divmod(int(self.duration.total_seconds()), 3600)
    113         minutes, seconds = divmod(remainder, 60)
    114         return hours, minutes, seconds
     113        return timedelta_to_hms(self.duration)
    115114
    116115    @property
Note: See TracChangeset for help on using the changeset viewer.