Changeset d7a9df5 in OpenWorkouts-current for ow


Ignore:
Timestamp:
Feb 10, 2019, 8:28:44 AM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
e547af5
Parents:
6662a84
Message:

Done some improvements on the dashboard:

  • Remove hr/speed/cad info from the workouts list (too much info)
  • Added workout sport to the workouts list
  • Replaced full notes for each workout with a shortened/trimmed version (done this in the workouts list in the profile page too)
Location:
ow
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ow/models/workout.py

    r6662a84 rd7a9df5  
    11import os
     2import textwrap
    23from datetime import datetime, timedelta, timezone
    34from decimal import Decimal
     
    136137
    137138    @property
     139    def trimmed_notes(self):
     140        """
     141        Return a string with a reduced version of the full notes for this
     142        workout.
     143        """
     144        return textwrap.shorten(self.notes, width=225, placeholder=' ...')
     145
     146    @property
    138147    def has_hr(self):
    139148        """
  • ow/templates/dashboard.pt

    r6662a84 rd7a9df5  
    5656            <ul class="workout-info">
    5757              <li>
     58                <tal:c tal:content="workout.sport"></tal:c>
     59              </li>
     60              <li>
    5861                <tal:c tal:content="workout.start_in_timezone(context.timezone)"></tal:c>
    5962              </li>
     
    7073            </ul>
    7174
    72             <ul class="workout-info" tal:define="hr workout.hr; cad workout.cad">
    73               <li tal:condition="hr">
    74                 <span i18n:translate="">HR (bpm)</span>:
    75                 <tal:c tal:content="hr['avg']"></tal:c>
    76                 <tal:t i18n:translate="">Avg.</tal:t>,
    77                 <tal:c tal:content="hr['max']"></tal:c>
    78                 <tal:t i18n:translate="">Max.</tal:t>
    79               </li>
    80               <li tal:condition="cad">
    81                 <span i18n:translate="">Cad</span>:
    82                 <tal:c tal:content="cad['avg']"></tal:c>
    83                 <tal:t i18n:translate="">Avg.</tal:t>,
    84                 <tal:c tal:content="cad['max']"></tal:c>
    85                 <tal:t i18n:translate="">Max.</tal:t>
    86               </li>
    87             </ul>
    88 
    89             <div class="workout-intro" tal:content="workout.notes"></div>
     75            <div class="workout-intro">
     76              <p tal:repeat="paragraph workout.trimmed_notes.split('\n')"
     77                 tal:content="paragraph"></p>
     78            </div>
    9079
    9180            <div class="workout-map" tal:condition="workout.has_gpx">
  • ow/templates/profile.pt

    r6662a84 rd7a9df5  
    138138
    139139              <div class="workout-intro">
    140                 <p tal:repeat="paragraph workout.notes.split('\n')"
     140                <p tal:repeat="paragraph workout.trimmed_notes.split('\n')"
    141141                   tal:content="paragraph"></p>
    142142              </div>
  • ow/tests/models/test_workout.py

    r6662a84 rd7a9df5  
    143143        workout.distance = 44.44444444
    144144        assert workout.rounded_distance == 44.44
     145
     146    def test_trimmed_notes(self):
     147        workout = Workout()
     148        assert workout.notes == ''
     149        assert workout.trimmed_notes == ''
     150        workout.notes = 'very short notes'
     151        assert workout.notes == 'very short notes'
     152        assert workout.trimmed_notes == 'very short notes'
     153        workout.notes = 'long notes now, repeated' * 1000
     154        assert len(workout.notes) == 24000
     155        assert len(workout.trimmed_notes) == 224
     156        assert workout.trimmed_notes.endswith(' ...')
    145157
    146158    def test_has_hr(self):
Note: See TracChangeset for help on using the changeset viewer.