Ejemplo n.º 1
0
 def get_context_data(self, **kwargs):
     context = super(ViewHoursView, self).get_context_data(**kwargs)
     volunteer_id = self.kwargs['volunteer_id']
     context['volunteer'] = get_volunteer_by_id(volunteer_id)
     context['volunteer_shift_list'] = get_volunteer_shifts_with_hours(
         volunteer_id)
     return context
Ejemplo n.º 2
0
Archivo: views.py Proyecto: systers/vms
 def get_context_data(self, **kwargs):
     context = super(ViewHoursView, self).get_context_data(**kwargs)
     volunteer_id = self.kwargs['volunteer_id']
     context['volunteer'] = get_volunteer_by_id(volunteer_id)
     context['volunteer_shift_list'] = get_volunteer_shifts_with_hours(
         volunteer_id)
     context['init_date'] = timezone.now()-timedelta(days=7)
     return context
Ejemplo n.º 3
0
 def get_context_data(self, **kwargs):
     context = super(ViewHoursView, self).get_context_data(**kwargs)
     volunteer_id = self.kwargs['volunteer_id']
     context['volunteer'] = get_volunteer_by_id(volunteer_id)
     context['volunteer_shift_list'] = get_volunteer_shifts_with_hours(
         volunteer_id)
     context['init_date'] = timezone.now() - timedelta(days=7)
     return context
Ejemplo n.º 4
0
Archivo: views.py Proyecto: systers/vms
 def get_context_data(self, **kwargs):
     context = super(ManageVolunteerShiftView, self).get_context_data(
         **kwargs)
     volunteer_id = self.kwargs['volunteer_id']
     context['volunteer'] = get_volunteer_by_id(volunteer_id)
     context['shift_list'] = get_unlogged_shifts_by_volunteer_id(
         volunteer_id)
     context['shift_list_with_hours'] = get_volunteer_shifts_with_hours(
         volunteer_id)
     return context
Ejemplo n.º 5
0
 def get_context_data(self, **kwargs):
     context = super(ManageVolunteerShiftView,
                     self).get_context_data(**kwargs)
     volunteer_id = self.kwargs['volunteer_id']
     context['volunteer'] = get_volunteer_by_id(volunteer_id)
     context['shift_list'] = get_unlogged_shifts_by_volunteer_id(
         volunteer_id)
     context['shift_list_with_hours'] = get_volunteer_shifts_with_hours(
         volunteer_id)
     return context
Ejemplo n.º 6
0
    def test_get_volunteer_shifts_with_hours(self):
        """ Uses volunteers v1 and v2
        Test get_volunteer_shifts_with_hours(v_id) """

        register(self.v1.id, self.s1.id)
        register(self.v1.id, self.s2.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)

        v1_hours = get_volunteer_shifts_with_hours(self.v1)
        v2_hours = get_volunteer_shifts_with_hours(self.v2)

        self.assertIsNotNone(get_volunteer_shifts_with_hours(self.v1))
        self.assertIsNotNone(get_volunteer_shifts_with_hours(self.v2))

        self.assertEqual(len(v1_hours), 1)
        self.assertEqual(self.s1.id, v1_hours[0].shift_id)
        self.assertEqual(len(v2_hours), 0)
Ejemplo n.º 7
0
    def test_get_volunteer_shifts_with_hours(self):
        """ Uses volunteers v1 and v2
        Test get_volunteer_shifts_with_hours(v_id) """

        register(self.v1.id, self.s1.id)
        register(self.v1.id, self.s2.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)

        v1_hours = get_volunteer_shifts_with_hours(self.v1)
        v2_hours = get_volunteer_shifts_with_hours(self.v2)

        self.assertIsNotNone(get_volunteer_shifts_with_hours(self.v1))
        self.assertIsNotNone(get_volunteer_shifts_with_hours(self.v2))

        self.assertEqual(len(v1_hours), 1)
        self.assertEqual(self.s1.id, v1_hours[0].shift_id)
        self.assertEqual(len(v2_hours), 0)
Ejemplo n.º 8
0
def get_signed_up_events_for_volunteer(volunteer_id):
    """ Gets sorted list of signed up events for a volunteer """

    event_list = []
    unsorted_events = []
    shift_list_without_hours = get_unlogged_shifts_by_volunteer_id(
        volunteer_id)
    shift_list_with_hours = get_volunteer_shifts_with_hours(volunteer_id)

    for shift_with_hours in shift_list_with_hours:
        event_name = str(shift_with_hours.shift.job.event.name)
        if event_name not in unsorted_events:
            unsorted_events.append(event_name)
    for shift in shift_list_without_hours:
        event_name = str(shift.job.event.name)
        if event_name not in unsorted_events:
            unsorted_events.append(event_name)

    # for sorting events alphabetically
    for event in sorted(unsorted_events, key=str.lower):
        event_list.append(event)
    return event_list
Ejemplo n.º 9
0
def get_signed_up_jobs_for_volunteer(volunteer_id):
    """ Gets sorted list of signed up jobs for a volunteer """

    unsorted_jobs = []
    job_list = []
    shift_list_without_hours = get_unlogged_shifts_by_volunteer_id(
        volunteer_id)
    shift_list_with_hours = get_volunteer_shifts_with_hours(volunteer_id)

    for shift_with_hours in shift_list_with_hours:
        job_name = str(shift_with_hours.shift.job.name)
        if job_name not in unsorted_jobs:
            unsorted_jobs.append(job_name)
    for shift in shift_list_without_hours:
        job_name = str(shift.job.name)
        if job_name not in unsorted_jobs:
            unsorted_jobs.append(job_name)

    # to sort jobs as per name
    for job in sorted(unsorted_jobs, key=str.lower):
        job_list.append(job)
    return job_list
Ejemplo n.º 10
0
def get_signed_up_events_for_volunteer(volunteer_id):
    """ Gets sorted list of signed up events for a volunteer """

    event_list = []
    unsorted_events = []
    shift_list_without_hours = get_unlogged_shifts_by_volunteer_id(
        volunteer_id)
    shift_list_with_hours = get_volunteer_shifts_with_hours(volunteer_id)

    for shift_with_hours in shift_list_with_hours:
        event_name = str(shift_with_hours.shift.job.event.name)
        if event_name not in unsorted_events:
            unsorted_events.append(event_name)
    for shift in shift_list_without_hours:
        event_name = str(shift.job.event.name)
        if event_name not in unsorted_events:
            unsorted_events.append(event_name)

    # for sorting events alphabetically
    for event in sorted(unsorted_events, key=str.lower):
        event_list.append(event)
    return event_list
Ejemplo n.º 11
0
    def test_get_volunteer_shifts_with_hours(self):
        """ Test  get_volunteer_shifts_with_hours(v_id) """
        u1 = User.objects.create_user("Yoshi")
        u2 = User.objects.create_user("John")

        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,
        )

        v2 = Volunteer(
            first_name="John",
            last_name="Doe",
            address="7 Alpine Street",
            city="Maplegrove",
            state="Wyoming",
            country="USA",
            phone_number="23454545",
            email="*****@*****.**",
            user=u2,
        )

        v1.save()
        v2.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()

        self.assertIsNotNone(get_volunteer_shifts_with_hours(v1))
        self.assertIsNotNone(get_volunteer_shifts_with_hours(v2))