Add waze link in room detail
This commit is contained in:
parent
0d88f255c5
commit
17b2415d08
1 changed files with 14 additions and 6 deletions
20
gym/views.py
20
gym/views.py
|
@ -23,24 +23,32 @@ class RoomDetailView(LoginRequiredMixin, QuickActionsMixin, SessionResetMixin, g
|
||||||
template_name = 'gym/room.html'
|
template_name = 'gym/room.html'
|
||||||
|
|
||||||
def get_quick_actions(self):
|
def get_quick_actions(self):
|
||||||
return [
|
quick_actions = [
|
||||||
{
|
{
|
||||||
'url': reverse('rooms-list'),
|
'url': reverse('rooms-list'),
|
||||||
'category': 'secondary',
|
'category': 'secondary',
|
||||||
'display': 'Liste des salles'
|
'display': 'Liste des salles'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
'url': "{}?room={}".format(reverse('equipment-create'), self.object.pk),
|
|
||||||
'category': 'success',
|
|
||||||
'display': 'Ajouter une machine'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
'url': "{}?room={}".format(reverse('session-start'), self.object.pk),
|
'url': "{}?room={}".format(reverse('session-start'), self.object.pk),
|
||||||
'category': 'primary',
|
'category': 'primary',
|
||||||
'display': 'Commencer une séance'
|
'display': 'Commencer une séance'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'url': "{}?room={}".format(reverse('equipment-create'), self.object.pk),
|
||||||
|
'category': 'success',
|
||||||
|
'display': 'Ajouter une machine'
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if self.object.latitude and self.object.longitude:
|
||||||
|
quick_actions.append({
|
||||||
|
'url': f"waze://?ll={self.object.latitude},{self.object.longitude}&navigate=yes",
|
||||||
|
'category': 'info',
|
||||||
|
'display': 'Waze'
|
||||||
|
})
|
||||||
|
return quick_actions
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['sessions'] = self.object.sessions.all().order_by('-start')
|
context['sessions'] = self.object.sessions.all().order_by('-start')
|
||||||
|
|
Loading…
Reference in a new issue