diff --git a/lacommunaute/event/models.py b/lacommunaute/event/models.py index b678596c9..b29c5b6c0 100644 --- a/lacommunaute/event/models.py +++ b/lacommunaute/event/models.py @@ -1,15 +1,8 @@ from django.conf import settings from django.db import models -from django.db.models.functions import TruncMonth -from django.utils import timezone from machina.models.abstract_models import DatedModel -class CurrentUpcomingManager(models.Manager): - def get_queryset(self): - return super().get_queryset().filter(date__gte=TruncMonth(timezone.now())) - - class Event(DatedModel): name = models.CharField(max_length=100, verbose_name="Nom") date = models.DateField(verbose_name="Date de début", help_text="au format JJ/MM/YYYY") @@ -27,7 +20,6 @@ class Event(DatedModel): ) objects = models.Manager() - current_and_upcomings = CurrentUpcomingManager() class Meta: verbose_name = "Event" diff --git a/lacommunaute/event/tests/tests_model.py b/lacommunaute/event/tests/tests_model.py index c19ce8310..501dff72b 100644 --- a/lacommunaute/event/tests/tests_model.py +++ b/lacommunaute/event/tests/tests_model.py @@ -1,28 +1,7 @@ -from dateutil.relativedelta import relativedelta from django.db import IntegrityError from django.test import TestCase -from django.utils import timezone from lacommunaute.event.factories import EventFactory -from lacommunaute.event.models import Event - - -class EventCurrentUpcomingManagerTest(TestCase): - def test_manager(self): - now = timezone.now() - - EventFactory(date=now) - - old_event = EventFactory(date=now - relativedelta(months=1)) - - # upcomming event - EventFactory(date=now + relativedelta(months=1)) - - # Event at the beginning of the current month - EventFactory(date=now.replace(now.year, now.month, 1)) - - self.assertEqual(Event.current_and_upcomings.count(), 3) - self.assertNotIn(old_event, Event.current_and_upcomings.all()) class EventModelTest(TestCase):