Provide Google Maps link for desktop users

This commit is contained in:
Gabriel Augendre 2018-04-03 18:17:30 +02:00
parent 8dcf4512cc
commit b318270fb0
No known key found for this signature in database
GPG key ID: F360212F958357D4

View file

@ -44,17 +44,19 @@ 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:
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': f"https://waze.com/ul?ll={self.object.latitude},{self.object.longitude}",
'url': url,
'category': 'info',
'display': 'Waze'
'display': name
})
return quick_actions