Changeset d1c4782 in OpenWorkouts-current for ow/views/workout.py


Ignore:
Timestamp:
Jan 21, 2019, 10:43:20 AM (5 years ago)
Author:
borja <borja@…>
Branches:
current, feature/docs, master
Children:
be40b02
Parents:
ceae158
Message:

Show a capture of the workout map, as an image, in the dashboard:

  • Added a view to render the tracking map of a workout full screen
  • Added a small shell script that uses chrome to grabs a screenshot of the full screen map view of a workout, then uses imagemagick convert to crop/resize it and finally saves it in a given location
  • Added a static/maps directory to store maps captures
  • Added static/maps to the boring/ignore file
  • Added a tool in utilities.py to call the shell script that captures the screenshot of the map
  • Added a method to the Workout model, that returns the static path to the workout map capture (valid to use with request.static_url()). If there is no capture yet, call the tool to make one
  • Added code to dashboard.pt to show the capture of the map
  • Added a new parameter to te ow maps js code, allowing us to hide/show the zoom controls of the map when building a new one
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/views/workout.py

    rceae158 rd1c4782  
    214214        content_disposition='attachment; filename="%s"' % gpx_slug,
    215215        body_file=context.tracking_file.open())
     216
     217
     218@view_config(
     219    context=Workout,
     220    name='map',
     221    renderer='ow:templates/workout-map.pt')
     222def workout_map(context, request):
     223    """
     224    Render a page that has only a map with tracking info
     225    """
     226    start_point = {}
     227    if context.has_gpx:
     228        with context.tracking_file.open() as gpx_file:
     229            gpx_contents = gpx_file.read()
     230            gpx_contents = gpx_contents.decode('utf-8')
     231            gpx = gpxpy.parse(gpx_contents)
     232            if gpx.tracks:
     233                track = gpx.tracks[0]
     234                center_point = track.get_center()
     235                start_point = {'latitude': center_point.latitude,
     236                               'longitude': center_point.longitude,
     237                               'elevation': center_point.elevation}
     238    return {'start_point': start_point}
Note: See TracChangeset for help on using the changeset viewer.