From 56e4457de416a3fe16592983dabfee16075c8892 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 9 Jul 2022 11:41:28 +0200 Subject: take title suggestion from track name Sometimes, the GPX itself does not have a name set, but the single tracks might have. --- fietsboek/views/upload.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fietsboek/views/upload.py b/fietsboek/views/upload.py index 4ce41c8..9e38069 100644 --- a/fietsboek/views/upload.py +++ b/fietsboek/views/upload.py @@ -107,10 +107,15 @@ def finish_upload(request): date = gpx.time or gpx.get_time_bounds().start_time date = date.astimezone(timezone) tz_offset = timezone.utcoffset(date) + track_name = "" + for track in gpx.tracks: + if track.name: + track_name = track.name + break return { 'preview_id': upload.id, - 'upload_title': gpx.name, + 'upload_title': gpx.name or track_name, 'upload_date': date, 'upload_date_tz': int(tz_offset.total_seconds() // 60), 'upload_visibility': Visibility.PRIVATE, -- cgit v1.2.3