mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 11:59:23 +00:00
fix localdate issues
This commit is contained in:
committed by
Bartuccio Antoine
parent
271d57051e
commit
0eaa20e09d
@ -35,6 +35,7 @@ from django.db.models import Q
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.timezone import localdate
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core.models import Group, MetaGroup, Notification, Page, RealGroup, SithFile, User
|
||||
@ -269,7 +270,7 @@ class Club(models.Model):
|
||||
class MembershipQuerySet(models.QuerySet):
|
||||
def ongoing(self) -> Self:
|
||||
"""Filter all memberships which are not finished yet."""
|
||||
return self.filter(Q(end_date=None) | Q(end_date__gt=timezone.now().date()))
|
||||
return self.filter(Q(end_date=None) | Q(end_date__gt=localdate()))
|
||||
|
||||
def board(self) -> Self:
|
||||
"""Filter all memberships where the user is/was in the board.
|
||||
|
@ -19,7 +19,7 @@ from django.core.cache import cache
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.timezone import localtime, now
|
||||
from django.utils.timezone import localdate, localtime, now
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from club.forms import MailingForm
|
||||
@ -109,7 +109,7 @@ class TestMembershipQuerySet(TestClub):
|
||||
|
||||
def test_ongoing_with_membership_ending_today(self):
|
||||
"""Test that a membership ending the present day is considered as ended."""
|
||||
today = timezone.now().date()
|
||||
today = localdate()
|
||||
self.richard.memberships.filter(club=self.club).update(end_date=today)
|
||||
current_members = list(self.club.members.ongoing().order_by("id"))
|
||||
expected = [
|
||||
|
Reference in New Issue
Block a user