source: OpenWorkouts-current/ow/templates/workout.pt @ 31adfa5

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

(#14) Timezones support:

  • Added pytz as a new dependency, please install it in your existing envs:

pip install pytz

  • Added a timezone attribute to users, to store in which timezone they are, defaults to 'UTC'. Ensure any users you could have in your database have such attribute. You can add it in pshell:

for user in root.users:

user.timezone = 'UTC'

request.tm.commit()

  • Modified schemas/templates/views to let users choose their timezone based on a list of "common" timezones provided by pytz
  • Added two methods to the Workout model so we can get the start and end dates formatted in the appropiate timezone (all datetime objects are stored in UTC)
  • Modified the templates where we show workout dates and times so the new timezone-formatting methods are used.
  • Property mode set to 100644
File size: 6.2 KB
Line 
1<html xmlns="http://www.w3.org/1999/xhtml"
2      xml:lang="en"
3      xmlns:tal="http://xml.zope.org/namespaces/tal"
4      xmlns:metal="http://xml.zope.org/namespaces/metal"
5      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
6      i18n:domain="OpenWorkouts"
7      metal:use-macro="load: base.pt"
8      tal:attributes="lang request.locale_name">
9
10  <metal:head-title metal:fill-slot="head-title">
11    <tal:t i18n:translate="">Workout details</tal:t>:
12    <tal:c tal:content="context.title"></tal:c>
13  </metal:head-title>
14
15  <metal:css metal:fill-slot="css">
16    <link rel="stylesheet" tal:condition="context.has_gpx"
17          href="${request.static_url('ow:static/components/Leaflet/leaflet.css')}" />
18    <link rel="stylesheet" tal:condition="context.has_gpx"
19          href="${request.static_url('ow:static/components/Leaflet.Elevation/dist/leaflet.elevation-0.0.4.css')}" />
20
21    <!--!
22    <link rel="stylesheet" tal:condition="context.has_gpx"
23          href="${request.static_url('ow:static/leaflet-elevation/leaflet.elevation.css')}" />
24
25    <link rel="stylesheet" tal:condition="context.has_gpx"
26          href="${request.static_url('ow:static/leaflet-openworkouts/leaflet.openworkouts.css')}" />
27    -->
28
29  </metal:css>
30
31  <metal:title metal:fill-slot="title">
32    <tal:t i18n:translate="">Workout details</tal:t>
33  </metal:title>
34
35  <metal:content metal:fill-slot="content">
36
37    <!--! Track map -->
38    <div id="map" tal:condition="context.has_gpx"></div>
39
40    <!--! Additional map controls -->
41
42    <div id="ow-analysis">
43
44      <!--!
45          FIXME: the list of available charts should come from the workout
46          details, based on which data this workout has
47        -->
48      <!--! All those ids are needed for the leaflet openworkouts plugin -->
49      <tal:r tal:repeat="chart ['elevation', 'heartrate', 'cadence', 'temperature']">
50        <div id="ow-" tal:attributes="id 'ow-' + chart">
51          <div class="ow-average" id=""
52               tal:attributes="id 'ow-' + chart + '-average'"></div>
53          <div class="ow-chart" id=""
54               tal:attributes="id 'ow-' + chart + '-chart'"></div>
55          <div class="ow-current" id=""
56               tal:attributes="id 'ow-' + chart + '-current'"></div>
57        </div>
58      </tal:r>
59
60    </div>
61
62    <div id="workout">
63      <h3 tal:content="context.title"></h3>
64      <h4>
65        <a href="" i18n:translate=""
66           tal:attributes="href request.resource_url(context, 'edit')">
67          (edit workout)
68        </a> |
69        <a href="" i18n:translate=""
70           tal:attributes="href request.resource_url(context, 'update-from-file')">
71          (update with tracking file)
72        </a> |
73        <a href="" i18n:translate=""
74           tal:attributes="href request.resource_url(context, 'delete')">
75          (delete)
76        </a>
77      </h4>
78
79      <ul id="" tal:attributes="id 'workout-' + context.workout_id + '-details'"
80          tal:define="hr context.hr; cad context.cad; timezone context.owner.timezone">
81        <li>
82          <tal:t i18n:translate="">Start:</tal:t>
83          <tal:c tal:content="context.start_in_timezone(timezone)"></tal:c>
84        </li>
85        <li>
86          <tal:t i18n:translate="">End:</tal:t>
87          <tal:c tal:content="context.end_in_timezone(timezone)"></tal:c>
88        </li>
89        <li>
90          <tal:t i18n:translate="">Duration:</tal:t>
91          <tal:c tal:content="context.duration"></tal:c>
92        </li>
93        <li tal:condition="context.distance">
94          <tal:t i18n:translate="">Distance:</tal:t>
95          <tal:c tal:content="context.rounded_distance"></tal:c> km
96        </li>
97        <li tal:condition="hr">
98          <tal:t i18n:translate="">Heart Rate:</tal:t>
99          <tal:t i18n:translate="">Min.</tal:t>
100          <tal:c tal:content="hr['min']"></tal:c> bpm |
101          <tal:t i18n:translate="">Avg.</tal:t>
102          <tal:c tal:content="hr['avg']"></tal:c> bpm |
103          <tal:t i18n:translate="">Max.</tal:t>
104          <tal:c tal:content="hr['max']"></tal:c> bpm
105        </li>
106        <li tal:condition="cad">
107          <tal:t i18n:translate="">Cadence:</tal:t>
108          <tal:t i18n:translate="">Min.</tal:t>
109          <tal:c tal:content="cad['min']"></tal:c> |
110          <tal:t i18n:translate="">Avg.</tal:t>
111          <tal:c tal:content="cad['avg']"></tal:c> |
112          <tal:t i18n:translate="">Max.</tal:t>
113          <tal:c tal:content="cad['max']"></tal:c>
114        </li>
115      </ul>
116      <div id="" tal:content="context.notes"
117           tal:attributes="id 'workout-' + context.workout_id + '-notes'">
118      </div>
119    </div>
120  </metal:content>
121
122  <metal:body-js metal:fill-slot="body-js">
123
124
125    <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
126    <!--
127    <script src="${request.static_url('ow:static/d3/d3.min.js')}"
128            tal:condition="context.has_gpx"></script>
129    -->
130
131    <script src="${request.static_url('ow:static/components/Leaflet/leaflet.js')}"
132            tal:condition="context.has_gpx"></script>
133
134    <script src="${request.static_url('ow:static/components/leaflet-gpx/gpx.js')}"
135            tal:condition="context.has_gpx"></script>
136
137    <script src="${request.static_url('ow:static/components/Leaflet.Elevation/dist/leaflet.elevation-0.0.4.min.js')}"
138            tal:condition="context.has_gpx"></script>
139
140    <!--!
141    <script src="${request.static_url('ow:static/leaflet-elevation/leaflet.elevation.min.js')}"
142            tal:condition="context.has_gpx"></script>
143    <script src="${request.static_url('ow:static/leaflet-openworkouts/leaflet.openworkouts.src.js')}"
144            tal:condition="context.has_gpx"></script>
145    -->
146    <script src="${request.static_url('ow:static/js/ow.js')}"
147            tal:condition="context.has_gpx"></script>
148
149    <script type="text/javascript" tal:condition="context.has_gpx">
150     var workout_map = owjs.map({
151         latitude: ${start_point['latitude']},
152         longitude: ${start_point['longitude']},
153         zoom: 11,
154         gpx_url: '${request.resource_url(context, 'gpx')}',
155         start_icon: '${request.static_url('ow:static/leaflet-gpx/pin-icon-start.png')}',
156         end_icon: '${request.static_url('ow:static/leaflet-gpx/pin-icon-end.png')}',
157         shadow: '${request.static_url('ow:static/leaflet-gpx/pin-shadow.png')}',
158     });
159     workout_map.render();
160    </script>
161  </metal:body-js>
162
163</html>
Note: See TracBrowser for help on using the repository browser.