mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-08-14 09:56:38 +02:00
Merge branch 'main' into family
This commit is contained in:
@@ -6,7 +6,7 @@ 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
|
||||
from .signals import save_user_profile, update_wei_registration_fee_on_membership_creation, update_wei_registration_fee_on_club_change
|
||||
|
||||
|
||||
class MemberConfig(AppConfig):
|
||||
@@ -17,7 +17,16 @@ class MemberConfig(AppConfig):
|
||||
"""
|
||||
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
|
||||
)
|
||||
|
18
apps/member/migrations/0015_alter_profile_promotion.py
Normal file
18
apps/member/migrations/0015_alter_profile_promotion.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.2.4 on 2025-08-02 13:43
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('member', '0014_create_bda'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='promotion',
|
||||
field=models.PositiveSmallIntegerField(default=2025, help_text='Year of entry to the school (None if not ENS student)', null=True, verbose_name='promotion'),
|
||||
),
|
||||
]
|
@@ -13,3 +13,28 @@ def save_user_profile(instance, created, raw, **_kwargs):
|
||||
instance.profile.email_confirmed = True
|
||||
instance.profile.registration_valid = True
|
||||
instance.profile.save()
|
||||
|
||||
|
||||
def update_wei_registration_fee_on_membership_creation(sender, instance, created, **kwargs):
|
||||
if not hasattr(instance, "_no_signal") and created:
|
||||
print('update_wei_registration_fee_on_membership_creation')
|
||||
from wei.models import WEIRegistration
|
||||
if instance.club.id == 1 or instance.club.id == 2:
|
||||
registrations = WEIRegistration.objects.filter(
|
||||
user=instance.user,
|
||||
wei__year=instance.date_start.year,
|
||||
)
|
||||
for r in registrations:
|
||||
r._force_save = True
|
||||
r.save()
|
||||
|
||||
|
||||
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):
|
||||
registrations = WEIRegistration.objects.filter(
|
||||
wei__year=instance.membership_start.year,
|
||||
)
|
||||
for r in registrations:
|
||||
r._force_save = True
|
||||
r.save()
|
||||
|
Reference in New Issue
Block a user