예제 #1
0
파일: tests.py 프로젝트: ahmedsabie/vms
    def test_get_events_by_date(self):
        """ Test get_events_by_date(start_date, end_date) """

        e1 = Event(
                name="Open Source Event",
                start_date="2012-10-22",
                end_date="2012-10-23"
                )
        e2 = Event(
                name="Python Event",
                start_date="2013-11-12",
                end_date="2013-11-13"
                )
        e3 = Event(
                name="Django Event",
                start_date="2015-07-02",
                end_date="2015-07-03"
                )
        e4 = Event(
                name="Systers Event",
                start_date="2015-07-25",
                end_date="2015-08-08"
                )
        e5 = Event(
                name="Anita Borg Event",
                start_date="2015-07-07",
                end_date="2015-07-08"
                )

        e1.save()
        e2.save()
        e3.save()
        e4.save()
        e5.save()

        # test typical cases
        event_list = get_events_by_date('2015-07-01','2015-08-01')
        self.assertIsNotNone(event_list)
        
        self.assertIn(e3, event_list)
        self.assertIn(e4, event_list)
        self.assertIn(e5, event_list)
        self.assertEqual(len(event_list), 3)
        
        # test order
        self.assertEqual(event_list[0], e3)
        self.assertEqual(event_list[1], e5)
        self.assertEqual(event_list[2], e4)
예제 #2
0
    def test_get_events_by_date(self):
        """ Test get_events_by_date(start_date, end_date) """

        # test typical cases
        event_list = get_events_by_date('2015-07-01', '2015-08-01')
        self.assertIsNotNone(event_list)

        self.assertIn(self.e3, event_list)
        self.assertIn(self.e4, event_list)
        self.assertIn(self.e5, event_list)
        self.assertEqual(len(event_list), 3)

        # test order
        self.assertEqual(event_list[0], self.e3)
        self.assertEqual(event_list[1], self.e5)
        self.assertEqual(event_list[2], self.e4)
예제 #3
0
    def test_get_events_by_date(self):
        """ Test get_events_by_date(start_date, end_date) """

        # test typical cases
        event_list = get_events_by_date('2015-07-01', '2015-08-01')
        self.assertIsNotNone(event_list)

        self.assertIn(self.e3, event_list)
        self.assertIn(self.e4, event_list)
        self.assertIn(self.e5, event_list)
        self.assertEqual(len(event_list), 3)

        # test order
        self.assertEqual(event_list[0], self.e3)
        self.assertEqual(event_list[1], self.e5)
        self.assertEqual(event_list[2], self.e4)
예제 #4
0
파일: views.py 프로젝트: pradeepgangwar/vms
def list_sign_up(request, volunteer_id):
    if request.method == 'POST':
        form = EventDateForm(request.POST)
        if form.is_valid():
            start_date = form.cleaned_data['start_date']
            end_date = form.cleaned_data['end_date']
            event_list = get_events_by_date(start_date, end_date)
            event_list = remove_empty_events_for_volunteer(
                event_list, volunteer_id)
            return render(
                request, 'event/list_sign_up.html', {
                    'form': form,
                    'event_list': event_list,
                    'volunteer_id': volunteer_id
                })
    else:
        event_list = get_events_ordered_by_name()
        event_list = remove_empty_events_for_volunteer(event_list,
                                                       volunteer_id)
        return render(request, 'event/list_sign_up.html', {
            'event_list': event_list,
            'volunteer_id': volunteer_id
        })