Example #1
0
    def test_get_jobs_by_event_id(self):
        """ Test get_jobs_by_event_id(e_id) 
        Uses jobs j1,j2,j3 and event e1, e2 """

        # test typical case
        job_list = get_jobs_by_event_id(self.e1.id)
        job_list_2 = get_jobs_by_event_id(self.e2.id)
        self.assertIsNotNone(job_list)
        self.assertNotEqual(job_list, False)
        self.assertEqual(len(job_list), 3)
        self.assertEqual(len(job_list_2), 0)
        self.assertIn(self.j1, job_list)
        self.assertIn(self.j2, job_list)
        self.assertIn(self.j3, job_list)
    def test_get_jobs_by_event_id(self):
        """ Test get_jobs_by_event_id(e_id) 
        Uses jobs j1,j2,j3 and event e1, e2 """

        # test typical case
        job_list = get_jobs_by_event_id(self.e1.id)
        job_list_2 = get_jobs_by_event_id(self.e2.id)
        self.assertIsNotNone(job_list)
        self.assertNotEqual(job_list, False)
        self.assertEqual(len(job_list), 3)
        self.assertEqual(len(job_list_2), 0)
        self.assertIn(self.j1, job_list)
        self.assertIn(self.j2, job_list)
        self.assertIn(self.j3, job_list)
Example #3
0
def list_sign_up(request, event_id, volunteer_id):
    if event_id:
        event = get_event_by_id(event_id)
        if request.method == 'POST':
            form = SearchJobForm(request.POST)
            if form.is_valid():
                name = form.cleaned_data['name']
                start_date = form.cleaned_data['start_date']
                end_date = form.cleaned_data['end_date']
                city = form.cleaned_data['city']
                state = form.cleaned_data['state']
                country = form.cleaned_data['country']
                search_result = search_jobs(name, start_date, end_date, city,
                                            state, country, '')
                search_result_list = search_result.filter(event_id=event_id)
        else:
            form = SearchJobForm()
            search_result_list = get_jobs_by_event_id(event_id)
        job_list = remove_empty_jobs_for_volunteer(search_result_list,
                                                   volunteer_id)
        return render(
            request, 'job/list_sign_up.html', {
                'form': form,
                'job_list': job_list,
                'volunteer_id': volunteer_id,
                'event': event,
            })
    else:
        raise Http404
Example #4
0
File: views.py Project: systers/vms
def list_sign_up(request, event_id, volunteer_id):
    if event_id:
        event = get_event_by_id(event_id)
        if request.method == 'POST':
            form = SearchJobForm(request.POST)
            if form.is_valid():
                name = form.cleaned_data['name']
                start_date = form.cleaned_data['start_date']
                end_date = form.cleaned_data['end_date']
                city = form.cleaned_data['city']
                state = form.cleaned_data['state']
                country = form.cleaned_data['country']
                search_result = search_jobs(name, start_date, end_date,
                                            city, state, country, '')
                search_result_list = search_result.filter(event_id=event_id)
        else:
                form = SearchJobForm()
                search_result_list = get_jobs_by_event_id(event_id)
        job_list = remove_empty_jobs_for_volunteer(search_result_list, volunteer_id)
        return render(
            request, 'job/list_sign_up.html', {
                'form': form,
                'job_list': job_list,
                'volunteer_id': volunteer_id,
                'event': event,
            })
    else:
        raise Http404
Example #5
0
def remove_empty_events_for_volunteer(event_list, volunteer_id):
    """ Removes all events from an event list without jobs or shifts """
    new_event_list = []
    for event in event_list:
        job_list = get_jobs_by_event_id(event.id)
        job_list = remove_empty_jobs_for_volunteer(job_list, volunteer_id)
        if job_list:
            new_event_list.append(event)
    return new_event_list
Example #6
0
def remove_empty_events_for_volunteer(event_list, volunteer_id):
    """ Removes all events from an event list without jobs or shifts """
    new_event_list = []
    for event in event_list:
        job_list = get_jobs_by_event_id(event.id)
        job_list = remove_empty_jobs_for_volunteer(job_list, volunteer_id)
        if job_list:
            new_event_list.append(event)
    return new_event_list
Example #7
0
def remove_empty_events(event_list, volunteer_id):
    """ Removes all events from an event list without jobs, or events
        that have jobs but not shifts"""
    new_event_list = []
    for event in event_list:
        job_list = get_jobs_by_event_id(event.id)
        job_list = remove_empty_jobs(job_list, volunteer_id)
        if job_list:
            new_event_list.append(event)
    return new_event_list
Example #8
0
    def test_get_jobs_by_event_id(self):
        """ Test get_jobs_by_event_id(e_id) """

        e1 = Event(
                name="Software Conference",
                start_date="2012-10-22",
                end_date="2012-10-25"
                )

        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
                )

        j3 = Job(
                name="Project Manager",
                start_date="2012-1-2",
                end_date="2012-2-2",
                description="A management job",
                event=e1
                )

        j1.save()
        j2.save()
        j3.save()

        # test typical case
        job_list = get_jobs_by_event_id(e1.id)
        self.assertIsNotNone(job_list)
        self.assertNotEqual(job_list, False)
        self.assertEqual(len(job_list), 3)
        self.assertIn(j1, job_list)
        self.assertIn(j2, job_list)
        self.assertIn(j3, job_list)
Example #9
0
 def get_context_data(self, **kwargs):
     context = super(EventUpdateView, self).get_context_data(**kwargs)
     job_obj = get_jobs_by_event_id(self.kwargs['event_id'])
     context['job_list'] = job_obj.values_list('start_date',
                                               'end_date').distinct()
     context['country_list'] = Country.objects.all()
     event_id = self.kwargs['event_id']
     event = get_event_by_id(event_id)
     if event.country:
         country = event.country
         state_list = Region.objects.filter(country=country)
         context['state_list'] = state_list
     if event.state:
         state = event.state
         city_list = City.objects.filter(region=state)
         context['city_list'] = city_list
     return context
Example #10
0
 def get_context_data(self, **kwargs):
     context = super(EventUpdateView, self).get_context_data(**kwargs)
     job_obj = get_jobs_by_event_id(self.kwargs['event_id'])
     context['job_list'] = job_obj.values_list('start_date',
                                               'end_date').distinct()
     return context
Example #11
0
File: views.py Project: systers/vms
 def get_context_data(self, **kwargs):
     context = super(EventUpdateView, self).get_context_data(**kwargs)
     job_obj = get_jobs_by_event_id(self.kwargs['event_id'])
     context['job_list'] = job_obj.values_list('start_date',
                                               'end_date').distinct()
     return context