Changeset 6edc367 in OpenWorkouts-current for ow


Ignore:
Timestamp:
Feb 8, 2019, 5:20:26 PM (5 years ago)
Author:
Segundo Fdez <segun.2@…>
Branches:
current, feature/docs, master
Children:
4226ce0
Parents:
2a71053 (diff), 55470f9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'feature/ui' of ssh://openworkouts/home/repos/git/OpenWorkouts-current into feature/ui

Location:
ow
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • ow/models/workout.py

    r2a71053 r6edc367  
    138138        """
    139139        if self.distance:
    140             return round(self.distance, 1)
     140            return round(self.distance, 2)
    141141        return '-'
    142142
  • ow/templates/add_manual_workout.pt

    r2a71053 r6edc367  
    88      tal:attributes="lang request.locale_name">
    99
    10   <metal:head-title metal:fill-slot="head-title">
     10  <metal:head-title metal:fill-slot="head-title" metal:define-slot="head-title">
    1111    <tal:t i18n:translate="">Add workout manually</tal:t>
    1212  </metal:head-title>
    1313
    14   <metal:title metal:fill-slot="title">
     14  <metal:title metal:fill-slot="title" metal:define-slot="head-title">
    1515    <tal:t i18n:translate="">Add workout Manually</tal:t>
    1616  </metal:title>
     
    2626    <div class="add_workout ow-forms">
    2727      <a href="" class="back"
    28              tal:attributes="href request.resource_url(context)"
    29              i18n:translate="">Back</a>
    30         <h2 i18n:translate="">Add a new workout</h2>
     28         tal:attributes="href request.resource_url(context)"
     29         i18n:translate="">Back</a>
     30
     31      <h2>
     32        <metal:form-title metal:define-slot="form-title">
     33          <tal:t i18n:translate="">Add a new workout</tal:t>
     34        </metal:form-title>
     35      </h2>
     36
    3137        ${form.begin()}
    3238        ${form.csrf_token()}
     
    4349              ${form.text('title')}
    4450          </p>
    45           <div class="input-container ly-flex ly-2 has-gap">
     51          <div class="input-container ly-flex ly-3 has-gap">
     52            <div>
     53              <label for="distance" i18n:translate="">Distance (Km):</label>
     54              ${form.errorlist('distance')}
     55              ${form.text('distance', size=4, **{'class': "number"})}
     56            </div>
    4657              <div>
    4758                  <label for="start_date" i18n:translate="">Start date (dd/mm/yyyy)</label>
     
    7384            </div>
    7485          </div>
    75 
    76           <p>
    77               <label for="distance" i18n:translate="">Distance (Km):</label>
    78               ${form.errorlist('distance')}
    79               ${form.text('distance', size=4, **{'class': "number"})}
    80           </p>
    8186          <div>
    8287            <label for="notes" i18n:translate="">Notes:</label>
  • ow/templates/delete_workout.pt

    r2a71053 r6edc367  
    3838              </li>
    3939              <li>
    40                 <tal:t i18n:translate="">End:</tal:t>
    41                 <tal:c tal:content="context.end_in_timezone(timezone)"></tal:c>
     40                <tal:t i18n:translate="">Duration:</tal:t>
     41                <tal:c tal:content="context._duration"></tal:c>
    4242              </li>
    4343              <li>
    4444                <tal:t i18n:translate="">Distance:</tal:t>
    45                 <tal:c tal:content="context.distance"></tal:c>
    46               </li>
    47               <li>
    48                 <tal:t i18n:translate="">Average Heart Rate:</tal:t>
    49                 <tal:c tal:content="context.hr_avg"></tal:c>
    50               </li>
    51               <li>
    52                 <tal:t i18n:translate="">Maximum Heart Rate:</tal:t>
    53                 <tal:c tal:content="context.hr_max"></tal:c>
     45                <tal:c tal:content="context.rounded_distance"></tal:c>
    5446              </li>
    5547            </ul>
  • ow/templates/edit_manual_workout.pt

    r2a71053 r6edc367  
    2323  </metal:title>
    2424
     25  <metal:form-title metal:fill-slot="form-title">
     26    <tal:t i18n:translate="">Edit workout</tal:t>
     27  </metal:form-title>
     28
    2529</html>
  • ow/templates/update_workout_from_file.pt

    r2a71053 r6edc367  
    2727      ${form.csrf_token()}
    2828
     29      <h2 tal:content="context.title"></h2>
     30
    2931      <div tal:condition="context.has_tracking_file"
    3032           i18n:translate="">
    31         <h2>Existing
    32         <tal:filetype i18n:name="filetype"
    33                       tal:content="context.tracking_filetype"></tal:filetype>
    34         tracking file data</h2>
    35         <p>
    36           <tal:data i18n:name="start"
    37                   tal:content="context.start"></tal:data>
    38         </p>
    39         <p>
    40           <tal:data i18n:name="end"
    41                   tal:content="context.end"></tal:data>
    42         </p>
    43         <p>
    44           <tal:data i18n:name="distance"
    45                   tal:content="context.distance"></tal:data> kms
    46         </p>
     33
     34        <h3>Existing
     35          <tal:filetype i18n:name="filetype"
     36                        tal:content="context.tracking_filetype"></tal:filetype>
     37          tracking file data</h3>
     38
     39        <ul class="workout-activity-summary" id=""
     40            tal:attributes="id 'workout-' + context.workout_id + '-details'"
     41            tal:define="timezone request.root[request.authenticated_userid].timezone">
     42          <li>
     43            <tal:t i18n:translate="">Start:</tal:t>
     44            <tal:c tal:content="context.start_in_timezone(timezone)"></tal:c>
     45          </li>
     46          <li>
     47            <tal:t i18n:translate="">Duration:</tal:t>
     48            <tal:c tal:content="context._duration"></tal:c>
     49          </li>
     50          <li>
     51            <tal:t i18n:translate="">Distance:</tal:t>
     52            <tal:c tal:content="context.rounded_distance"></tal:c>
     53          </li>
     54        </ul>
     55        <div id="" tal:content="context.notes"
     56             tal:attributes="id 'workout-' + context.workout_id + '-notes'">
     57        </div>
    4758      </div>
    4859
  • ow/tests/models/test_workout.py

    r2a71053 r6edc367  
    138138        workout = Workout()
    139139        workout.distance = 44.44444444
    140         assert workout.rounded_distance == 44.4
     140        assert workout.rounded_distance == 44.44
    141141
    142142    def test_has_hr(self):
  • ow/tests/views/test_user.py

    r2a71053 r6edc367  
    11import os
    22import json
     3from decimal import Decimal
    34from datetime import datetime, timedelta, timezone
    45from shutil import copyfileobj
     
    269270        # profile page for the current day (no workouts avalable)
    270271        response = user_views.profile(john, request)
    271         assert len(response.keys()) == 3
     272        assert len(response.keys()) == 4
    272273        current_month = datetime.now(timezone.utc).strftime('%Y-%m')
    273274        assert response['current_month'] == current_month
    274275        assert response['current_week'] is None
    275276        assert response['workouts'] == []
     277        assert response['totals'] == {
     278            'distance': Decimal(0),
     279            'time': timedelta(0),
     280            'elevation': Decimal(0)
     281        }
    276282        # profile page for a previous date, that has workouts
    277283        request.GET['year'] = 2015
    278         request.GET['month'] = 8
     284        request.GET['month'] = 6
    279285        response = user_views.profile(john, request)
    280         assert len(response.keys()) == 3
    281         assert response['current_month'] == '2015-08'
     286        assert len(response.keys()) == 4
     287        assert response['current_month'] == '2015-06'
    282288        assert response['current_week'] is None
    283         assert response['workouts'] == john.workouts(2015, 8)
     289        workouts = john.workouts(2015, 6)
     290        assert response['workouts'] == workouts
     291        assert response['totals'] == {
     292            'distance': workouts[0].distance,
     293            'time': workouts[0].duration,
     294            'elevation': Decimal(0)
     295        }
    284296        # same, passing a week, first on a week without workouts
    285297        request.GET['year'] = 2015
    286         request.GET['month'] = 8
     298        request.GET['month'] = 6
    287299        request.GET['week'] = 25
    288300        response = user_views.profile(john, request)
    289         assert len(response.keys()) == 3
    290         assert response['current_month'] == '2015-08'
    291         assert response['current_week'] is 25
     301        assert len(response.keys()) == 4
     302        assert response['current_month'] == '2015-06'
     303        assert response['current_week'] == 25
    292304        assert response['workouts'] == []
    293         # now in a week with workoutss
     305        assert response['totals'] == {
     306            'distance': Decimal(0),
     307            'time': timedelta(0),
     308            'elevation': Decimal(0)
     309        }
     310        # now in a week with workouts
    294311        request.GET['year'] = 2015
    295         request.GET['month'] = 8
     312        request.GET['month'] = 6
    296313        request.GET['week'] = 26
    297314        response = user_views.profile(john, request)
    298         assert len(response.keys()) == 3
    299         assert response['current_month'] == '2015-08'
    300         assert response['current_week'] is 26
    301         assert response['workouts'] == john.workouts(2015, 8)
     315        assert len(response.keys()) == 4
     316        assert response['current_month'] == '2015-06'
     317        assert response['current_week'] == 26
     318        workouts = john.workouts(2015, 6)
     319        assert response['workouts'] == workouts
     320        assert response['totals'] == {
     321            'distance': workouts[0].distance,
     322            'time': workouts[0].duration,
     323            'elevation': Decimal(0)
     324        }
    302325
    303326    def test_login_get(self, dummy_request):
  • ow/views/user.py

    r2a71053 r6edc367  
    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 {
  • ow/views/workout.py

    r2a71053 r6edc367  
    128128        return HTTPFound(location=request.resource_url(context))
    129129
     130    # round some values before rendering
     131    if form.data['distance']:
     132        form.data['distance'] = round(form.data['distance'], 2)
     133
    130134    return {
    131135        'form': FormRenderer(form)
Note: See TracChangeset for help on using the changeset viewer.