# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later

from django.apps import AppConfig
from django.conf import settings
from django.db.models.signals import post_save
from django.utils.translation import gettext_lazy as _

from .signals import save_user_profile, update_wei_registration_fee_on_membership_creation, update_wei_registration_fee_on_club_change


class MemberConfig(AppConfig):
    name = 'member'
    verbose_name = _('member')

    def ready(self):
        """
        Define app internal signals to interact with other apps
        """
        from .models import Membership, Club
        post_save.connect(
            save_user_profile,
            sender=settings.AUTH_USER_MODEL,
        )
        post_save.connect(
            update_wei_registration_fee_on_membership_creation,
            sender=Membership
        )
        post_save.connect(
            update_wei_registration_fee_on_club_change,
            sender=Club
        )
