source: OpenWorkouts-current/ow/template_helpers.py @ 2f8a48f

currentfeature/docs
Last change on this file since 2f8a48f was 2f8a48f, checked in by borja <borja@…>, 5 years ago

(#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.

  • Property mode set to 100644
File size: 225 bytes
Line 
1from pyramid.events import subscriber, BeforeRender
2
3from ow.utilities import timedelta_to_hms
4
5
6@subscriber(BeforeRender)
7def add_renderer_globals(event):  # pragma: no cover
8    event['timedelta_to_hms'] = timedelta_to_hms
Note: See TracBrowser for help on using the repository browser.