コード例 #1
0
    def test_li_edit_lu_year_non_editable_for_faculty_manager(self):
        faculty_manager = FacultyManagerFactory()

        self.context["learning_unit_year"] = self.previous_learning_unit_year
        self.context["user"] = faculty_manager.user

        result = li_edit_lu(self.context, self.url_edit, "")

        self.assertEqual(
            result, {
                'load_modal':
                False,
                'id_li':
                ID_LINK_EDIT_LU,
                'url':
                "#",
                'title':
                "{}.  {}".format(
                    "You can't modify learning unit under year : %(year)d" %
                    {"year": settings.YEAR_LIMIT_LUE_MODIFICATION},
                    "Modifications should be made in EPC for year %(year)d" % {
                        "year":
                        self.previous_learning_unit_year.academic_year.year
                    }),
                'class_li':
                DISABLED,
                'text':
                "",
                'data_target':
                ""
            })
コード例 #2
0
    def test_li_edit_lu_year_is_learning_unit_year_not_in_range_to_be_modified(
            self):
        managers = [
            create_person_with_permission_and_group(FACULTY_MANAGER_GROUP,
                                                    'can_edit_learningunit'),
            create_person_with_permission_and_group(UE_FACULTY_MANAGER_GROUP,
                                                    'can_edit_learningunit'),
        ]

        later_luy = LearningUnitYearFactory(
            academic_year=self.later_academic_year,
            learning_unit=LearningUnitFactory(existing_proposal_in_epc=False))
        self.context["learning_unit_year"] = later_luy

        for manager in managers:
            self.context["user"] = manager.user

            result = li_edit_lu(
                self.context, reverse('edit_learning_unit',
                                      args=[later_luy.id]), "")

            self.assertEqual(
                result,
                self._get_result_data_expected(ID_LINK_EDIT_LU,
                                               MSG_NOT_GOOD_RANGE_OF_YEARS))
コード例 #3
0
 def test_li_edit_lu_year_person_is_not_linked_to_entity_in_charge_of_lu(
         self):
     a_person = CentralManagerFactory()
     self.context['user'] = a_person.user
     result = li_edit_lu(self.context, self.url_edit, "")
     self.assertEqual(
         result,
         self._get_result_data_expected(
             ID_LINK_EDIT_LU, MSG_ONLY_IF_YOUR_ARE_LINK_TO_ENTITY))
コード例 #4
0
 def test_li_edit_lu_year_person_is_not_linked_to_entity_in_charge_of_lu(
         self):
     a_person = create_person_with_permission_and_group(
         CENTRAL_MANAGER_GROUP, 'can_edit_learningunit')
     self.context['user'] = a_person.user
     result = li_edit_lu(self.context, self.url_edit, "")
     self.assertEqual(
         result,
         self._get_result_data_expected(
             ID_LINK_EDIT_LU, MSG_ONLY_IF_YOUR_ARE_LINK_TO_ENTITY))
コード例 #5
0
    def test_li_edit_lu_everything_ok(self):
        result = li_edit_lu(self.context, self.url_edit, "")
        self.assertEqual(
            result,
            self._get_result_data_expected(ID_LINK_EDIT_LU, url=self.url_edit))

        result = li_edit_date_lu(self.context, self.url_edit, "")

        self.assertEqual(
            result,
            self._get_result_data_expected(ID_LINK_EDIT_DATE_LU,
                                           url=self.url_edit))
コード例 #6
0
    def test_li_edit_lu_year_is_learning_unit_year_not_in_range_to_be_modified(
            self):
        person_faculty = FacultyManagerFactory()
        later_luy = LearningUnitYearFactory(
            academic_year=self.later_academic_year,
            learning_unit=LearningUnitFactory(existing_proposal_in_epc=False))
        self.context["learning_unit_year"] = later_luy
        self.context["user"] = person_faculty.user

        result = li_edit_lu(self.context,
                            reverse('edit_learning_unit', args=[later_luy.id]),
                            "")

        self.assertEqual(
            result,
            self._get_result_data_expected(ID_LINK_EDIT_LU,
                                           MSG_NOT_GOOD_RANGE_OF_YEARS))
コード例 #7
0
    def test_li_edit_lu_year_is_editable_but_existing_proposal_in_epc(self):
        self.learning_unit.existing_proposal_in_epc = True
        self.learning_unit.save()
        self.context["learning_unit_year"] = self.learning_unit_year

        result = li_edit_lu(self.context, self.url_edit, "")
        self.assertEqual(
            result,
            self._get_result_data_expected(ID_LINK_EDIT_LU,
                                           MSG_EXISTING_PROPOSAL_IN_EPC))

        result = li_edit_date_lu(self.context, self.url_edit, "")
        self.assertEqual(
            result,
            self._get_result_data_expected(ID_LINK_EDIT_DATE_LU,
                                           MSG_EXISTING_PROPOSAL_IN_EPC))

        result = li_delete_all_lu(self.context, self.url_edit, '',
                                  "#modalDeleteLuy")
        expected = self._get_result_data_expected_delete(
            "link_delete_lus", MSG_EXISTING_PROPOSAL_IN_EPC)

        self.assertEqual(result, expected)

        self.proposal.learning_unit_year = self.learning_unit_year
        self.proposal.save()
        self.context["proposal"] = self.proposal
        result = li_suppression_proposal(self.context, self.url_edit, "")
        self.assertEqual(
            result,
            self._get_result_data_expected_for_proposal_suppression(
                "link_proposal_suppression", MSG_EXISTING_PROPOSAL_IN_EPC,
                DISABLED))
        result = li_modification_proposal(self.context, self.url_edit, "")

        self.assertEqual(
            result,
            self._get_result_data_expected(
                "link_proposal_modification",
                MSG_EXISTING_PROPOSAL_IN_EPC,
            ))
コード例 #8
0
    def test_li_edit_lu_year_non_editable_for_faculty_managers(self):
        faculty_managers = [
            create_person_with_permission_and_group(FACULTY_MANAGER_GROUP,
                                                    'can_edit_learningunit'),
            create_person_with_permission_and_group(UE_FACULTY_MANAGER_GROUP,
                                                    'can_edit_learningunit')
        ]
        for manager in faculty_managers:
            self.context[
                "learning_unit_year"] = self.previous_learning_unit_year
            self.context["user"] = manager.user

            result = li_edit_lu(self.context, self.url_edit, "")

            self.assertEqual(
                result, {
                    'load_modal':
                    False,
                    'id_li':
                    ID_LINK_EDIT_LU,
                    'url':
                    "#",
                    'title':
                    "{}.  {}".format(
                        "You can't modify learning unit under year : %(year)d"
                        % {"year": settings.YEAR_LIMIT_LUE_MODIFICATION},
                        "Modifications should be made in EPC for year %(year)d"
                        % {
                            "year":
                            self.previous_learning_unit_year.academic_year.year
                        }),
                    'class_li':
                    DISABLED,
                    'text':
                    "",
                    'data_target':
                    ""
                })