Exemplo n.º 1
0
    def setUp(self):
        Group.objects.get_or_create(name='tutors')
        self.person = PersonFactory()
        self.tutor = TutorFactory(person=self.person)

        attribution_permission = Permission.objects.get(
            codename='can_access_attribution')
        self.person.user.user_permissions.add(attribution_permission)

        today = datetime.datetime.today()
        self.academic_year = AcademicYearFactory(
            year=today.year,
            start_date=today - datetime.timedelta(days=5),
            end_date=today + datetime.timedelta(days=5))
        self.learning_unit_year = LearningUnitYearFactory(
            academic_year=self.academic_year,
            learning_container_year__academic_year=self.academic_year,
            learning_container_year__in_charge=True)
        self.attribution = AttributionFactory(
            function=function.CO_HOLDER,
            learning_unit_year=self.learning_unit_year,
            tutor=self.tutor,
            external_id=ATTRIBUTION_EXTERNAL_ID)

        self.url = reverse('attribution_home')
        self.client.force_login(self.person.user)
Exemplo n.º 2
0
    def test_list_teaching_charge_for_multiple_attributions_less_in_json(
            self, mock_requests_get):

        an_other_attribution = AttributionFactory(
            learning_unit_year=self.get_data('learning_unit_year'),
            tutor=self.a_tutor,
            external_id=OTHER_ATTRIBUTION_EXTERNAL_ID)
        inexisting_external_id = "osis.attribution_8082"

        attribution_not_in_json = AttributionFactory(
            learning_unit_year=self.get_data('learning_unit_year'),
            tutor=self.a_tutor,
            external_id=inexisting_external_id)

        teaching_charge = tutor_charge.list_teaching_charge(
            self.a_tutor.person, self.get_data('academic_year'))

        self.assertTrue(mock_requests_get.called)

        attributions = teaching_charge["attributions"]
        tot_lecturing = teaching_charge["tot_lecturing"]
        tot_practical = teaching_charge["tot_practical"]

        self.assertEqual(len(attributions), 2)
        self.assertEqual(tot_lecturing, LEARNING_UNIT_LECTURING_DURATION)
        self.assertEqual(tot_practical,
                         LEARNING_UNIT_PRACTICAL_EXERCISES_DURATION)
Exemplo n.º 3
0
    def test_with_attribution_not_recognized(self, mock_requests_get):
        an_other_attribution = AttributionFactory(
            learning_unit_year=self.learning_unit_year,
            tutor=self.tutor,
            external_id=OTHER_ATTRIBUTION_EXTERNAL_ID)

        inexisting_external_id = "osis.attribution_8082"
        attribution_not_in_json = AttributionFactory(
            learning_unit_year=self.learning_unit_year,
            tutor=self.tutor,
            external_id=inexisting_external_id)

        response = self.client.get(self.url)

        self.assertTrue(mock_requests_get.called)

        self.assertTemplateUsed(response, 'tutor_charge.html')

        self.assertEqual(response.context['user'], self.person.user)
        self.assertEqual(response.context['year'],
                         int(self.academic_year.year))
        self.assertEqual(response.context['tot_lecturing'],
                         LEARNING_UNIT_LECTURING_DURATION)
        self.assertEqual(response.context['tot_practical'],
                         LEARNING_UNIT_PRACTICAL_EXERCISES_DURATION)
        self.assertEqual(response.context['academic_year'], self.academic_year)
        self.assertEqual(response.context['global_id'], self.person.global_id)
        self.assertEqual(response.context['error'], False)

        self.assertIsInstance(response.context['formset'], BaseFormSet)

        self.assertEqual(len(response.context['attributions']), 2)
Exemplo n.º 4
0
    def setUpTestData(cls):
        group = EntityManagerGroupFactory()
        group.permissions.add(
            Permission.objects.get(codename='view_scoresresponsible'))
        group.permissions.add(
            Permission.objects.get(codename='change_scoresresponsible'))

        cls.tutor = TutorFactory()
        cls.user = cls.tutor.person.user
        cls.academic_year = AcademicYearFactory(current=True)

        # FIXME: Old structure model [To remove]
        cls.structure = structure.StructureFactory()
        cls.structure_children = structure.StructureFactory(
            part_of=cls.structure)

        # New structure model
        entities_hierarchy = create_entities_hierarchy()
        cls.root_entity = entities_hierarchy.get('root_entity')
        cls.child_one_entity = entities_hierarchy.get('child_one_entity')
        cls.child_two_entity = entities_hierarchy.get('child_two_entity')
        cls.learning_unit_yr_req_entity_acronym = entities_hierarchy.get(
            'child_one_entity_version').acronym
        cls.root_entity_acronym = entities_hierarchy.get(
            'root_entity_version').acronym

        cls.entity_manager = EntityManagerFactory(
            person=cls.tutor.person,
            structure=cls.structure,
            entity=cls.root_entity,
        )

        cls.learning_unit_year = LearningUnitYearFactory(
            academic_year=cls.academic_year,
            acronym="LBIR1210",
            structure=cls.structure,
            learning_container_year__academic_year=cls.academic_year,
            learning_container_year__acronym="LBIR1210",
            learning_container_year__requirement_entity=cls.child_one_entity,
        )

        cls.learning_unit_year_children = LearningUnitYearFactory(
            academic_year=cls.academic_year,
            acronym="LBIR1211",
            structure=cls.structure_children,
            learning_container_year__academic_year=cls.academic_year,
            learning_container_year__acronym="LBIR1211",
            learning_container_year__requirement_entity=cls.child_two_entity,
        )

        cls.attribution = AttributionFactory(
            tutor=cls.tutor,
            learning_unit_year=cls.learning_unit_year,
            score_responsible=True)
        cls.attribution_children = AttributionFactory(
            tutor=cls.tutor,
            learning_unit_year=cls.learning_unit_year_children,
            score_responsible=True)
        cls.url = reverse('scores_responsible_list')
        cls.user.groups.add(group)
Exemplo n.º 5
0
 def test_when_not_attributed_to_the_learning_unit_year(self):
     an_attribution = AttributionFactory(
         summary_responsible=True, learning_unit_year__summary_locked=False)
     an_other_attribution = AttributionFactory(
         summary_responsible=True, learning_unit_year__summary_locked=False)
     can_edit_educational_information = can_user_edit_educational_information(
         an_other_attribution.tutor.person.user,
         an_attribution.learning_unit_year.id)
     self.assertFalse(can_edit_educational_information)
Exemplo n.º 6
0
    def test_find_learning_unit_years_by_academic_year_tutor_attributions_case_distinct_occurrence_found(self):
        """In this test, we ensure that user see one line per learning unit year despite multiple attribution"""
        AttributionFactory(learning_unit_year=self.learning_unit_year, tutor=self.tutor, function=COORDINATOR)
        AttributionFactory(learning_unit_year=self.learning_unit_year, tutor=self.tutor, function=CO_HOLDER)
        AttributionFactory(learning_unit_year=self.learning_unit_year, tutor=self.tutor)

        result = find_learning_unit_years_by_academic_year_tutor_attributions(
            academic_year=self.current_academic_year,
            tutor=self.tutor
        )
        self.assertIsInstance(result, QuerySet)
        self.assertEqual(result.count(), 1)
Exemplo n.º 7
0
    def test_is_not_summary_responsible(self):
        Group.objects.create(name="tutors")
        AttributionFactory()

        response = self.client.get(self.url)
        context = response.context
        self.assertFalse(context["is_summary_responsible"])
Exemplo n.º 8
0
    def test_learning_units_summary_list(self, mock_render):
        request_factory = RequestFactory()

        now = datetime.datetime.now()

        EntityVersionFactory(entity=self.an_entity,
                             start_date=now,
                             end_date=datetime.datetime(now.year + 1, 9, 15),
                             entity_type='INSTITUTE')

        request = request_factory.get(
            self.url, data={'academic_year_id': starting_academic_year().id})
        request.user = self.faculty_user

        lu = self._create_learning_unit_year_for_entity(self.an_entity)
        person_lu = PersonFactory()
        tutor_lu_1 = TutorFactory(person=person_lu)
        self.attribution_lu = AttributionFactory(learning_unit_year=lu,
                                                 tutor=tutor_lu_1,
                                                 summary_responsible=True)
        self._create_entity_calendar(self.an_entity)
        self.client.force_login(self.faculty_user)

        learning_units_summary_list(request)

        self.assertTrue(mock_render.called)
        request, template, context = mock_render.call_args[0]
        self.assertEqual(template, 'learning_units.html')
        self.assertEqual(context['search_type'], SUMMARY_LIST)
        self.assertEqual(len(context['learning_units_with_errors']), 1)
        self.assertTrue(context['is_faculty_manager'])
Exemplo n.º 9
0
    def setUpTestData(cls):
        cls.person = PersonFactory()
        cls.user = cls.person.user
        cls.tutor = TutorFactory(person=cls.person)
        cls.current_ac_year = create_current_academic_year()
        ac_year_in_past = AcademicYearFactory.produce_in_past(
            cls.current_ac_year.year)
        cls.ac_year_in_future = AcademicYearFactory.produce_in_future(
            cls.current_ac_year.year)

        cls.academic_calendar = OpenAcademicCalendarFactory(
            academic_year=cls.current_ac_year,
            data_year=cls.current_ac_year,
            reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)
        requirement_entity = EntityVersionFactory().entity
        # Create multiple attribution in different academic years
        for ac_year in ac_year_in_past + [cls.current_ac_year
                                          ] + cls.ac_year_in_future:
            learning_container_year = LearningContainerYearFactory(
                academic_year=ac_year, requirement_entity=requirement_entity)
            learning_unit_year = LearningUnitYearFactory(
                summary_locked=False,
                academic_year=ac_year,
                learning_container_year=learning_container_year)
            AttributionFactory(
                tutor=cls.tutor,
                summary_responsible=True,
                learning_unit_year=learning_unit_year,
            )
        cls.url = reverse(list_my_attributions_summary_editable)
Exemplo n.º 10
0
 def setUpTestData(cls):
     cls.current_academic_year = create_current_academic_year()
     cls.academic_calendar = AcademicCalendarFactory(
         academic_year=cls.current_academic_year,
         data_year=cls.current_academic_year,
         reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION,
     )
     cls.academic_year_in_future = AcademicYearFactory(
         year=cls.current_academic_year.year + 1)
     cls.academic_calendar = OpenAcademicCalendarFactory(
         academic_year=cls.academic_year_in_future,
         data_year=cls.academic_year_in_future,
         reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION,
     )
     a_valid_entity_version = EntityVersionFactory(entity_type=FACULTY)
     cls.learning_unit_year = LearningUnitYearFactory(
         subtype=FULL,
         academic_year=cls.academic_year_in_future,
         learning_container_year__academic_year=cls.academic_year_in_future,
         learning_container_year__requirement_entity=a_valid_entity_version.
         entity,
         summary_locked=False)
     cls.tutor = _get_tutor()
     # Add attribution to course [set summary responsible]
     AttributionFactory(
         tutor=cls.tutor,
         summary_responsible=True,
         learning_unit_year=cls.learning_unit_year,
     )
Exemplo n.º 11
0
    def create_lu_yr_annual_data(self, a_year):
        an_academic_yr = test_academic_year.create_academic_year_with_year(
            a_year)
        an_academic_yr.year = a_year
        a_container_year = LearningContainerYearFactory(in_charge=True)
        a_learning_unit_year = test_learning_unit_year.create_learning_unit_year(
            {
                'acronym': ACRONYM,
                'specific_title': TITLE,
                'academic_year': an_academic_yr,
                'weight': WEIGHT,
                'subtype': learning_unit_year_subtypes.FULL,
            })
        a_learning_unit_year.learning_container_year = a_container_year
        a_learning_unit_year.save()
        an_attribution = AttributionFactory(
            function=function.CO_HOLDER,
            learning_unit_year=a_learning_unit_year,
            tutor=self.a_tutor,
            external_id=ATTRIBUTION_EXTERNAL_ID)

        return {
            'academic_year': an_academic_yr,
            'learning_unit_year': a_learning_unit_year,
            'attribution': an_attribution
        }
Exemplo n.º 12
0
    def setUpTestData(cls):
        cls.person = PersonFactory()
        cls.user = cls.person.user
        cls.tutor = TutorFactory(person=cls.person)
        cls.current_ac_year = create_current_academic_year()
        ac_year_in_future = GenerateAcademicYear(
            start_year=cls.current_ac_year.year + 1,
            end_year=cls.current_ac_year.year + 5)
        cls.academic_calendar = AcademicCalendarFactory(
            academic_year=cls.current_ac_year,
            reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)

        # Create multiple attribution in different academic years
        for ac_year in [cls.current_ac_year
                        ] + ac_year_in_future.academic_years:
            learning_container_year = LearningContainerYearFactory(
                academic_year=ac_year)
            learning_unit_year = LearningUnitYearFactory(
                summary_locked=False,
                academic_year=ac_year,
                learning_container_year=learning_container_year)
            AttributionFactory(
                tutor=cls.tutor,
                summary_responsible=True,
                learning_unit_year=learning_unit_year,
            )
        cls.url = reverse(list_my_attributions_summary_editable)
Exemplo n.º 13
0
 def setUpTestData(cls):
     cls.current_academic_year = create_current_academic_year()
     cls.academic_calendar = AcademicCalendarFactory(
         academic_year=cls.current_academic_year,
         reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION,
         start_date=datetime.date(timezone.now().year - 1, 9, 30),
         end_date=datetime.date(timezone.now().year + 1, 9, 30))
     cls.academic_year_in_future = AcademicYearFactory(
         year=cls.current_academic_year.year + 1)
     cls.learning_unit_year = LearningUnitYearFactory(
         subtype=FULL,
         academic_year=cls.academic_year_in_future,
         learning_container_year__academic_year=cls.academic_year_in_future,
         summary_locked=False)
     a_valid_entity_version = EntityVersionFactory(entity_type=FACULTY)
     EntityContainerYearFactory(
         learning_container_year=cls.learning_unit_year.
         learning_container_year,
         entity=a_valid_entity_version.entity,
         type=entity_container_year_link_type.REQUIREMENT_ENTITY)
     cls.tutor = _get_tutor()
     # Add attribution to course [set summary responsible]
     AttributionFactory(
         tutor=cls.tutor,
         summary_responsible=True,
         learning_unit_year=cls.learning_unit_year,
     )
Exemplo n.º 14
0
    def test_learning_units_summary_list(self):
        now = datetime.datetime.now()

        EntityVersionFactory(entity=self.an_entity,
                             start_date=now,
                             end_date=datetime.datetime(now.year + 1, 9, 15),
                             entity_type='INSTITUTE')

        lu = self._create_learning_unit_year_for_entity(
            self.an_entity, "LBIR1100")
        person_lu = PersonFactory()
        tutor_lu_1 = TutorFactory(person=person_lu)
        self.attribution_lu = AttributionFactory(learning_unit_year=lu,
                                                 tutor=tutor_lu_1,
                                                 summary_responsible=True)
        self._create_entity_calendar(self.an_entity)
        self.client.force_login(self.faculty_user)

        response = self.client.get(
            self.url, data={'academic_year_id': starting_academic_year().id})
        self.assertTemplateUsed(response, 'learning_units.html')
        context = response.context
        self.assertEqual(context['search_type'], SUMMARY_LIST)
        self.assertEqual(context['learning_units_count'], 1)
        self.assertTrue(context['is_faculty_manager'])
Exemplo n.º 15
0
    def test_with_post_and_webservice_is_available(self, mock_fetch):
        today = datetime.datetime.today()
        an_academic_year = AcademicYearFactory(
            year=today.year,
            start_date=today - datetime.timedelta(days=5),
            end_date=today + datetime.timedelta(days=5))
        a_learning_unit_year = LearningUnitYearFactory(
            academic_year=an_academic_year,
            learning_container_year__academic_year=an_academic_year)
        AttributionFactory(learning_unit_year=a_learning_unit_year,
                           tutor=self.tutor)

        key = '{}{}'.format(LEARNING_UNIT_ACRONYM_ID,
                            a_learning_unit_year.acronym)
        response = self.client.post(self.url, data={key: ""})

        filename = "Liste_Insc_Exam.xls"
        self.assertEqual(response.status_code, OK)
        self.assertTrue(mock_fetch.called)
        self.assertEqual(
            response['Content-Type'],
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
        )
        self.assertEqual(response['Content-Disposition'],
                         'attachment; filename="{}"'.format(filename))
        self.assertEqual(response.content.decode(), str(return_sample_xls()))
Exemplo n.º 16
0
    def test_when_trying_to_access_other_tutor_students_list(self):
        an_other_tutor = TutorFactory()
        an_other_tutor.person.user.user_permissions.add(
            Permission.objects.get(codename="can_access_attribution"))
        self.client.force_login(an_other_tutor.person.user)
        today = datetime.datetime.today()
        an_academic_year = AcademicYearFactory(
            year=today.year,
            start_date=today - datetime.timedelta(days=5),
            end_date=today + datetime.timedelta(days=5))
        a_learning_unit_year = LearningUnitYearFactory(
            academic_year=an_academic_year)
        AttributionFactory(learning_unit_year=a_learning_unit_year,
                           tutor=self.tutor)

        key = '{}{}'.format(LEARNING_UNIT_ACRONYM_ID,
                            a_learning_unit_year.acronym)
        response = self.client.post(self.url, data={key: ""})

        self.assertEqual(response.status_code, OK)
        self.assertTemplateUsed(response, 'list/students_exam.html')

        self.assertEqual(response.context['person'], an_other_tutor.person)
        self.assertEqual(response.context['my_learning_units'], [])
        self.assertEqual(response.context['msg_error'], _('No data found'))
Exemplo n.º 17
0
    def test_with_post_but_webservice_unavailable(self, mock_fetch):
        today = datetime.datetime.today()
        an_academic_year = AcademicYearFactory(
            year=today.year,
            start_date=today - datetime.timedelta(days=5),
            end_date=today + datetime.timedelta(days=5))
        a_learning_unit_year = LearningUnitYearFactory(
            academic_year=an_academic_year,
            learning_container_year__academic_year=an_academic_year)
        AttributionFactory(learning_unit_year=a_learning_unit_year,
                           tutor=self.tutor)

        key = '{}{}'.format(LEARNING_UNIT_ACRONYM_ID,
                            a_learning_unit_year.acronym)
        response = self.client.post(self.url, data={key: ""})

        self.assertTrue(mock_fetch.called)

        self.assertEqual(response.status_code, OK)
        self.assertTemplateUsed(response, 'admin/students_exam_list.html')

        self.assertEqual(response.context['person'], self.tutor.person)
        self.assertEqual(response.context['learning_units'],
                         [a_learning_unit_year])
        self.assertEqual(response.context['msg_error'], _('No data found'))
Exemplo n.º 18
0
    def test_with_missing_values(self, mock_requests_get):
        an_other_attribution = AttributionFactory(
            learning_unit_year=self.learning_unit_year,
            tutor=self.tutor,
            external_id=OTHER_ATTRIBUTION_EXTERNAL_ID)

        response = self.client.get(self.url)

        self.assertTrue(mock_requests_get.called)

        self.assertTemplateUsed(response, 'tutor_charge.html')

        self.assertEqual(response.context['user'], self.person.user)
        self.assertEqual(response.context['year'],
                         int(self.academic_year.year))
        self.assertEqual(response.context['tot_lecturing'],
                         LEARNING_UNIT_LECTURING_DURATION)
        self.assertEqual(response.context['tot_practical'],
                         LEARNING_UNIT_PRACTICAL_EXERCISES_DURATION)
        self.assertEqual(response.context['academic_year'], self.academic_year)
        self.assertEqual(response.context['global_id'], self.person.global_id)
        self.assertEqual(response.context['error'], False)

        self.assertIsInstance(response.context['formset'], BaseFormSet)

        attributions = response.context['attributions']
        reduced_list_attributions = map(
            lambda attribution: [
                attribution["lecturing_allocation_charge"], attribution[
                    'practice_allocation_charge'], attribution[
                        'percentage_allocation_charge']
            ], attributions)
        self.assertIn([str(LEARNING_UNIT_LECTURING_DURATION), None, "25.0"],
                      reduced_list_attributions)
Exemplo n.º 19
0
    def setUp(self):
        today = datetime.datetime.today()
        twenty_days = datetime.timedelta(days=20)

        #Take same academic year as the one in the associated xls file
        an_academic_year = AcademicYearFactory(year=2017)

        a_learning_unit_year = LearningUnitYearFakerFactory(
            academic_year=an_academic_year, acronym=LEARNING_UNIT_ACRONYM)

        tutor = TutorFactory()

        an_academic_calendar = AcademicCalendarFactory(
            academic_year=an_academic_year,
            start_date=today - twenty_days,
            end_date=today + twenty_days,
            reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        SessionExamCalendarFactory(number_session=number_session.ONE,
                                   academic_calendar=an_academic_calendar)
        AttributionFactory(learning_unit_year=a_learning_unit_year,
                           tutor=tutor)
        a_session_exam = SessionExamFactory(
            number_session=number_session.ONE,
            learning_unit_year=a_learning_unit_year)

        self.person_student_1 = PersonFactory(email=EMAIL_1)
        person_student_2 = PersonFactory(email=EMAIL_2)

        student_1 = StudentFactory(registration_id=REGISTRATION_ID_1,
                                   person=self.person_student_1)
        student_2 = StudentFactory(registration_id=REGISTRATION_ID_2,
                                   person=person_student_2)

        an_offer_year = OfferYearFactory(academic_year=an_academic_year,
                                         acronym=OFFER_ACRONYM)
        offer_enrollment_1 = OfferEnrollmentFactory(offer_year=an_offer_year,
                                                    student=student_1)
        offer_enrollment_2 = OfferEnrollmentFactory(offer_year=an_offer_year,
                                                    student=student_2)

        learning_unit_enrollment_1 = LearningUnitEnrollmentFactory(
            learning_unit_year=a_learning_unit_year,
            offer_enrollment=offer_enrollment_1)
        learning_unit_enrollment_2 = LearningUnitEnrollmentFactory(
            learning_unit_year=a_learning_unit_year,
            offer_enrollment=offer_enrollment_2)

        ExamEnrollmentFactory(
            session_exam=a_session_exam,
            learning_unit_enrollment=learning_unit_enrollment_1)
        ExamEnrollmentFactory(
            session_exam=a_session_exam,
            learning_unit_enrollment=learning_unit_enrollment_2)

        user = tutor.person.user
        self.client = Client()
        self.client.force_login(user=user)
        self.url = reverse(
            'upload_encoding',
            kwargs={'learning_unit_year_id': a_learning_unit_year.id})
Exemplo n.º 20
0
 def setUpTestData(cls):
     cls.tutor = TutorFactory()
     cls.attribution = AttributionFactory(tutor=cls.tutor,
                                          summary_responsible=True)
     cls.url = reverse("tutor_edit_educational_information",
                       args=[cls.attribution.learning_unit_year.id])
     cls.tutor.person.user.user_permissions.add(
         Permission.objects.get(codename='can_edit_learningunit_pedagogy'))
Exemplo n.º 21
0
 def test_summary_responsible_when_multiple_attribution_for_same_tutor(self):
     luy = LearningUnitYearFactory()
     attr1 = AttributionFactory(
         function=COORDINATOR,
         learning_unit_year=luy,
         summary_responsible=False,
     )
     AttributionFactory(
         function=CO_HOLDER,
         tutor=attr1.tutor,
         learning_unit_year=luy,
         summary_responsible=True,
     )  # Second attribution with different function
     result = attribution.find_all_responsible_by_learning_unit_year(luy, '-summary_responsible')
     self.assertEqual(result.count(), 1)
     self.assertNotEqual(result.count(), 2)  # Prevent from duplication of Tutor name
     self.assertTrue(result.get().summary_responsible)
Exemplo n.º 22
0
def _create_attribution(learning_unit_year, person, is_score_responsible=False):
    PersonAddressFactory(person=person, label='PROFESSIONAL', city="Louvain-la-neuve")
    PersonAddressFactory(person=person, label='PRIVATE', city="Bruxelles")
    return AttributionFactory(
        learning_unit_year=learning_unit_year,
        tutor=TutorFactory(person=person),
        score_responsible=is_score_responsible
    )
Exemplo n.º 23
0
 def setUp(self):
     self.current_academic_year = create_current_academic_year()
     self.learning_unit_year = LearningUnitYearFactory(
         academic_year=self.current_academic_year,
         learning_container_year__academic_year=self.current_academic_year,
     )
     self.tutor = TutorFactory()
     AttributionFactory(learning_unit_year=self.learning_unit_year, tutor=self.tutor)
Exemplo n.º 24
0
 def setUp(self):
     group = Group(name="tutors")
     group.save()
     self.attribution = AttributionFactory()
     today = datetime.datetime.today()
     self.an_academic_year = AcademicYearFactory(year=today.year)
     self.user = UserFactory()
     self.person = test_person.create_person_with_user(self.user)
     self.tutor = TutorFactory(person=self.person)
Exemplo n.º 25
0
    def test_is_summary_responsible(self):
        Group.objects.create(name="tutors")
        an_attribution = AttributionFactory(summary_responsible=True)
        an_attribution.tutor.person.user = self.user
        an_attribution.tutor.person.save()

        response = self.client.get(self.url)
        context = response.context
        self.assertTrue(context["is_summary_responsible"])
Exemplo n.º 26
0
 def setUpTestData(cls):
     cls.current_academic_year = create_current_academic_year()
     cls.learning_unit_year = LearningUnitYearFactory(
         academic_year=cls.current_academic_year,
         learning_container_year__academic_year=cls.current_academic_year,
     )
     cls.tutor = TutorFactory()
     AttributionFactory(learning_unit_year=cls.learning_unit_year,
                        tutor=cls.tutor)
Exemplo n.º 27
0
 def setUp(self):
     attrib = AttributionFactory(learning_unit_year=self.learning_unit_year,
                                 score_responsible=False)
     self.url = reverse('scores_responsible_add',
                        kwargs={'pk': self.learning_unit_year.pk})
     self.post_data = {
         'action': 'add',
         'attribution': "attribution_%d" % attrib.pk
     }
     self.client.force_login(self.person.user)
Exemplo n.º 28
0
    def setUp(self):
        today = datetime.date.today()
        academic_year = AcademicYearFakerFactory(start_date=today-datetime.timedelta(days=3), year=today.year,
                                                 end_date=today + datetime.timedelta(days=5))
        self.summary_course_submission_calendar = \
            AcademicCalendarFactory(academic_year=academic_year,
                                    start_date=academic_year.start_date,
                                    end_date=academic_year.end_date,
                                    reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)

        self.tutor = TutorFactory()

        learning_container_year = LearningContainerYearFactory(academic_year=academic_year)
        self.learning_unit_year = LearningUnitYearFakerFactory(academic_year=academic_year,
                                                               learning_container_year=learning_container_year)
        self.attribution = AttributionFactory(learning_unit_year=self.learning_unit_year, summary_responsible=True,
                                              tutor=self.tutor)

        self.url = reverse('learning_unit_summary_edit', args=[self.learning_unit_year.id])
        self.client.force_login(self.tutor.person.user)
Exemplo n.º 29
0
    def test_is_tutor_summary_responsible_of_learning_unit_year(self):
        attribution_not_summary_responsible = AttributionFactory(tutor=self.tutor)
        luy = attribution_not_summary_responsible.learning_unit_year
        with self.assertRaises(PermissionDenied):
            _is_tutor_summary_responsible_of_learning_unit_year(user=self.tutor.person.user,
                                                                learning_unit_year_id=luy.id)

        self.assertIsNone(
            _is_tutor_summary_responsible_of_learning_unit_year(user=self.tutor.person.user,
                                                                learning_unit_year_id=self.learning_unit_year.id)
        )
Exemplo n.º 30
0
 def setUp(self):
     self.tutor = TutorFactory()
     self.learning_unit_years = [
         LearningUnitYearFactory(summary_locked=False) for i in range(4)
     ]
     self.attributions = [
         AttributionFactory(tutor=self.tutor,
                            summary_responsible=True,
                            learning_unit_year=self.learning_unit_years[i])
         for i in range(4)
     ]