Skip to content

Commit

Permalink
[EVENT] remove unused EventCurrentUpcomingManager
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Oct 2, 2023
1 parent dede3bc commit 49b42ad
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
8 changes: 0 additions & 8 deletions lacommunaute/event/models.py
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -27,7 +20,6 @@ class Event(DatedModel):
)

objects = models.Manager()
current_and_upcomings = CurrentUpcomingManager()

class Meta:
verbose_name = "Event"
Expand Down
21 changes: 0 additions & 21 deletions lacommunaute/event/tests/tests_model.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down

0 comments on commit 49b42ad

Please sign in to comment.