mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-11-04 01:12:08 +01:00 
			
		
		
		
	apps: display appstore badges based on UA
* on iPhone, only AppStore badge displays * on Android, only PlayStore badge displays * on any other platform, both display
This commit is contained in:
		@@ -50,6 +50,15 @@ class CustomLoginView(LoginView):
 | 
				
			|||||||
        self.request.session['permission_mask'] = form.cleaned_data['permission_mask'].rank
 | 
					        self.request.session['permission_mask'] = form.cleaned_data['permission_mask'].rank
 | 
				
			||||||
        return super().form_valid(form)
 | 
					        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):
 | 
					class UserUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,14 +41,18 @@ SPDX-License-Identifier: GPL-2.0-or-later
 | 
				
			|||||||
        </form>
 | 
					        </form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <div class="text-center mt-4">
 | 
					        <div class="text-center mt-4">
 | 
				
			||||||
 | 
					            {% if display_appstore_badge %}
 | 
				
			||||||
            <a href="https://apps.apple.com/fr/app/la-note-kfet/id6754661723" class="d-inline-block mx-1" aria-label="{% trans 'Download on the AppStore' %}" style="cursor: pointer;">
 | 
					            <a href="https://apps.apple.com/fr/app/la-note-kfet/id6754661723" class="d-inline-block mx-1" aria-label="{% trans 'Download on the AppStore' %}" style="cursor: pointer;">
 | 
				
			||||||
                <img src="/static/img/appstore_badge_fr.svg"
 | 
					                <img src="/static/img/appstore_badge_fr.svg"
 | 
				
			||||||
                     alt="{% trans 'Download on the AppStore' %}" style="height: 50px;">
 | 
					                     alt="{% trans 'Download on the AppStore' %}" style="height: 50px;">
 | 
				
			||||||
            </a>
 | 
					            </a>
 | 
				
			||||||
 | 
					            {% endif %}
 | 
				
			||||||
 | 
					            {% if display_playstore_badge %}
 | 
				
			||||||
            <a href="https://play.google.com/store/apps/details?id=org.crans.bde.note&hl=fr" class="d-inline-block mx-1" aria-label="{% trans 'Get it on Google Play' %}" style="cursor: pointer;">
 | 
					            <a href="https://play.google.com/store/apps/details?id=org.crans.bde.note&hl=fr" class="d-inline-block mx-1" aria-label="{% trans 'Get it on Google Play' %}" style="cursor: pointer;">
 | 
				
			||||||
                <img src="/static/img/playstore_badge_fr.svg"
 | 
					                <img src="/static/img/playstore_badge_fr.svg"
 | 
				
			||||||
                     alt="{% trans 'Get it on Google Play' %}" style="height: 50px;">
 | 
					                     alt="{% trans 'Get it on Google Play' %}" style="height: 50px;">
 | 
				
			||||||
            </a>
 | 
					            </a>
 | 
				
			||||||
 | 
					            {% endif %}
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user