diff --git a/apps/member/views.py b/apps/member/views.py index 72ad446e..84275db1 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -50,6 +50,15 @@ class CustomLoginView(LoginView): self.request.session['permission_mask'] = form.cleaned_data['permission_mask'].rank return super().form_valid(form) + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + user_agent = self.request.META.get('HTTP_USER_AGENT', '').lower() + + context['display_appstore_badge'] = 'iphone' in user_agent or 'android' not in user_agent + context['display_playstore_badge'] = 'android' in user_agent or 'iphone' not in user_agent + + return context + class UserUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): """ diff --git a/note_kfet/templates/registration/login.html b/note_kfet/templates/registration/login.html index e83c9d93..af2a3f5b 100644 --- a/note_kfet/templates/registration/login.html +++ b/note_kfet/templates/registration/login.html @@ -41,14 +41,18 @@ SPDX-License-Identifier: GPL-2.0-or-later
+ {% if display_appstore_badge %} {% trans 'Download on the AppStore' %} + {% endif %} + {% if display_playstore_badge %} {% trans 'Get it on Google Play' %} + {% endif %}