예제 #1
0
    def test_cant_claim_task_beyond_alotted_slots(self):
        event = Event.objects.all()[0]

        some_task = Task()
        some_task.for_event = event
        some_task.for_committee = Committee.objects.filter(
                                            name="Events Committee").all()[0]
        some_task.task_type = TaskType.objects.filter(
                                            short_description="Tabling").all()[0]
        some_task.start_time = datetime.datetime(2009,4,18,9)
        some_task.duration_minutes = 60
        some_task.num_volunteers = 1
        some_task.save()

        plainuser = User.objects.filter(username='******').all()[0]
        temp_volunteer = Volunteer()
        temp_volunteer.user = plainuser
        temp_volunteer.save()

        asn = TaskAssignment()
        asn.task = some_task
        asn.points = 1
        asn.volunteer = temp_volunteer
        asn.save()

        # should not be able to save
        resp = self.client.get('/chirp/tasks/claim/%s.json' % some_task.id)
        json = simplejson.loads(resp.content)
        eq_(json['success'], False)
        eq_(json['error'],
            "All volunteers needed for this task have been filled "
            "(Tabling on Sat Apr 18th from 9:00 a.m. - 10:00 a.m.)")
예제 #2
0
    def test_hide_expired_events(self):
        old_event = Event()
        old_event.name = "Pitchfork 2008"
        old_event.duration_days = 3
        # make it just expire by a day:
        old_event.start_date = datetime.datetime.now() - timedelta(days=4)
        old_event.save()

        some_task = Task()
        some_task.for_event = old_event
        some_task.for_committee = Committee.objects.filter(
                                            name="Events Committee").all()[0]
        some_task.task_type = TaskType.objects.filter(
                                            short_description="Tabling").all()[0]
        some_task.start_time = datetime.datetime.now() - timedelta(days=30)
        some_task.duration_minutes = 60
        some_task.num_volunteers = 1
        some_task.save()

        plainuser = User.objects.filter(username='******').all()[0]
        temp_volunteer = Volunteer()
        temp_volunteer.user = plainuser
        temp_volunteer.save()

        asn = TaskAssignment()
        asn.task = some_task
        asn.points = 1
        asn.volunteer = temp_volunteer
        asn.save()

        resp = self.client.get('/chirp/tasks/claim/')
        context = resp.context[0]

        eq_(sorted(e.name for e in context['events']),
            ['CHIRP Record Fair & Other Delights'])