Exemplo n.º 1
0
 def get_queryset(self):
     form_class = MandatesArchivesForm
     form = form_class(self.request.GET)
     current_reviewer = reviewer.find_by_person(self.request.user.person)
     if len(
             assistant_mandate.find_for_supervisor_for_academic_year(
                 self.request.user.person,
                 academic_year.current_academic_year())) > 0:
         self.is_supervisor = True
     mandates_id = mandate_entity.find_by_entity(
         current_reviewer.entity).values_list('assistant_mandate_id',
                                              flat=True)
     if form.is_valid():
         self.request.session['selected_academic_year'] = form.cleaned_data[
             'academic_year'].id
         selected_academic_year = academic_year.AcademicYear.objects.get(
             id=self.request.session.get('selected_academic_year'))
     elif self.request.session.get('selected_academic_year'):
         selected_academic_year = academic_year.AcademicYear.objects.get(
             id=self.request.session.get('selected_academic_year'))
     else:
         selected_academic_year = academic_year.current_academic_year()
         self.request.session[
             'selected_academic_year'] = selected_academic_year.id
     if self.kwargs.get("filter", None):
         selected_academic_year = academic_year.current_academic_year()
         self.request.session[
             'selected_academic_year'] = selected_academic_year.id
         queryset = assistant_mandate.find_by_academic_year(selected_academic_year).filter(id__in=mandates_id).\
             filter(state=current_reviewer.role.replace('_ASSISTANT', ''))
     else:
         queryset = assistant_mandate.find_by_academic_year(
             selected_academic_year).filter(id__in=mandates_id)
     return queryset
 def get_queryset(self):
     form_class = MandatesArchivesForm
     form = form_class(self.request.GET)
     current_reviewer = reviewer.find_by_person(self.request.user.person)
     if len(assistant_mandate.find_for_supervisor_for_academic_year(self.request.user.person,
                                                                    academic_year.current_academic_year())) > 0:
         self.is_supervisor = True
     mandates_id = mandate_entity.find_by_entity(current_reviewer.entity).values_list(
         'assistant_mandate_id', flat=True)
     if form.is_valid():
         self.request.session['selected_academic_year'] = form.cleaned_data[
             'academic_year'].id
         selected_academic_year = academic_year.AcademicYear.objects.get(
             id=self.request.session.get('selected_academic_year'))
     elif self.request.session.get('selected_academic_year'):
         selected_academic_year = academic_year.AcademicYear.objects.get(
             id=self.request.session.get('selected_academic_year'))
     else:
         selected_academic_year = academic_year.current_academic_year()
         self.request.session[
             'selected_academic_year'] = selected_academic_year.id
     if self.kwargs.get("filter", None):
         selected_academic_year = academic_year.current_academic_year()
         self.request.session[
             'selected_academic_year'] = selected_academic_year.id
         queryset = assistant_mandate.find_by_academic_year(selected_academic_year).filter(id__in=mandates_id).\
             filter(state=current_reviewer.role.replace('_ASSISTANT', '').replace('_DAF', ''))
     else:
         queryset = assistant_mandate.find_by_academic_year(selected_academic_year).filter(id__in=mandates_id)
     return queryset
 def test_context_data(self):
     self.client.force_login(self.phd_supervisor.user)
     response = self.client.get('/assistants/reviewer/')
     self.assertEqual(response.context['reviewer'], self.reviewer)
     self.assertTrue(response.context['can_delegate'])
     mandates_id = find_by_entity(self.reviewer.entity).values_list(
         'assistant_mandate_id', flat=True)
     self.assertQuerysetEqual(
         response.context['object_list'],
         find_by_academic_year(
             self.current_academic_year).filter(id__in=mandates_id),
         transform=lambda x: x)
 def test_context_data(self):
     self.reviewer = ReviewerFactory(role=reviewer_role.RESEARCH,
                                     entity=self.entity_version.entity,
                                     person=self.phd_supervisor)
     self.client.force_login(self.phd_supervisor.user)
     response = self.client.get('/assistants/reviewer/')
     self.assertEqual(response.context['reviewer'], find_by_person(self.phd_supervisor))
     self.assertTrue(response.context['can_delegate'])
     mandates_id = find_by_entity(self.reviewer.entity).values_list(
         'assistant_mandate_id', flat=True)
     self.assertQuerysetEqual(response.context['object_list'],
                              find_by_academic_year(self.current_academic_year).filter(id__in=mandates_id),
                              transform=lambda x: x
                              )
Exemplo n.º 5
0
 def test_context_data_for_specific_academic_year(self):
     self.reviewer = ReviewerFactory(role=reviewer_role.RESEARCH,
                                     entity=self.entity_version.entity,
                                     person=self.phd_supervisor)
     self.client.force_login(self.phd_supervisor.user)
     response = self.client.get('/assistants/reviewer/?academic_year=' +
                                str(self.previous_academic_year.id))
     self.assertEqual(response.context['reviewer'],
                      find_by_person(self.phd_supervisor))
     self.assertTrue(response.context['can_delegate'])
     mandates_id = find_by_entity(self.reviewer.entity).values_list(
         'assistant_mandate_id', flat=True)
     self.assertQuerysetEqual(
         response.context['object_list'],
         find_by_academic_year(
             self.previous_academic_year).filter(id__in=mandates_id),
         transform=lambda x: x)
Exemplo n.º 6
0
def find_mandates_for_academic_year_and_entity(academic_year, entity):
    mandates_id = find_by_entity(entity).values_list(
        'assistant_mandate_id', flat=True)
    return assistant_mandate.find_by_academic_year(academic_year).filter(id__in=mandates_id)
Exemplo n.º 7
0
 def test_find_by_entity(self):
     self.assertEqual(self.mandate_entity,
                      mandate_entity.find_by_entity(self.entity).first())
 def test_find_by_entity(self):
     self.assertEqual(self.mandate_entity,
                      mandate_entity.find_by_entity(self.entity).first())