From b318270fb0a3cd811e5573403fa9562c6e8c63ca Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Tue, 3 Apr 2018 18:17:30 +0200 Subject: [PATCH] Provide Google Maps link for desktop users --- gym/views.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gym/views.py b/gym/views.py index 8d616af..7702532 100644 --- a/gym/views.py +++ b/gym/views.py @@ -44,18 +44,20 @@ class RoomDetailView(LoginRequiredMixin, QuickActionsMixin, SessionResetMixin, g if self.object.latitude and self.object.longitude: from user_agents import parse user_agent = parse(self.request.META.get('HTTP_USER_AGENT')) + if user_agent.is_mobile: - quick_actions.append({ - 'url': f"waze://?ll={self.object.latitude},{self.object.longitude}&navigate=yes", - 'category': 'info', - 'display': 'Waze' - }) + url = f"waze://?ll={self.object.latitude},{self.object.longitude}&navigate=yes" + name = 'Waze' else: - quick_actions.append({ - 'url': f"https://waze.com/ul?ll={self.object.latitude},{self.object.longitude}", - 'category': 'info', - 'display': 'Waze' - }) + url = (f"https://www.google.com/maps/place/{self.object.latitude},{self.object.longitude}" + f"/@{self.object.latitude},{self.object.longitude},18z") + name = 'Google Maps' + + quick_actions.append({ + 'url': url, + 'category': 'info', + 'display': name + }) return quick_actions def get_context_data(self, **kwargs):