1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-22 23:42:25 +00:00

fix update of club membership start/end date

This commit is contained in:
bleizi 2023-07-07 20:39:19 +02:00
parent 16f8a60a3f
commit 981c4d0300
No known key found for this signature in database
GPG Key ID: D46D7E3364433208
3 changed files with 6 additions and 2 deletions

View File

@ -263,7 +263,7 @@ class Club(models.Model):
today = datetime.date.today() today = datetime.date.today()
if (today - self.membership_start).days >= 365: while (today - self.membership_start).days >= 365:
if self.membership_start: if self.membership_start:
self.membership_start = datetime.date(self.membership_start.year + 1, self.membership_start = datetime.date(self.membership_start.year + 1,
self.membership_start.month, self.membership_start.day) self.membership_start.month, self.membership_start.day)

View File

@ -183,7 +183,7 @@ class TestMemberships(TestCase):
club = Club.objects.get(name="Kfet") club = Club.objects.get(name="Kfet")
else: else:
club = Club.objects.create( club = Club.objects.create(
name="Second club " + ("with BDE" if bde_parent else "without BDE"), name="Second club without BDE",
parent_club=None, parent_club=None,
email="newclub@example.com", email="newclub@example.com",
require_memberships=True, require_memberships=True,

View File

@ -753,6 +753,10 @@ class ClubAddMemberView(ProtectQuerysetMixin, ProtectedCreateView):
club = old_membership.club club = old_membership.club
user = old_membership.user 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 form.instance.club = club
# Get form data # Get form data