Example #1
0
File: views.py Project: systers/vms
 def get_context_data(self, **kwargs):
     context = super(ClearHoursManager, self).get_context_data(**kwargs)
     shift_id = self.kwargs['shift_id']
     volunteer_id = self.kwargs['volunteer_id']
     context['volunteer_id'] = volunteer_id
     context['shift_id'] = shift_id
     context['result'] = clear_shift_hours(volunteer_id, shift_id)
     return context
Example #2
0
 def get_context_data(self, **kwargs):
     context = super(ClearHoursManager, self).get_context_data(**kwargs)
     shift_id = self.kwargs['shift_id']
     volunteer_id = self.kwargs['volunteer_id']
     context['volunteer_id'] = volunteer_id
     context['shift_id'] = shift_id
     context['result'] = clear_shift_hours(volunteer_id, shift_id)
     return context
Example #3
0
File: views.py Project: systers/vms
 def post(self, request, *args, **kwargs):
     volunteer_id = self.kwargs['volunteer_id']
     shift_id = self.kwargs['shift_id']
     result = clear_shift_hours(volunteer_id, shift_id)
     if result:
         return HttpResponseRedirect(
             reverse('shift:view_hours', args=(volunteer_id, )))
     else:
         raise Http404
Example #4
0
 def post(self, request, *args, **kwargs):
     volunteer_id = self.kwargs['volunteer_id']
     shift_id = self.kwargs['shift_id']
     result = clear_shift_hours(volunteer_id, shift_id)
     if result:
         return HttpResponseRedirect(
             reverse('shift:view_hours', args=(volunteer_id, )))
     else:
         raise Http404
    def test_clear_shift_hours(self):
        """ Uses shifts s1, s2, s3 and volunteer v1 """

        register(self.v1.id, self.s1.id)
        self.assertIsNotNone(VolunteerShift.objects.get(
                                                        volunteer_id=self.v1.id,
                                                        shift_id=self.s1.id
                                                        ))

        register(self.v1.id, self.s2.id)
        self.assertIsNotNone(VolunteerShift.objects.get(
                                                        volunteer_id=self.v1.id,
                                                        shift_id=self.s2.id
                                                        ))

        register(self.v1.id, self.s3.id)
        self.assertIsNotNone(VolunteerShift.objects.get(
                                                        volunteer_id=self.v1.id,
                                                        shift_id=self.s3.id
                                                        ))

        start_time = datetime.time(hour=9, minute=0)
        end_time = datetime.time(hour=10, minute=0)
        add_shift_hours(self.v1.id, self.s1.id, start_time, end_time)

        start_time = datetime.time(hour=10, minute=0)
        end_time = datetime.time(hour=12, minute=0)
        add_shift_hours(self.v1.id, self.s2.id, start_time, end_time)

        start_time = datetime.time(hour=5, minute=0)
        end_time = datetime.time(hour=6, minute=0)
        add_shift_hours(self.v1.id, self.s3.id, start_time, end_time)

        clear_shift_hours(self.v1.id, self.s1.id)
        volunteer_shift = VolunteerShift.objects.get(
                                                    volunteer_id=self.v1.id,
                                                    shift_id=self.s1.id
                                                    )
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)

        clear_shift_hours(self.v1.id, self.s2.id)
        volunteer_shift = VolunteerShift.objects.get(
                                                    volunteer_id=self.v1.id,
                                                    shift_id=self.s2.id
                                                    )
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)

        clear_shift_hours(self.v1.id, self.s3.id)
        volunteer_shift = VolunteerShift.objects.get(
                                                    volunteer_id=self.v1.id,
                                                    shift_id=self.s3.id
                                                    )
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)
    def test_clear_shift_hours(self):
        """ Uses shifts s1, s2, s3 and volunteer v1 """

        register(self.v1.id, self.s1.id)
        self.assertIsNotNone(
            VolunteerShift.objects.get(volunteer_id=self.v1.id,
                                       shift_id=self.s1.id))

        register(self.v1.id, self.s2.id)
        self.assertIsNotNone(
            VolunteerShift.objects.get(volunteer_id=self.v1.id,
                                       shift_id=self.s2.id))

        register(self.v1.id, self.s3.id)
        self.assertIsNotNone(
            VolunteerShift.objects.get(volunteer_id=self.v1.id,
                                       shift_id=self.s3.id))

        start_time = datetime.time(hour=9, minute=0)
        end_time = datetime.time(hour=10, minute=0)
        add_shift_hours(self.v1.id, self.s1.id, start_time, end_time)

        start_time = datetime.time(hour=10, minute=0)
        end_time = datetime.time(hour=12, minute=0)
        add_shift_hours(self.v1.id, self.s2.id, start_time, end_time)

        start_time = datetime.time(hour=5, minute=0)
        end_time = datetime.time(hour=6, minute=0)
        add_shift_hours(self.v1.id, self.s3.id, start_time, end_time)

        clear_shift_hours(self.v1.id, self.s1.id)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=self.v1.id,
                                                     shift_id=self.s1.id)
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)

        clear_shift_hours(self.v1.id, self.s2.id)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=self.v1.id,
                                                     shift_id=self.s2.id)
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)

        clear_shift_hours(self.v1.id, self.s3.id)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=self.v1.id,
                                                     shift_id=self.s3.id)
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)
Example #7
0
    def test_clear_shift_hours(self):

        u1 = User.objects.create_user("Yoshi")

        v1 = Volunteer(
            first_name="Yoshi",
            last_name="Turtle",
            address="Mario Land",
            city="Nintendo Land",
            state="Nintendo State",
            country="Nintendo Nation",
            phone_number="2374983247",
            email="*****@*****.**",
            user=u1,
        )

        v1.save()

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j2 = Job(
            name="Systems Administrator",
            start_date="2012-9-1",
            end_date="2012-10-26",
            description="A systems administrator job",
            event=e1,
        )

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)

        s1.save()
        s2.save()
        s3.save()

        register(v1.id, s1.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id))

        register(v1.id, s2.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id))

        register(v1.id, s3.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id))

        start_time = datetime.time(hour=9, minute=0)
        end_time = datetime.time(hour=10, minute=0)
        add_shift_hours(v1.id, s1.id, start_time, end_time)

        start_time = datetime.time(hour=10, minute=0)
        end_time = datetime.time(hour=12, minute=0)
        add_shift_hours(v1.id, s2.id, start_time, end_time)

        start_time = datetime.time(hour=5, minute=0)
        end_time = datetime.time(hour=6, minute=0)
        add_shift_hours(v1.id, s3.id, start_time, end_time)

        clear_shift_hours(v1.id, s1.id)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)

        clear_shift_hours(v1.id, s2.id)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id)
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)

        clear_shift_hours(v1.id, s3.id)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id)
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)