Esempio n. 1
0
    def get_redirect_url(self):
        thedate = self.date_from_yyymmdd()
        monday, sunday = get_week_bounds(thedate)
        next_monday = sunday + timedelta(days=1)

        done_something = False

        for event in RegularEvent.objects.filter(autoschedule=True):
            exists = ScheduledEvent.objects.filter(event=event).\
                exclude(date__lt=monday).exclude(date__gt=next_monday)
            if not exists:
                done_something = True
                event.schedule(monday, next_monday)

        if done_something:
            messages.success(self.request, ('I\'ve scheduled this week\'s '
                                            'events for you - enjoy!'))
        else:
            messages.info(self.request, 'No events to schedule.')

        return self.get_relative_root_url()
Esempio n. 2
0
    def get_redirect_url(self):
        thedate = self.date_from_yyymmdd()
        monday, sunday = get_week_bounds(thedate)
        next_monday = sunday + timedelta(days=1)

        done_something = False

        for event in RegularEvent.objects.filter(autoschedule=True):
            exists = ScheduledEvent.objects.filter(event=event).\
                exclude(date__lt=monday).exclude(date__gt=next_monday)
            if not exists:
                done_something = True
                event.schedule(monday, next_monday)

        if done_something:
            messages.success(self.request, ('I\'ve scheduled this week\'s '
                                            'events for you - enjoy!'))
        else:
            messages.info(self.request, 'No events to schedule.')

        return self.get_relative_root_url()
Esempio n. 3
0
 def test_get_week_bounds_on_a_sunday(self):
     monday, sunday = get_week_bounds(date(2012, 6, 17))
     self.assertEqual(monday.weekday(), 0)
     self.assertEqual(sunday.weekday(), 6)
     self.assertEqual(monday, date(2012, 6, 11))
     self.assertEqual(sunday, date(2012, 6, 17))
Esempio n. 4
0
 def test_get_week_bounds_today(self):
     monday, sunday = get_week_bounds()
     self.assertEqual(monday.weekday(), 0)
     self.assertEqual(sunday.weekday(), 6)
     self.assertTrue(monday <= date.today())
     self.assertTrue(sunday >= date.today())
Esempio n. 5
0
 def test_get_week_bounds_on_a_sunday(self):
     monday, sunday = get_week_bounds(date(2012, 6, 17))
     self.assertEqual(monday.weekday(), 0)
     self.assertEqual(sunday.weekday(), 6)
     self.assertEqual(monday, date(2012, 6, 11))
     self.assertEqual(sunday, date(2012, 6, 17))
Esempio n. 6
0
 def test_get_week_bounds_today(self):
     monday, sunday = get_week_bounds()
     self.assertEqual(monday.weekday(), 0)
     self.assertEqual(sunday.weekday(), 6)
     self.assertTrue(monday <= date.today())
     self.assertTrue(sunday >= date.today())
Esempio n. 7
0
def kanisa_this_sunday():
    monday, sunday = get_week_bounds()

    events = ScheduledEvent.objects.filter(date=sunday)

    return events
Esempio n. 8
0
def kanisa_this_sunday():
    monday, sunday = get_week_bounds()

    events = ScheduledEvent.objects.filter(date=sunday)

    return events