From 2a638e7b32f490cef51c16ff6173a2f635452666 Mon Sep 17 00:00:00 2001 From: Ehouarn Date: Sat, 30 Aug 2025 01:55:03 +0200 Subject: [PATCH] INSTALLED_APPS checks --- apps/member/signals.py | 8 +++++--- apps/member/templates/member/includes/profile_info.html | 5 ++++- apps/member/views.py | 7 ++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/member/signals.py b/apps/member/signals.py index f07c8896..839f0dc9 100644 --- a/apps/member/signals.py +++ b/apps/member/signals.py @@ -1,6 +1,8 @@ # Copyright (C) 2018-2025 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later +from django.conf import settings + def save_user_profile(instance, created, raw, **_kwargs): """ @@ -16,7 +18,7 @@ def save_user_profile(instance, created, raw, **_kwargs): def update_wei_registration_fee_on_membership_creation(sender, instance, created, **kwargs): - if not hasattr(instance, "_no_signal") and created: + if not hasattr(instance, "_no_signal") and 'wei' in settings.INSTALLED_APPS and created: from wei.models import WEIRegistration if instance.club.id == 1 or instance.club.id == 2: registrations = WEIRegistration.objects.filter( @@ -29,8 +31,8 @@ def update_wei_registration_fee_on_membership_creation(sender, instance, created def update_wei_registration_fee_on_club_change(sender, instance, **kwargs): - from wei.models import WEIRegistration - if not hasattr(instance, "_no_signal") and (instance.id == 1 or instance.id == 2): + if not hasattr(instance, "_no_signal") and 'wei' in settings.INSTALLED_APPS and (instance.id == 1 or instance.id == 2): + from wei.models import WEIRegistration registrations = WEIRegistration.objects.filter( wei__year=instance.membership_start.year, ) diff --git a/apps/member/templates/member/includes/profile_info.html b/apps/member/templates/member/includes/profile_info.html index 3ea525d5..579fac25 100644 --- a/apps/member/templates/member/includes/profile_info.html +++ b/apps/member/templates/member/includes/profile_info.html @@ -7,16 +7,19 @@
{% trans 'username'|capfirst %}
{{ user_object.username }}
+ {% if family_app_installed %}
{% trans 'family'|capfirst %}
{% if families %} + test {% for fam in families %} - {{ fam.name }}{% if not forloop.last %}, {% endif %} + asfafs{{ fam.name }}{% if not forloop.last %}, {% endif %} {% endfor %} {% else %} Aucune {% endif %}
+ {% endif %} {% if user_object.pk == user.pk %}
{% trans 'password'|capfirst %}
diff --git a/apps/member/views.py b/apps/member/views.py index 3cf3cd32..bf6245f5 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -207,9 +207,10 @@ class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): modified_note.is_active = True context["can_unlock_note"] = not user.note.is_active and PermissionBackend\ .check_perm(self.request, "note.change_noteuser_is_active", modified_note) - - families = Family.objects.filter(memberships__user=user).distinct() - context["families"] = families + if 'family' in settings.INSTALLED_APPS: + context["family_app_installed"] = True + families = Family.objects.filter(memberships__user=user).distinct() + context["families"] = families return context