From 981c4d030060f28b0898f180357c65638cea93df Mon Sep 17 00:00:00 2001 From: bleizi Date: Fri, 7 Jul 2023 20:39:19 +0200 Subject: [PATCH] fix update of club membership start/end date --- apps/member/models.py | 2 +- apps/member/tests/test_memberships.py | 2 +- apps/member/views.py | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/member/models.py b/apps/member/models.py index 0b471f12..3706e47f 100644 --- a/apps/member/models.py +++ b/apps/member/models.py @@ -263,7 +263,7 @@ class Club(models.Model): today = datetime.date.today() - if (today - self.membership_start).days >= 365: + while (today - self.membership_start).days >= 365: if self.membership_start: self.membership_start = datetime.date(self.membership_start.year + 1, self.membership_start.month, self.membership_start.day) diff --git a/apps/member/tests/test_memberships.py b/apps/member/tests/test_memberships.py index 2dc6dd41..b2647551 100644 --- a/apps/member/tests/test_memberships.py +++ b/apps/member/tests/test_memberships.py @@ -183,7 +183,7 @@ class TestMemberships(TestCase): club = Club.objects.get(name="Kfet") else: club = Club.objects.create( - name="Second club " + ("with BDE" if bde_parent else "without BDE"), + name="Second club without BDE", parent_club=None, email="newclub@example.com", require_memberships=True, diff --git a/apps/member/views.py b/apps/member/views.py index 2f6348a6..63307383 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -753,6 +753,10 @@ class ClubAddMemberView(ProtectQuerysetMixin, ProtectedCreateView): club = old_membership.club user = old_membership.user + # Update club membership date + if PermissionBackend.check_perm(self.request, "member.change_club_membership_start", club): + club.update_membership_dates() + form.instance.club = club # Get form data