1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-08-31 00:51:16 +02:00

INSTALLED_APPS checks

This commit is contained in:
Ehouarn
2025-08-30 01:55:03 +02:00
parent 99a90867cc
commit 2a638e7b32
3 changed files with 13 additions and 7 deletions

View File

@@ -1,6 +1,8 @@
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay # Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
from django.conf import settings
def save_user_profile(instance, created, raw, **_kwargs): 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): 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 from wei.models import WEIRegistration
if instance.club.id == 1 or instance.club.id == 2: if instance.club.id == 1 or instance.club.id == 2:
registrations = WEIRegistration.objects.filter( 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): def update_wei_registration_fee_on_club_change(sender, instance, **kwargs):
from wei.models import WEIRegistration if not hasattr(instance, "_no_signal") and 'wei' in settings.INSTALLED_APPS and (instance.id == 1 or instance.id == 2):
if not hasattr(instance, "_no_signal") and (instance.id == 1 or instance.id == 2): from wei.models import WEIRegistration
registrations = WEIRegistration.objects.filter( registrations = WEIRegistration.objects.filter(
wei__year=instance.membership_start.year, wei__year=instance.membership_start.year,
) )

View File

@@ -7,16 +7,19 @@
<dt class="col-xl-6">{% trans 'username'|capfirst %}</dt> <dt class="col-xl-6">{% trans 'username'|capfirst %}</dt>
<dd class="col-xl-6">{{ user_object.username }}</dd> <dd class="col-xl-6">{{ user_object.username }}</dd>
{% if family_app_installed %}
<dt class="col-xl-6">{% trans 'family'|capfirst %}</dt> <dt class="col-xl-6">{% trans 'family'|capfirst %}</dt>
<dd class="col-xl-6"> <dd class="col-xl-6">
{% if families %} {% if families %}
test
{% for fam in families %} {% for fam in families %}
<a href="{% url 'family:family_detail' fam.pk %}">{{ fam.name }}</a>{% if not forloop.last %}, {% endif %} <a href="{% url 'family:family_detail' fam.pk %}">asfafs{{ fam.name }}</a>{% if not forloop.last %}, {% endif %}
{% endfor %} {% endfor %}
{% else %} {% else %}
<span class="text-muted">Aucune</span> <span class="text-muted">Aucune</span>
{% endif %} {% endif %}
</dd> </dd>
{% endif %}
{% if user_object.pk == user.pk %} {% if user_object.pk == user.pk %}
<dt class="col-xl-6">{% trans 'password'|capfirst %}</dt> <dt class="col-xl-6">{% trans 'password'|capfirst %}</dt>

View File

@@ -207,9 +207,10 @@ class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
modified_note.is_active = True modified_note.is_active = True
context["can_unlock_note"] = not user.note.is_active and PermissionBackend\ context["can_unlock_note"] = not user.note.is_active and PermissionBackend\
.check_perm(self.request, "note.change_noteuser_is_active", modified_note) .check_perm(self.request, "note.change_noteuser_is_active", modified_note)
if 'family' in settings.INSTALLED_APPS:
families = Family.objects.filter(memberships__user=user).distinct() context["family_app_installed"] = True
context["families"] = families families = Family.objects.filter(memberships__user=user).distinct()
context["families"] = families
return context return context