From 7448b77bc3fa1c4f4d00482d5d3dad766820c1e5 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Tue, 10 Jan 2023 22:03:59 +0100 Subject: use GPX track description if available --- CHANGELOG.rst | 3 ++- fietsboek/views/upload.py | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8668b5c..7f4ac6b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -26,7 +26,8 @@ Fixed - Account registration giving a 400 error. - Track deletion being forbidden for users. - +- Descriptions embedded in GPX tracks not being pre-filled when + uploading the track. 0.4.0 - 2022-11-28 ------------------ diff --git a/fietsboek/views/upload.py b/fietsboek/views/upload.py index 49c839c..e172339 100644 --- a/fietsboek/views/upload.py +++ b/fietsboek/views/upload.py @@ -114,10 +114,12 @@ def finish_upload(request): tz_offset = timezone.utcoffset(date) tz_offset = 0 if tz_offset is None else tz_offset.total_seconds() track_name = "" + track_desc = "" for track in gpx.tracks: - if track.name: + if not track_name and track.name: track_name = track.name - break + if not track_desc and track.description: + track_desc = track.description return { "preview_id": upload.id, @@ -126,7 +128,7 @@ def finish_upload(request): "upload_date_tz": int(tz_offset // 60), "upload_visibility": Visibility.PRIVATE, "upload_type": TrackType.ORGANIC, - "upload_description": gpx.description, + "upload_description": gpx.description or track_desc, "upload_tags": set(), "upload_tagged_people": [], "badges": badges, -- cgit v1.2.3