Changeset d1c4782 in OpenWorkouts-current for ow/models/workout.py
- Timestamp:
- Jan 21, 2019, 10:43:20 AM (5 years ago)
- Branches:
- current, feature/docs, master
- Children:
- be40b02
- Parents:
- ceae158
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ow/models/workout.py
rceae158 rd1c4782 1 1 import os 2 2 from datetime import datetime, timedelta, timezone 3 3 from decimal import Decimal … … 12 12 copy_blob, 13 13 create_blob, 14 mps_to_kmph 14 mps_to_kmph, 15 save_map_screenshot 15 16 ) 16 17 … … 419 420 def has_fit(self): 420 421 return self.fit_file is not None 422 423 @property 424 def map_screenshot(self): 425 """ 426 Return the static path to the screenshot image of the map for 427 this workout (works only for workouts with gps tracking) 428 """ 429 if not self.has_gpx: 430 return None 431 432 current_path = os.path.abspath(os.path.dirname(__file__)) 433 screenshot_path = os.path.join( 434 current_path, '../static/maps', 435 str(self.owner.uid), str(self.workout_id)) + '.png' 436 437 if not os.path.exists(screenshot_path): 438 # screenshot does not exist, generate it 439 save_map_screenshot(self) 440 441 # the value returned is relative to the static files served 442 # by the app, so we can use request.static_url() with it 443 static_path = os.path.join('static/maps', str(self.owner.uid), 444 str(self.workout_id)) 445 return 'ow:' + static_path + '.png'
Note: See TracChangeset
for help on using the changeset viewer.