mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-07-22 00:49:11 +02:00
Add fee field to WEIRegistration to be able to sort on validation status
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
|
||||
)
|
||||
|
@ -13,3 +13,25 @@ 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 created:
|
||||
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.save()
|
||||
|
||||
|
||||
def update_wei_registration_fee_on_club_change(sender, instance, **kwargs):
|
||||
from wei.models import WEIRegistration
|
||||
if instance.id == 1 or instance.id == 2:
|
||||
registrations = WEIRegistration.objects.filter(
|
||||
wei__year=instance.membership_start.year,
|
||||
)
|
||||
for r in registrations:
|
||||
r.save()
|
||||
|
Reference in New Issue
Block a user