Changeset 04c882d in OpenWorkouts-current
- Timestamp:
- Mar 6, 2019, 11:25:01 AM (5 years ago)
- Branches:
- current
- Children:
- 8d726ec
- Parents:
- aa6dcaf
- Location:
- ow
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
ow/models/user.py
raa6dcaf r04c882d 405 405 'distance': Decimal(0), 406 406 'elevation': Decimal(0), 407 'max_time': timedelta(0), 408 'max_time_wid': None, 409 'max_distance': Decimal(0), 410 'max_distance_wid': None, 411 'max_elevation': Decimal(0), 412 'max_elevation_wid': None 407 413 } 414 408 415 if self.activity_sports: 409 416 sport = sport or self.favorite_sport … … 411 418 if workout.sport == sport: 412 419 if year is None or workout.start.year == year: 420 wid = str(workout.workout_id) 421 time = workout.duration or timedelta(0) 422 distance = workout.distance or Decimal(0) 423 elevation = workout.uphill or Decimal(0) 413 424 totals['workouts'] += 1 414 totals['time'] += workout.duration or timedelta(0) 415 totals['distance'] += workout.distance or Decimal(0) 416 totals['elevation'] += workout.uphill or Decimal(0) 425 totals['time'] += time 426 totals['distance'] += distance 427 totals['elevation'] += elevation 428 if time > totals['max_time']: 429 totals['max_time'] = time 430 totals['max_time_wid'] = wid 431 if distance > totals['max_distance']: 432 totals['max_distance'] = distance 433 totals['max_distance_wid'] = wid 434 if elevation > totals['max_elevation']: 435 totals['max_elevation'] = elevation 436 totals['max_elevation_wid'] = wid 437 417 438 return totals -
ow/static/css/main.css
raa6dcaf r04c882d 1490 1490 color: #151515; 1491 1491 } 1492 .profile-data li a { 1493 color: #EE4056; 1494 text-decoration: none; 1495 } 1496 .profile-data li a:hover { 1497 color: #151515; 1498 } 1499 .profile-data li a:active, 1500 .profile-data li a:focus { 1501 outline: 0; 1502 border: none; 1503 -moz-outline-style: none; 1504 } 1492 1505 .profile-bio { 1493 1506 margin: 0.5em 0; -
ow/static/less/pages/profile.less
raa6dcaf r04c882d 90 90 color: @color-main; 91 91 } 92 a { 93 color: @color-app; 94 text-decoration: none; 95 &:hover { 96 color: @color-main; 97 } 98 &:active, &:focus { 99 outline: 0; 100 border: none; 101 -moz-outline-style: none; 102 } 103 } 92 104 } 93 105 } -
ow/templates/profile.pt
raa6dcaf r04c882d 253 253 <tal:t i18n:translate="">m</tal:t> 254 254 </li> 255 <li><span i18n:translate="">Single workout records:</span></li> 256 <li> 257 <span> 258 <tal:t i18n:translate="">Farthest distance</tal:t> 259 </span> 260 <a href="" tal:attributes="href request.resource_url(context[sport_totals['max_distance_wid']])"> 261 <tal:w tal:replace="round(sport_totals['max_distance'])"></tal:w> 262 <tal:t i18n:translate="">km</tal:t> 263 </a> 264 </li> 265 <li> 266 <span> 267 <tal:t i18n:translate="">Longer workout</tal:t> 268 </span> 269 <a href="" tal:attributes="href request.resource_url(context[sport_totals['max_time_wid']])"> 270 <tal:hms tal:define="hms timedelta_to_hms(sport_totals['max_time'])"> 271 <tal:h tal:content="str(hms[0]).zfill(2)"></tal:h> 272 <tal:t i18n:translate="">hours</tal:t>, 273 <tal:h tal:content="str(hms[1]).zfill(2)"></tal:h> 274 <tal:t i18n:translate="">min.</tal:t> 275 </tal:hms> 276 </a> 277 </li> 278 <li> 279 <span> 280 <tal:t i18n:translate="">Higher elevation gain</tal:t> 281 </span> 282 <a href="" tal:attributes="href request.resource_url(context[sport_totals['max_elevation_wid']])"> 283 <tal:w tal:replace="round(sport_totals['max_elevation'])"></tal:w> 284 <tal:t i18n:translate="">m</tal:t> 285 </a> 286 </li> 255 287 </ul> 256 288 </div> … … 290 322 <tal:w tal:replace="round(sport_totals['elevation'])"></tal:w> 291 323 <tal:t i18n:translate="">m</tal:t> 324 </li> 325 <li><span i18n:translate="">Single workout records:</span></li> 326 <li> 327 <span> 328 <tal:t i18n:translate="">Farthest distance</tal:t> 329 </span> 330 <a href="" tal:attributes="href request.resource_url(context[sport_totals['max_distance_wid']])"> 331 <tal:w tal:replace="round(sport_totals['max_distance'])"></tal:w> 332 <tal:t i18n:translate="">km</tal:t> 333 </a> 334 </li> 335 <li> 336 <span> 337 <tal:t i18n:translate="">Longer workout</tal:t> 338 </span> 339 <a href="" tal:attributes="href request.resource_url(context[sport_totals['max_time_wid']])"> 340 <tal:hms tal:define="hms timedelta_to_hms(sport_totals['max_time'])"> 341 <tal:h tal:content="str(hms[0]).zfill(2)"></tal:h> 342 <tal:t i18n:translate="">hours</tal:t>, 343 <tal:h tal:content="str(hms[1]).zfill(2)"></tal:h> 344 <tal:t i18n:translate="">min.</tal:t> 345 </tal:hms> 346 </a> 347 </li> 348 <li> 349 <span> 350 <tal:t i18n:translate="">Higher elevation gain</tal:t> 351 </span> 352 <a href="" tal:attributes="href request.resource_url(context[sport_totals['max_elevation_wid']])"> 353 <tal:w tal:replace="round(sport_totals['max_elevation'])"></tal:w> 354 <tal:t i18n:translate="">m</tal:t> 355 </a> 292 356 </li> 293 357 </ul> -
ow/tests/models/test_user.py
raa6dcaf r04c882d 659 659 'distance': Decimal(0), 660 660 'elevation': Decimal(0), 661 'max_time': timedelta(0), 662 'max_time_wid': None, 663 'max_distance': Decimal(0), 664 'max_distance_wid': None, 665 'max_elevation': Decimal(0), 666 'max_elevation_wid': None 661 667 } 662 668 # add a cycling workout happening now … … 665 671 start=datetime.now(timezone.utc), 666 672 duration=timedelta(minutes=120), 667 distance=66, 668 ) 669 root['john'].add_workout(workout) 673 distance=Decimal(66), 674 ) 675 root['john'].add_workout(workout) 676 cycling_wid = workout.workout_id 670 677 # only one workout, one sport, so the default will show totals 671 678 # for that sport … … 675 682 'distance': Decimal(66), 676 683 'elevation': Decimal(0), 684 'max_time': timedelta(minutes=120), 685 'max_time_wid': cycling_wid, 686 'max_distance': Decimal(66), 687 'max_distance_wid': cycling_wid, 688 'max_elevation': Decimal(0), 689 'max_elevation_wid': None 677 690 } 678 691 # Add a running workout … … 681 694 start=datetime(2018, 11, 25, 10, 00, tzinfo=timezone.utc), 682 695 duration=timedelta(minutes=45), 683 distance=5, 684 ) 685 root['john'].add_workout(workout) 696 distance=Decimal(5), 697 ) 698 root['john'].add_workout(workout) 699 running_wid = workout.workout_id 686 700 # the favorite sport is running now 687 701 assert root['john'].sport_totals() == { … … 690 704 'distance': Decimal(5), 691 705 'elevation': Decimal(0), 706 'max_time': timedelta(minutes=45), 707 'max_time_wid': running_wid, 708 'max_distance': Decimal(5), 709 'max_distance_wid': running_wid, 710 'max_elevation': Decimal(0), 711 'max_elevation_wid': None, 692 712 } 693 713 # but we can get the totals for cycling too … … 697 717 'distance': Decimal(66), 698 718 'elevation': Decimal(0), 719 'max_time': timedelta(minutes=120), 720 'max_time_wid': cycling_wid, 721 'max_distance': Decimal(66), 722 'max_distance_wid': cycling_wid, 723 'max_elevation': Decimal(0), 724 'max_elevation_wid': None 699 725 } 700 726 # adding a new cycling workout, in a different year … … 703 729 start=datetime(2017, 11, 25, 10, 00, tzinfo=timezone.utc), 704 730 duration=timedelta(minutes=60), 705 distance=32, 706 ) 707 root['john'].add_workout(workout) 731 distance=Decimal(32), 732 uphill=Decimal(430) 733 ) 734 root['john'].add_workout(workout) 735 second_cycling_wid = workout.workout_id 708 736 # now cycling is the favorite sport 709 737 assert root['john'].sport_totals() == { … … 711 739 'time': timedelta(minutes=180), 712 740 'distance': Decimal(98), 713 'elevation': Decimal(0), 741 'elevation': Decimal(430), 742 'max_time': timedelta(minutes=120), 743 'max_time_wid': cycling_wid, 744 'max_distance': Decimal(66), 745 'max_distance_wid': cycling_wid, 746 'max_elevation': Decimal(430), 747 'max_elevation_wid': second_cycling_wid 714 748 } 715 749 # but we can get running stats too … … 719 753 'distance': Decimal(5), 720 754 'elevation': Decimal(0), 755 'max_time': timedelta(minutes=45), 756 'max_time_wid': running_wid, 757 'max_distance': Decimal(5), 758 'max_distance_wid': running_wid, 759 'max_elevation': Decimal(0), 760 'max_elevation_wid': None, 721 761 } 722 762 # there are no running activities for 2016 … … 726 766 'distance': Decimal(0), 727 767 'elevation': Decimal(0), 768 'max_time': timedelta(0), 769 'max_time_wid': None, 770 'max_distance': Decimal(0), 771 'max_distance_wid': None, 772 'max_elevation': Decimal(0), 773 'max_elevation_wid': None 728 774 } 729 775 # and not activities for cycling in 2016 neither … … 733 779 'distance': Decimal(0), 734 780 'elevation': Decimal(0), 781 'max_time': timedelta(0), 782 'max_time_wid': None, 783 'max_distance': Decimal(0), 784 'max_distance_wid': None, 785 'max_elevation': Decimal(0), 786 'max_elevation_wid': None 735 787 } 736 788 # and we can get the separate totals for cycling in different years … … 741 793 'distance': Decimal(66), 742 794 'elevation': Decimal(0), 795 'max_time': timedelta(minutes=120), 796 'max_time_wid': cycling_wid, 797 'max_distance': Decimal(66), 798 'max_distance_wid': cycling_wid, 799 'max_elevation': Decimal(0), 800 'max_elevation_wid': None 743 801 } 744 802 assert root['john'].sport_totals('cycling', 2017) == { … … 746 804 'time': timedelta(minutes=60), 747 805 'distance': Decimal(32), 748 'elevation': Decimal(0), 749 } 806 'elevation': Decimal(430), 807 'max_time': timedelta(minutes=60), 808 'max_time_wid': second_cycling_wid, 809 'max_distance': Decimal(32), 810 'max_distance_wid': second_cycling_wid, 811 'max_elevation': Decimal(430), 812 'max_elevation_wid': second_cycling_wid 813 }
Note: See TracChangeset
for help on using the changeset viewer.